This commit is contained in:
Luke Boswell 2024-11-11 10:22:58 +11:00
parent 743030fc99
commit 8a566dc339
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
260 changed files with 6344 additions and 2958 deletions

View file

@ -78,6 +78,7 @@ fn wrap_in_decode_custom_decode_with(
this_decode_with_var_slice,
this_decode_with_clos_var,
this_decode_with_ret_var,
Variable::PURE,
)),
);
@ -91,6 +92,7 @@ fn wrap_in_decode_custom_decode_with(
Loc::at_zero(decode_with_var),
this_decode_with_clos_var,
this_decode_with_ret_var,
Variable::PURE,
));
let decode_with_call = Call(
decode_with_fn,
@ -139,6 +141,7 @@ fn wrap_in_decode_custom_decode_with(
args_slice,
fn_clos_var,
decode_with_result_var,
Variable::PURE,
)),
);
@ -147,6 +150,7 @@ fn wrap_in_decode_custom_decode_with(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: decode_with_result_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: sorted_inner_decoder_captures,
@ -184,6 +188,7 @@ fn wrap_in_decode_custom_decode_with(
this_decode_custom_args,
this_decode_custom_clos_var,
this_decode_custom_ret_var,
Variable::PURE,
)),
);
@ -197,6 +202,7 @@ fn wrap_in_decode_custom_decode_with(
Loc::at_zero(decode_custom_var),
this_decode_custom_clos_var,
this_decode_custom_ret_var,
Variable::PURE,
));
let decode_custom_call = Call(
decode_custom_fn,

View file

@ -65,6 +65,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
elem_decoder_var_slice,
this_decode_list_clos_var,
this_decode_list_ret_var,
Variable::PURE,
)),
);
@ -78,6 +79,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
Loc::at_zero(decode_list_member),
this_decode_list_clos_var,
this_decode_list_ret_var,
Variable::PURE,
));
let decode_list_call = Call(

View file

@ -112,6 +112,7 @@ pub(crate) fn decoder(
.insert_into_vars([initial_state_var, step_var, finalizer_var]),
decode_record_lambda_set,
record_decoder_var,
Variable::PURE,
);
synth_var(env.subs, Content::Structure(flat_type))
@ -130,6 +131,7 @@ pub(crate) fn decoder(
)),
decode_record_lambda_set,
record_decoder_var,
Variable::PURE,
)),
vec![
(initial_state_var, Loc::at_zero(initial_state)),
@ -342,7 +344,12 @@ pub(super) fn step_field(
env.subs.set_content(
function_type,
Content::Structure(FlatType::Func(args_slice, closure_type, keep_or_skip_var)),
Content::Structure(FlatType::Func(
args_slice,
closure_type,
keep_or_skip_var,
Variable::PURE,
)),
)
};
@ -350,6 +357,7 @@ pub(super) fn step_field(
function_type,
closure_type,
return_type: keep_or_skip_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: step_field_closure,
captured_symbols: Vec::new(),
@ -406,8 +414,12 @@ fn custom_decoder(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variable, Expr
let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_var = {
let subs_slice = env.subs.insert_into_vars([this_custom_callback_var]);
let flat_type =
FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var);
let flat_type = FlatType::Func(
subs_slice,
decode_custom_closure_var,
decode_custom_ret_var,
Variable::PURE,
);
synth_var(env.subs, Content::Structure(flat_type))
};
@ -421,6 +433,7 @@ fn custom_decoder(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variable, Expr
Loc::at_zero(Expr::Var(Symbol::DECODE_CUSTOM, this_decode_custom_var)),
decode_custom_closure_var,
decode_custom_ret_var,
Variable::PURE,
)),
vec![(this_custom_callback_var, Loc::at_zero(custom_callback))],
CalledVia::Space,
@ -576,6 +589,7 @@ fn custom_decoder_lambda(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variabl
subs_slice,
custom_callback_lambda_set_var,
custom_callback_ret_var,
Variable::PURE,
)),
);
@ -587,6 +601,7 @@ fn custom_decoder_lambda(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variabl
function_type: this_custom_callback_var,
closure_type: custom_callback_lambda_set_var,
return_type: custom_callback_ret_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: custom_closure_symbol,
captured_symbols: vec![(state_arg_symbol, state_record_var)],
@ -985,6 +1000,7 @@ pub(super) fn finalizer(
env.subs.insert_into_vars([state_record_var, fmt_arg_var]),
closure_type,
return_type_var,
Variable::PURE,
);
// Fix up function_var so it's not Content::Error anymore
@ -995,6 +1011,7 @@ pub(super) fn finalizer(
function_type: function_var,
closure_type,
return_type: return_type_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: function_symbol,
captured_symbols: Vec::new(),
@ -1275,7 +1292,12 @@ fn make_decode_with_vars(
.insert_into_vars([bytes_arg_var, decoder_var, fmt_arg_var]);
let this_decode_with_var = synth_var(
env.subs,
Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)),
Content::Structure(FlatType::Func(
subs_slice,
lambda_set_var,
rec_var,
Variable::PURE,
)),
);
env.unify(decode_with_var, this_decode_with_var);
@ -1325,6 +1347,7 @@ pub(super) fn decode_with(
Loc::at_zero(Expr::Var(Symbol::DECODE_DECODE_WITH, this_decode_with_var)),
lambda_set_var,
rec_var,
Variable::PURE,
)),
vec![
(Variable::LIST_U8, Loc::at_zero(bytes_arg_expr)),

View file

@ -102,6 +102,7 @@ pub(crate) fn decoder(env: &mut Env, _def_symbol: Symbol, arity: u32) -> (Expr,
.insert_into_vars([state_var, step_var, finalizer_var]),
decode_record_lambda_set,
tuple_decoder_var,
Variable::PURE,
);
synth_var(env.subs, Content::Structure(flat_type))
@ -120,6 +121,7 @@ pub(crate) fn decoder(env: &mut Env, _def_symbol: Symbol, arity: u32) -> (Expr,
)),
decode_record_lambda_set,
tuple_decoder_var,
Variable::PURE,
)),
vec![
(state_var, Loc::at_zero(initial_state)),
@ -276,7 +278,12 @@ fn step_elem(
.insert_into_vars([bytes_arg_var, decoder_var, fmt_arg_var]);
let this_decode_with_var = synth_var(
env.subs,
Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)),
Content::Structure(FlatType::Func(
subs_slice,
lambda_set_var,
rec_var,
Variable::PURE,
)),
);
env.unify(decode_with_var, this_decode_with_var);
@ -490,6 +497,7 @@ fn step_elem(
Loc::at_zero(Expr::Var(Symbol::DECODE_DECODE_WITH, this_decode_with_var)),
lambda_set_var,
rec_var,
Variable::PURE,
)),
vec![
(
@ -545,6 +553,7 @@ fn step_elem(
subs_slice,
custom_callback_lambda_set_var,
custom_callback_ret_var,
Variable::PURE,
)),
);
@ -556,6 +565,7 @@ fn step_elem(
function_type: this_custom_callback_var,
closure_type: custom_callback_lambda_set_var,
return_type: custom_callback_ret_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: custom_closure_symbol,
captured_symbols: vec![(state_arg_symbol, state_record_var)],
@ -582,8 +592,12 @@ fn step_elem(
let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_var = {
let subs_slice = env.subs.insert_into_vars([this_custom_callback_var]);
let flat_type =
FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var);
let flat_type = FlatType::Func(
subs_slice,
decode_custom_closure_var,
decode_custom_ret_var,
Variable::PURE,
);
synth_var(env.subs, Content::Structure(flat_type))
};
@ -597,6 +611,7 @@ fn step_elem(
Loc::at_zero(Expr::Var(Symbol::DECODE_CUSTOM, this_decode_custom_var)),
decode_custom_closure_var,
decode_custom_ret_var,
Variable::PURE,
)),
vec![(this_custom_callback_var, Loc::at_zero(custom_callback))],
CalledVia::Space,
@ -703,7 +718,12 @@ fn step_elem(
env.subs.set_content(
function_type,
Content::Structure(FlatType::Func(args_slice, closure_type, keep_or_skip_var)),
Content::Structure(FlatType::Func(
args_slice,
closure_type,
keep_or_skip_var,
Variable::PURE,
)),
)
};
@ -711,6 +731,7 @@ fn step_elem(
function_type,
closure_type,
return_type: keep_or_skip_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: step_elem_closure,
captured_symbols: Vec::new(),
@ -888,6 +909,7 @@ fn finalizer(
env.subs.insert_into_vars([state_record_var]),
closure_type,
return_type_var,
Variable::PURE,
);
// Fix up function_var so it's not Content::Error anymore
@ -898,6 +920,7 @@ fn finalizer(
function_type: function_var,
closure_type,
return_type: return_type_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: function_symbol,
captured_symbols: Vec::new(),

View file

@ -132,6 +132,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
elem_var_slice,
to_encoder_clos_var,
elem_encoder_var,
Variable::PURE,
)),
);
@ -146,6 +147,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
Loc::at_zero(to_encoder_var),
to_encoder_clos_var,
elem_encoder_var,
Variable::PURE,
));
// toEncoder elem
@ -180,6 +182,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
elem_var_slice,
to_elem_encoder_lset,
elem_encoder_var,
Variable::PURE,
)),
);
@ -188,6 +191,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
function_type: to_elem_encoder_fn_var,
closure_type: to_elem_encoder_lset,
return_type: elem_encoder_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: to_elem_encoder_sym,
captured_symbols: vec![],
@ -216,6 +220,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
this_encode_list_args_slice,
this_encode_list_clos_var,
this_list_encoder_var,
Variable::PURE,
)),
);
@ -230,6 +235,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
Loc::at_zero(encode_list),
this_encode_list_clos_var,
this_list_encoder_var,
Variable::PURE,
));
// Encode.list lst to_elem_encoder
@ -274,6 +280,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
list_var_slice,
fn_clos_var,
this_encoder_var,
Variable::PURE,
)),
);
@ -282,6 +289,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_encoder_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -354,6 +362,7 @@ fn to_encoder_record(
field_var_slice,
to_encoder_clos_var,
encoder_var,
Variable::PURE,
)),
);
@ -368,6 +377,7 @@ fn to_encoder_record(
Loc::at_zero(to_encoder_var),
to_encoder_clos_var,
encoder_var,
Variable::PURE,
));
// toEncoder rcd.a
@ -435,6 +445,7 @@ fn to_encoder_record(
fields_list_var_slice,
encode_record_clos_var,
encoder_var,
Variable::PURE,
)),
);
@ -449,6 +460,7 @@ fn to_encoder_record(
Loc::at_zero(encode_record_var),
encode_record_clos_var,
encoder_var,
Variable::PURE,
));
// Encode.record [ { key: .., value: .. }, .. ]
@ -484,6 +496,7 @@ fn to_encoder_record(
record_var_slice,
fn_clos_var,
this_encoder_var,
Variable::PURE,
)),
);
@ -492,6 +505,7 @@ fn to_encoder_record(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_encoder_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -557,6 +571,7 @@ fn to_encoder_tuple(
elem_var_slice,
to_encoder_clos_var,
encoder_var,
Variable::PURE,
)),
);
@ -571,6 +586,7 @@ fn to_encoder_tuple(
Loc::at_zero(to_encoder_var),
to_encoder_clos_var,
encoder_var,
Variable::PURE,
));
// toEncoder tup.0
@ -618,6 +634,7 @@ fn to_encoder_tuple(
elem_encoders_list_var_slice,
encode_tuple_clos_var,
encoder_var,
Variable::PURE,
)),
);
@ -632,6 +649,7 @@ fn to_encoder_tuple(
Loc::at_zero(encode_tuple_var),
encode_tuple_clos_var,
encoder_var,
Variable::PURE,
));
// Encode.tuple [ { key: .., value: .. }, .. ]
@ -667,6 +685,7 @@ fn to_encoder_tuple(
tuple_var_slice,
fn_clos_var,
this_encoder_var,
Variable::PURE,
)),
);
@ -675,6 +694,7 @@ fn to_encoder_tuple(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_encoder_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -757,6 +777,7 @@ fn to_encoder_tag_union(
var_slice_of_sym_var,
to_encoder_clos_var,
encoder_var,
Variable::PURE,
)),
);
@ -772,6 +793,7 @@ fn to_encoder_tag_union(
Loc::at_zero(to_encoder_var),
to_encoder_clos_var,
encoder_var,
Variable::PURE,
));
// toEncoder rcd.a
@ -817,6 +839,7 @@ fn to_encoder_tag_union(
this_encode_tag_args_var_slice,
this_encode_tag_clos_var,
this_encoder_var,
Variable::PURE,
)),
);
@ -831,6 +854,7 @@ fn to_encoder_tag_union(
Loc::at_zero(encode_tag_var),
this_encode_tag_clos_var,
this_encoder_var,
Variable::PURE,
));
// Encode.tag "A" [ Encode.toEncoder v1, Encode.toEncoder v2 ]
@ -905,6 +929,7 @@ fn to_encoder_tag_union(
tag_union_var_slice,
fn_clos_var,
this_encoder_var,
Variable::PURE,
)),
);
@ -918,6 +943,7 @@ fn to_encoder_tag_union(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_encoder_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -973,6 +999,7 @@ fn wrap_in_encode_custom(
this_append_with_args_var_slice,
this_append_with_clos_var,
Variable::LIST_U8,
Variable::PURE,
)),
);
@ -986,6 +1013,7 @@ fn wrap_in_encode_custom(
Loc::at_zero(Var(Symbol::ENCODE_APPEND_WITH, this_append_with_fn_var)),
this_append_with_clos_var,
Variable::LIST_U8,
Variable::PURE,
));
// Encode.appendWith bytes encoder fmt
@ -1022,7 +1050,12 @@ fn wrap_in_encode_custom(
let args_slice = env.subs.insert_into_vars(vec![bytes_var, fmt_var]);
env.subs.set_content(
fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, Variable::LIST_U8)),
Content::Structure(FlatType::Func(
args_slice,
fn_clos_var,
Variable::LIST_U8,
Variable::PURE,
)),
);
// \bytes, fmt -[[fn_name captured_var]]-> Encode.appendWith bytes encoder fmt
@ -1030,6 +1063,7 @@ fn wrap_in_encode_custom(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: Variable::LIST_U8,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![(captured_symbol, captured_var)],
@ -1065,6 +1099,7 @@ fn wrap_in_encode_custom(
this_custom_args_var_slice,
this_custom_clos_var,
this_custom_encoder_var,
Variable::PURE,
)),
);
@ -1078,6 +1113,7 @@ fn wrap_in_encode_custom(
Loc::at_zero(Var(Symbol::ENCODE_CUSTOM, this_custom_fn_var)),
this_custom_clos_var, // -[clos]->
this_custom_encoder_var, // t' ~ Encoder fmt
Variable::PURE,
));
// Encode.custom \bytes, fmt -> Encode.appendWith bytes encoder fmt

