-module(l4u@l4u_type). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([unsafe_corece/1, to_native_dictionary/1, native_undefined/0, native_nil/0, native_true/0, native_false/0, unbox_l4u/1, box_l4u_int/1, box_l4u_float/1, box_l4u_string/1, box_l4u_symbol/1, box_l4u_keyword/1, box_l4u_list/1, box_l4u_vector/1, box_l4u_dict/1, box_l4u_native_value/2, box_l4u_native_function/2, box_l4u_custom_type/2, box_l4u_custom_type_def/2, box_l4u_ok/1]). -export_type([p_dic/0, ref/0, error_ex/0, info/0, description/0, scope/0, env_options/0, env_option/0, env/0, expr/0]). -type p_dic() :: any(). -type ref() :: any(). -type error_ex() :: {error_ex2, binary(), gleam@dynamic:dynamic_()}. -type info() :: {info, binary(), integer()}. -type description() :: {description, binary(), binary()}. -type scope() :: {scope, gleam@dict:dict(binary(), expr())} | {process_dict, p_dic()}. -type env_options() :: {env_options, boolean(), boolean()}. -type env_option() :: verbose | trace. -type env() :: {env, info(), p_dic(), gleam@dict:dict(binary(), expr()), gleam@dict:dict(binary(), expr()), list(scope()), env_options()}. -type expr() :: {printable, expr()} | undefined | nil | true | false | delimiter | {with_env, expr(), env()} | {local_continuation, list(expr()), env(), env()} | {continuation, list(expr()), env()} | {atom, ref()} | {int, integer()} | {float, float()} | {string, binary()} | {symbol, binary()} | {ex_var, binary(), binary()} | {keyword, binary()} | {list, list(expr())} | {vector, list(expr())} | {dict, list(expr())} | {bif, description(), fun((list(expr()), env()) -> expr())} | {bispform, description(), fun((list(expr()), env()) -> expr())} | {closure, description(), list(binary()), list(expr()), env()} | {macro, description(), list(binary()), list(expr()), env()} | {with_meta, expr(), expr()} | {native_value, binary(), gleam@dynamic:dynamic_()} | {native_function, binary(), gleam@dynamic:dynamic_()} | {repl_command, binary(), expr()} | {custom_type, binary(), expr()} | {custom_type_def, binary(), expr()}. -spec unsafe_corece(any()) -> any(). unsafe_corece(Value) -> l4u_ffi:unsafe_corece(Value). -spec to_native_dictionary(list(any())) -> any(). to_native_dictionary(Xs) -> l4u@sys_bridge_ffi:to_native_dictionary(Xs). -spec native_undefined() -> any(). native_undefined() -> _pipe = nil, l4u_ffi:unsafe_corece(_pipe). -spec native_nil() -> any(). native_nil() -> _pipe = nil, l4u_ffi:unsafe_corece(_pipe). -spec native_true() -> any(). native_true() -> _pipe = true, l4u_ffi:unsafe_corece(_pipe). -spec native_false() -> any(). native_false() -> _pipe = false, l4u_ffi:unsafe_corece(_pipe). -spec unbox_l4u(expr()) -> any(). unbox_l4u(Expr) -> case Expr of {printable, X} -> unbox_l4u(X); undefined -> native_undefined(); nil -> native_nil(); true -> native_true(); false -> native_false(); {int, X@1} -> l4u_ffi:unsafe_corece(X@1); {float, X@2} -> l4u_ffi:unsafe_corece(X@2); {string, X@3} -> l4u_ffi:unsafe_corece(X@3); {symbol, X@4} -> l4u_ffi:unsafe_corece(X@4); {keyword, X@5} -> l4u_ffi:unsafe_corece(X@5); {list, Xs} -> _pipe = gleam@list:map(Xs, fun unbox_l4u/1), l4u_ffi:unsafe_corece(_pipe); {vector, Xs@1} -> _pipe@1 = gleam@list:map(Xs@1, fun unbox_l4u/1), l4u_ffi:unsafe_corece(_pipe@1); {dict, Xs@2} -> _pipe@2 = l4u@sys_bridge_ffi:to_native_dictionary( gleam@list:map(Xs@2, fun unbox_l4u/1) ), l4u_ffi:unsafe_corece(_pipe@2); {native_value, _, X@6} -> l4u_ffi:unsafe_corece(X@6); {native_function, _, X@7} -> l4u_ffi:unsafe_corece(X@7); {custom_type, _, X@8} -> l4u_ffi:unsafe_corece(X@8); Else_val -> l4u_ffi:unsafe_corece(Else_val) end. -spec box_l4u_int(integer()) -> expr(). box_l4u_int(X) -> {int, X}. -spec box_l4u_float(float()) -> expr(). box_l4u_float(X) -> {float, X}. -spec box_l4u_string(binary()) -> expr(). box_l4u_string(X) -> {string, X}. -spec box_l4u_symbol(binary()) -> expr(). box_l4u_symbol(X) -> {symbol, X}. -spec box_l4u_keyword(binary()) -> expr(). box_l4u_keyword(X) -> {keyword, X}. -spec box_l4u_list(list(expr())) -> expr(). box_l4u_list(X) -> {list, X}. -spec box_l4u_vector(list(expr())) -> expr(). box_l4u_vector(X) -> {vector, X}. -spec box_l4u_dict(list(expr())) -> expr(). box_l4u_dict(X) -> {dict, X}. -spec box_l4u_native_value(binary(), gleam@dynamic:dynamic_()) -> expr(). box_l4u_native_value(Name, X) -> {native_value, Name, X}. -spec box_l4u_native_function(binary(), gleam@dynamic:dynamic_()) -> expr(). box_l4u_native_function(Name, X) -> {native_function, Name, X}. -spec box_l4u_custom_type(binary(), expr()) -> expr(). box_l4u_custom_type(Name, X) -> {custom_type, Name, X}. -spec box_l4u_custom_type_def(binary(), expr()) -> expr(). box_l4u_custom_type_def(Name, X) -> {custom_type_def, Name, X}. -spec box_l4u_ok(FIU) -> {ok, FIU} | {error, any()}. box_l4u_ok(X) -> {ok, X}.