View file

@ -475,6 +475,7 @@ fn call_hash_ability_member(
this_arguments_slice,
this_hash_clos_var,
this_out_hasher_var,
Variable::PURE,
)),
);
@ -489,6 +490,7 @@ fn call_hash_ability_member(
Loc::at_zero(hash_fn_head),
this_hash_clos_var,
this_out_hasher_var,
Variable::PURE,
));
let hash_arguments = vec![
@ -532,7 +534,12 @@ fn build_outer_derived_closure(
let args_slice = env.subs.insert_into_vars([hasher_var, val_var]);
env.subs.set_content(
fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, body_var)),
Content::Structure(FlatType::Func(
args_slice,
fn_clos_var,
body_var,
Variable::PURE,
)),
);
(fn_var, fn_clos_var)
@ -542,6 +549,7 @@ fn build_outer_derived_closure(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: body_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],

View file

@ -137,6 +137,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
elem_var_slice,
to_inspector_clos_var,
elem_inspector_var,
Variable::PURE,
)),
);
@ -152,6 +153,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
Loc::at_zero(to_inspector_var),
to_inspector_clos_var,
elem_inspector_var,
Variable::PURE,
));
// toInspector elem
@ -186,6 +188,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
elem_var_slice,
to_elem_inspector_lset,
elem_inspector_var,
Variable::PURE,
)),
);
@ -194,6 +197,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
function_type: to_elem_inspector_fn_var,
closure_type: to_elem_inspector_lset,
return_type: elem_inspector_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: to_elem_inspector_sym,
captured_symbols: vec![],
@ -223,6 +227,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
this_inspect_list_args_slice,
this_inspect_list_clos_var,
this_list_inspector_var,
Variable::PURE,
)),
);
@ -237,6 +242,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
Loc::at_zero(inspect_list),
this_inspect_list_clos_var,
this_list_inspector_var,
Variable::PURE,
));
// Inspect.list lst to_elem_inspector
@ -285,6 +291,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
list_var_slice,
fn_clos_var,
this_inspector_var,
Variable::PURE,
)),
);
@ -293,6 +300,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_inspector_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -365,6 +373,7 @@ fn to_inspector_record(
field_var_slice,
to_inspector_clos_var,
inspector_var,
Variable::PURE,
)),
);
@ -380,6 +389,7 @@ fn to_inspector_record(
Loc::at_zero(to_inspector_var),
to_inspector_clos_var,
inspector_var,
Variable::PURE,
));
// toInspector rcd.a
@ -447,6 +457,7 @@ fn to_inspector_record(
fields_list_var_slice,
inspect_record_clos_var,
inspector_var,
Variable::PURE,
)),
);
@ -461,6 +472,7 @@ fn to_inspector_record(
Loc::at_zero(inspect_record_var),
inspect_record_clos_var,
inspector_var,
Variable::PURE,
));
// Inspect.record [ { key: .., value: .. }, .. ]
@ -496,6 +508,7 @@ fn to_inspector_record(
record_var_slice,
fn_clos_var,
this_inspector_var,
Variable::PURE,
)),
);
@ -504,6 +517,7 @@ fn to_inspector_record(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_inspector_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -569,6 +583,7 @@ fn to_inspector_tuple(
elem_var_slice,
to_inspector_clos_var,
inspector_var,
Variable::PURE,
)),
);
@ -584,6 +599,7 @@ fn to_inspector_tuple(
Loc::at_zero(to_inspector_var),
to_inspector_clos_var,
inspector_var,
Variable::PURE,
));
// toInspector tup.0
@ -631,6 +647,7 @@ fn to_inspector_tuple(
elem_inspectors_list_var_slice,
inspect_tuple_clos_var,
inspector_var,
Variable::PURE,
)),
);
@ -645,6 +662,7 @@ fn to_inspector_tuple(
Loc::at_zero(inspect_tuple_var),
inspect_tuple_clos_var,
inspector_var,
Variable::PURE,
));
// Inspect.tuple [ { key: .., value: .. }, .. ]
@ -680,6 +698,7 @@ fn to_inspector_tuple(
tuple_var_slice,
fn_clos_var,
this_inspector_var,
Variable::PURE,
)),
);
@ -688,6 +707,7 @@ fn to_inspector_tuple(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_inspector_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -770,6 +790,7 @@ fn to_inspector_tag_union(
var_slice_of_sym_var,
to_inspector_clos_var,
inspector_var,
Variable::PURE,
)),
);
@ -785,6 +806,7 @@ fn to_inspector_tag_union(
Loc::at_zero(to_inspector_var),
to_inspector_clos_var,
inspector_var,
Variable::PURE,
));
// toInspector rcd.a
@ -834,6 +856,7 @@ fn to_inspector_tag_union(
this_inspect_tag_args_var_slice,
this_inspect_tag_clos_var,
this_inspector_var,
Variable::PURE,
)),
);
@ -848,6 +871,7 @@ fn to_inspector_tag_union(
Loc::at_zero(inspect_tag_var),
this_inspect_tag_clos_var,
this_inspector_var,
Variable::PURE,
));
// Inspect.tag "A" [ Inspect.toInspector v1, Inspect.toInspector v2 ]
@ -922,6 +946,7 @@ fn to_inspector_tag_union(
tag_union_var_slice,
fn_clos_var,
this_inspector_var,
Variable::PURE,
)),
);
@ -935,6 +960,7 @@ fn to_inspector_tag_union(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: this_inspector_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![],
@ -979,6 +1005,7 @@ fn wrap_in_inspect_custom(
this_apply_args_var_slice,
this_apply_clos_var,
fmt_var,
Variable::PURE,
)),
);
@ -992,6 +1019,7 @@ fn wrap_in_inspect_custom(
Loc::at_zero(Var(Symbol::INSPECT_APPLY, this_apply_fn_var)),
this_apply_clos_var,
fmt_var,
Variable::PURE,
));
// Inspect.apply inspector fmt
@ -1026,7 +1054,12 @@ fn wrap_in_inspect_custom(
let args_slice = env.subs.insert_into_vars(vec![fmt_var]);
env.subs.set_content(
fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, fmt_var)),
Content::Structure(FlatType::Func(
args_slice,
fn_clos_var,
fmt_var,
Variable::PURE,
)),
);
// \fmt -[[fn_name captured_var]]-> Inspect.apply inspector fmt
@ -1034,6 +1067,7 @@ fn wrap_in_inspect_custom(
function_type: fn_var,
closure_type: fn_clos_var,
return_type: fmt_var,
fx_type: Variable::PURE,
early_returns: vec![],
name: fn_name,
captured_symbols: vec![(captured_symbol, captured_var)],
@ -1062,6 +1096,7 @@ fn wrap_in_inspect_custom(
this_custom_args_var_slice,
this_custom_clos_var,
this_custom_inspector_var,
Variable::PURE,
)),
);
@ -1075,6 +1110,7 @@ fn wrap_in_inspect_custom(
Loc::at_zero(Var(Symbol::INSPECT_CUSTOM, this_custom_fn_var)),
this_custom_clos_var, // -[clos]->
this_custom_inspector_var, // t' ~ Inspector fmt
Variable::PURE,
));
// Inspect.custom \fmt -> Inspect.apply inspector fmt

View file

@ -4,6 +4,7 @@ use std::iter::once;
use std::sync::{Arc, Mutex};
use roc_can::abilities::SpecializationLambdaSets;
use roc_can::def::DefKind;
use roc_can::expr::Expr;
use roc_can::pattern::Pattern;
use roc_can::{def::Def, module::ExposedByModule};
@ -90,6 +91,7 @@ fn build_derived_body(
expr_var: body_type,
pattern_vars: once((derived_symbol, body_type)).collect(),
annotation: None,
kind: DefKind::Let,
};
(def, specialization_lambda_sets)