From b74c3e2693151e5a800111a4cc4f4885aad6fd89 Mon Sep 17 00:00:00 2001 From: imaqtkatt Date: Mon, 27 May 2024 15:09:23 -0300 Subject: [PATCH] Generate definitions for constructor tags --- src/fun/transform/encode_adts.rs | 35 ++++++++-- .../cli__compile_strict_loop.bend.snap | 8 ++- .../cli__no_check_net_size.bend.snap | 24 +++++-- tests/snapshots/cli__run_pretty.bend.snap | 2 +- .../compile_file__huge_tree.bend.snap | 8 ++- ...pile_file__redex_order_recursive.bend.snap | 16 +++-- .../desugar_file__bind_syntax.bend.snap | 16 +++-- .../desugar_file__combinators.bend.snap | 8 ++- .../desugar_file__deref_loop.bend.snap | 8 ++- ...ncode_pattern_match__adt_tup_era.bend.snap | 4 +- .../encode_pattern_match__and3.bend.snap | 8 ++- .../encode_pattern_match__bool.bend.snap | 8 ++- .../encode_pattern_match__bool_tup.bend.snap | 8 ++- .../encode_pattern_match__box.bend.snap | 4 +- .../encode_pattern_match__common.bend.snap | 68 ++++++++++++++----- .../encode_pattern_match__concat.bend.snap | 8 ++- ...encode_pattern_match__concat_def.bend.snap | 8 ++- ..._pattern_match__definition_merge.bend.snap | 16 +++-- .../encode_pattern_match__expr.bend.snap | 52 ++++++++++---- ...code_pattern_match__is_some_some.bend.snap | 8 ++- ...e_pattern_match__list_merge_sort.bend.snap | 16 +++-- ...match__match_adt_unscoped_in_arm.bend.snap | 8 ++- ...match__match_adt_unscoped_lambda.bend.snap | 8 ++- ...rn_match__match_adt_unscoped_var.bend.snap | 8 ++- ..._match__match_auto_linearization.bend.snap | 4 +- ..._match__match_num_adt_tup_parser.bend.snap | 16 +++-- ...code_pattern_match__match_syntax.bend.snap | 8 ++- ...tern_match__non_matching_fst_arg.bend.snap | 8 ++- ...rn_match__pattern_match_encoding.bend.snap | 20 ++++-- .../encode_pattern_match__var_only.bend.snap | 8 ++- .../encode_pattern_match__weekday.bend.snap | 28 ++++++-- tests/snapshots/examples__gen_tree.bend.snap | 2 +- .../examples__insertion_sort.bend.snap | 2 +- tests/snapshots/examples__queue.bend.snap | 2 +- .../snapshots/mutual_recursion__len.bend.snap | 8 ++- tests/snapshots/parse_file__imp_map.bend.snap | 8 ++- .../parse_file__imp_program.bend.snap | 28 ++++++-- .../parse_file__scape_chars.bend.snap | 8 ++- tests/snapshots/run_file__adt_match.bend.snap | 2 +- .../run_file__basic_num_ops.bend.snap | 2 +- tests/snapshots/run_file__box.bend.snap | 2 +- tests/snapshots/run_file__chars.bend.snap | 2 +- .../run_file__comprehension.bend.snap | 2 +- .../run_file__do_block_mixed.bend.snap | 2 +- .../run_file__escape_sequences.bend.snap | 2 +- .../run_file__fold_with_state.bend.snap | 2 +- .../run_file__guide_bend_7tree.bend.snap | 2 +- .../run_file__guide_enumerate.bend.snap | 2 +- .../run_file__guide_if_age.bend.snap | 2 +- .../run_file__guide_is_even_str.bend.snap | 2 +- .../run_file__guide_list_ctrs.bend.snap | 2 +- .../run_file__guide_list_sugar.bend.snap | 2 +- .../run_file__list_resugar.bend.snap | 2 +- .../run_file__list_reverse.bend.snap | 2 +- tests/snapshots/run_file__list_take.bend.snap | 2 +- .../run_file__match_builtins.bend.snap | 2 +- ...n_file__match_num_adt_tup_parser.bend.snap | 2 +- .../run_file__match_num_num_to_char.bend.snap | 2 +- ...run_file__match_num_succ_complex.bend.snap | 2 +- tests/snapshots/run_file__match_str.bend.snap | 2 +- .../run_file__names_hyphen_toplevel.bend.snap | 2 +- ...run_file__nested_list_and_string.bend.snap | 2 +- .../snapshots/run_file__nested_str.bend.snap | 2 +- tests/snapshots/run_file__open.bend.snap | 2 +- tests/snapshots/run_file__ops.bend.snap | 2 +- ...un_file__readback_list_other_ctr.bend.snap | 2 +- .../snapshots/run_file__str_concat.bend.snap | 2 +- .../run_file__tup_list_strings.bend.snap | 2 +- .../run_file__unaplied_str.bend.snap | 2 +- tests/snapshots/run_file__world.bend.snap | 2 +- .../run_file__wrong_string.bend.snap | 2 +- .../scott_triggers_unused__test.bend.snap | 12 ++-- .../simplify_matches__adt_tup_era.bend.snap | 4 +- .../simplify_matches__already_flat.bend.snap | 36 +++++++--- .../simplify_matches__bits_dec.bend.snap | 12 +++- ...plify_matches__complex_with_case.bend.snap | 8 ++- ...plify_matches__double_unwrap_box.bend.snap | 4 +- ...ify_matches__double_unwrap_maybe.bend.snap | 8 ++- ...y_matches__flatten_with_terminal.bend.snap | 8 ++- ...ify_matches__linearize_match_all.bend.snap | 8 ++- .../simplify_matches__nested.bend.snap | 20 ++++-- .../simplify_matches__nested2.bend.snap | 8 ++- .../simplify_matches__nested_0ary.bend.snap | 8 ++- 83 files changed, 511 insertions(+), 198 deletions(-) diff --git a/src/fun/transform/encode_adts.rs b/src/fun/transform/encode_adts.rs index fe6c0d45..b5b239d6 100644 --- a/src/fun/transform/encode_adts.rs +++ b/src/fun/transform/encode_adts.rs @@ -7,13 +7,31 @@ impl Book { /// Defines a function for each constructor in each ADT in the book. pub fn encode_adts(&mut self, adt_encoding: AdtEncoding) { let mut defs = vec![]; - for adt in self.adts.values() { + let mut tags = vec![]; + + for (adt_name, adt) in self.adts.iter() { for (ctr_idx, (ctr_name, fields)) in adt.ctrs.iter().enumerate() { let ctrs: Vec<_> = adt.ctrs.keys().cloned().collect(); let body = match adt_encoding { AdtEncoding::Scott => encode_ctr_scott(fields.iter().map(|f| &f.nam), ctrs, ctr_name), - AdtEncoding::NumScott => encode_ctr_num_scott(fields.iter().map(|f| &f.nam), ctr_idx), + AdtEncoding::NumScott => { + let is_object = adt_name == ctr_name; + if is_object { + let tag = Name::new(format!("{ctr_name}/tag")); + let body = encode_ctr_num_scott(fields.iter().map(|f| &f.nam), &tag); + let tag_def = make_tag_def(ctr_idx, &tag, adt); + tags.push((tag, tag_def)); + body + } else { + let (typ, ctr) = ctr_name.rsplit_once('/').expect("To split at '/'"); + let tag = Name::new(format!("{typ}/{ctr}/tag")); + let body = encode_ctr_num_scott(fields.iter().map(|f| &f.nam), &tag); + let tag_def = make_tag_def(ctr_idx, &tag, adt); + tags.push((tag, tag_def)); + body + } + } }; let rules = vec![Rule { pats: vec![], body }]; @@ -22,6 +40,7 @@ impl Book { } } self.defs.extend(defs); + self.defs.extend(tags); } } @@ -36,16 +55,18 @@ fn encode_ctr_scott<'a>( ctr_args.cloned().rfold(lam, |acc, arg| Term::lam(Pattern::Var(Some(arg)), acc)) } -fn encode_ctr_num_scott<'a>( - ctr_args: impl DoubleEndedIterator + Clone, - ctr_idx: usize, -) -> Term { +fn encode_ctr_num_scott<'a>(ctr_args: impl DoubleEndedIterator + Clone, tag: &str) -> Term { let nam = Name::new("%x"); // λa1 .. λan λx (x TAG a1 .. an) let term = Term::Var { nam: nam.clone() }; - let tag = Term::Num { val: Num::U24(ctr_idx as u32) }; + let tag = Term::r#ref(tag); let term = Term::app(term, tag); let term = Term::call(term, ctr_args.clone().cloned().map(|nam| Term::Var { nam })); let term = Term::lam(Pattern::Var(Some(nam)), term); Term::rfold_lams(term, ctr_args.cloned().map(Some)) } + +fn make_tag_def(ctr_idx: usize, tag: &Name, adt: &crate::fun::Adt) -> Definition { + let tag_rule = vec![Rule { pats: vec![], body: Term::Num { val: Num::U24(ctr_idx as u32) } }]; + Definition { name: tag.clone(), rules: tag_rule, builtin: adt.builtin } +} diff --git a/tests/snapshots/cli__compile_strict_loop.bend.snap b/tests/snapshots/cli__compile_strict_loop.bend.snap index 2b1ac765..ee58a768 100644 --- a/tests/snapshots/cli__compile_strict_loop.bend.snap +++ b/tests/snapshots/cli__compile_strict_loop.bend.snap @@ -5,9 +5,13 @@ input_file: tests/golden_tests/cli/compile_strict_loop.bend @A = (((?((0 (* (* (a b)))) c) c) d) d) & @A ~ (a b) -@List/Cons = (a (b ((1 (a (b c))) c))) +@List/Cons = (a (b ((@List/Cons/tag (a (b c))) c))) -@List/Nil = ((0 a) a) +@List/Cons/tag = 1 + +@List/Nil = ((@List/Nil/tag a) a) + +@List/Nil/tag = 0 @main = c & @A ~ (b c) diff --git a/tests/snapshots/cli__no_check_net_size.bend.snap b/tests/snapshots/cli__no_check_net_size.bend.snap index 8f5597b8..a3ad9dc1 100644 --- a/tests/snapshots/cli__no_check_net_size.bend.snap +++ b/tests/snapshots/cli__no_check_net_size.bend.snap @@ -2,11 +2,17 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/cli/no_check_net_size.bend --- -@Arr/Leaf = (a ((1 (a b)) b)) +@Arr/Leaf = (a ((@Arr/Leaf/tag (a b)) b)) -@Arr/Node = (a (b ((2 (a (b c))) c))) +@Arr/Leaf/tag = 1 -@Arr/Null = ((0 a) a) +@Arr/Node = (a (b ((@Arr/Node/tag (a (b c))) c))) + +@Arr/Node/tag = 2 + +@Arr/Null = ((@Arr/Null/tag a) a) + +@Arr/Null/tag = 0 @Gen = (a b) & @Gen.go ~ (a (0 b)) @@ -30,11 +36,17 @@ input_file: tests/golden_tests/cli/no_check_net_size.bend @Main__C2 = a & @Sort ~ (@Main__C1 a) -@Map_/Both = (a (b ((2 (a (b c))) c))) +@Map_/Both = (a (b ((@Map_/Both/tag (a (b c))) c))) -@Map_/Free = ((0 a) a) +@Map_/Both/tag = 2 -@Map_/Used = ((1 a) a) +@Map_/Free = ((@Map_/Free/tag a) a) + +@Map_/Free/tag = 0 + +@Map_/Used = ((@Map_/Used/tag a) a) + +@Map_/Used/tag = 1 @Merge = ((@Merge__C13 a) a) diff --git a/tests/snapshots/cli__run_pretty.bend.snap b/tests/snapshots/cli__run_pretty.bend.snap index ff7d1150..b906a8e4 100644 --- a/tests/snapshots/cli__run_pretty.bend.snap +++ b/tests/snapshots/cli__run_pretty.bend.snap @@ -8,5 +8,5 @@ Result: 0: "ba"; _: λ* "ta"; }; - _: λ* "ata"; + _: λ* λb (b String/Cons/tag 97 λc (c String/Cons/tag 116 λd (d String/Cons/tag 97 ""))); } diff --git a/tests/snapshots/compile_file__huge_tree.bend.snap b/tests/snapshots/compile_file__huge_tree.bend.snap index a1d30ecd..2ba2ce2d 100644 --- a/tests/snapshots/compile_file__huge_tree.bend.snap +++ b/tests/snapshots/compile_file__huge_tree.bend.snap @@ -2,9 +2,13 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/compile_file/huge_tree.bend --- -@Tree/Leaf = (a ((1 (a b)) b)) +@Tree/Leaf = (a ((@Tree/Leaf/tag (a b)) b)) -@Tree/Node = (a (b (c (d ((0 (a (b (c (d e))))) e))))) +@Tree/Leaf/tag = 1 + +@Tree/Node = (a (b (c (d ((@Tree/Node/tag (a (b (c (d e))))) e))))) + +@Tree/Node/tag = 0 @main = e & @Tree/Node ~ (a (b (c (d e)))) diff --git a/tests/snapshots/compile_file__redex_order_recursive.bend.snap b/tests/snapshots/compile_file__redex_order_recursive.bend.snap index 47eb1d89..077b3106 100644 --- a/tests/snapshots/compile_file__redex_order_recursive.bend.snap +++ b/tests/snapshots/compile_file__redex_order_recursive.bend.snap @@ -77,9 +77,13 @@ input_file: tests/golden_tests/compile_file/redex_order_recursive.bend @List.sum__C1 = (?(((a a) @List.sum__C0) b) b) -@List/Cons = (a (b ((1 (a (b c))) c))) +@List/Cons = (a (b ((@List/Cons/tag (a (b c))) c))) -@List/Nil = ((0 a) a) +@List/Cons/tag = 1 + +@List/Nil = ((@List/Nil/tag a) a) + +@List/Nil/tag = 0 @Tree.flip = ((@Tree.flip__C2 a) a) @@ -132,9 +136,13 @@ input_file: tests/golden_tests/compile_file/redex_order_recursive.bend @Tree.nodes__C1 = (?((@Tree.nodes__C0 (* (* 0))) a) a) -@Tree/leaf = (a ((1 (a b)) b)) +@Tree/leaf = (a ((@Tree/leaf/tag (a b)) b)) -@Tree/node = (a (b ((0 (a (b c))) c))) +@Tree/leaf/tag = 1 + +@Tree/node = (a (b ((@Tree/node/tag (a (b c))) c))) + +@Tree/node/tag = 0 @add = ((@add__C0 ((a a) b)) b) diff --git a/tests/snapshots/desugar_file__bind_syntax.bend.snap b/tests/snapshots/desugar_file__bind_syntax.bend.snap index 84eb49c6..8071bb82 100644 --- a/tests/snapshots/desugar_file__bind_syntax.bend.snap +++ b/tests/snapshots/desugar_file__bind_syntax.bend.snap @@ -10,13 +10,21 @@ input_file: tests/golden_tests/desugar_file/bind_syntax.bend (Main) = (Result/bind Main__C1 Main__C0) -(String/Nil) = λa (a 0) +(String/Nil) = λa (a String/Nil/tag) -(String/Cons) = λa λb λc (c 1 a b) +(String/Cons) = λa λb λc (c String/Cons/tag a b) -(Result/Ok) = λa λb (b 0 a) +(Result/Ok) = λa λb (b Result/Ok/tag a) -(Result/Err) = λa λb (b 1 a) +(Result/Err) = λa λb (b Result/Err/tag a) + +(String/Nil/tag) = 0 + +(String/Cons/tag) = 1 + +(Result/Ok/tag) = 0 + +(Result/Err/tag) = 1 (Main__C0) = λa (Result/bind (safe_rem a 0) λb b) diff --git a/tests/snapshots/desugar_file__combinators.bend.snap b/tests/snapshots/desugar_file__combinators.bend.snap index dd38fdaf..9ff28da8 100644 --- a/tests/snapshots/desugar_file__combinators.bend.snap +++ b/tests/snapshots/desugar_file__combinators.bend.snap @@ -24,9 +24,13 @@ input_file: tests/golden_tests/desugar_file/combinators.bend (Main) = list -(List/Nil) = λa (a 0) +(List/Nil) = λa (a List/Nil/tag) -(List/Cons) = λa λb λc (c 1 a b) +(List/Cons) = λa λb λc (c List/Cons/tag a b) + +(List/Nil/tag) = 0 + +(List/Cons/tag) = 1 (A__C0) = let {a b} = A; λc (a b c) diff --git a/tests/snapshots/desugar_file__deref_loop.bend.snap b/tests/snapshots/desugar_file__deref_loop.bend.snap index 17b251ec..4cedbf62 100644 --- a/tests/snapshots/desugar_file__deref_loop.bend.snap +++ b/tests/snapshots/desugar_file__deref_loop.bend.snap @@ -8,9 +8,13 @@ input_file: tests/golden_tests/desugar_file/deref_loop.bend (main) = (foo 0) -(nat/succ) = λa λb (b 0 a) +(nat/succ) = λa λb (b nat/succ/tag a) -(nat/zero) = λa (a 1) +(nat/zero) = λa (a nat/zero/tag) + +(nat/succ/tag) = 0 + +(nat/zero/tag) = 1 (foo__C0) = λ* (bar 0) diff --git a/tests/snapshots/encode_pattern_match__adt_tup_era.bend.snap b/tests/snapshots/encode_pattern_match__adt_tup_era.bend.snap index 977f7d7b..4ccd0b47 100644 --- a/tests/snapshots/encode_pattern_match__adt_tup_era.bend.snap +++ b/tests/snapshots/encode_pattern_match__adt_tup_era.bend.snap @@ -14,4 +14,6 @@ NumScott (Main) = (Foo (Tuple/Pair 1 5)) -(Tuple/Pair) = λa λb λc (c 0 a b) +(Tuple/Pair) = λa λb λc (c Tuple/Pair/tag a b) + +(Tuple/Pair/tag) = 0 diff --git a/tests/snapshots/encode_pattern_match__and3.bend.snap b/tests/snapshots/encode_pattern_match__and3.bend.snap index 92cedfe4..14ca7da2 100644 --- a/tests/snapshots/encode_pattern_match__and3.bend.snap +++ b/tests/snapshots/encode_pattern_match__and3.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = (And (Bool/F, Bool/T, Bool/F)) -(Bool/T) = λa (a 0) +(Bool/T) = λa (a Bool/T/tag) -(Bool/F) = λa (a 1) +(Bool/F) = λa (a Bool/F/tag) + +(Bool/T/tag) = 0 + +(Bool/F/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__bool.bend.snap b/tests/snapshots/encode_pattern_match__bool.bend.snap index 8b900f22..5fb408e5 100644 --- a/tests/snapshots/encode_pattern_match__bool.bend.snap +++ b/tests/snapshots/encode_pattern_match__bool.bend.snap @@ -28,6 +28,10 @@ NumScott (and4) = λa (a λb switch b { 0: λc (c λd switch d { 0: bool/true; _: λ* bool/false; }); _: λ* λ* bool/false; }) -(bool/true) = λa (a 0) +(bool/true) = λa (a bool/true/tag) -(bool/false) = λa (a 1) +(bool/false) = λa (a bool/false/tag) + +(bool/true/tag) = 0 + +(bool/false/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__bool_tup.bend.snap b/tests/snapshots/encode_pattern_match__bool_tup.bend.snap index 9b033fc8..c8b2e15b 100644 --- a/tests/snapshots/encode_pattern_match__bool_tup.bend.snap +++ b/tests/snapshots/encode_pattern_match__bool_tup.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = (foo (Bool/F, Bool/T)) -(Bool/T) = λa (a 0) +(Bool/T) = λa (a Bool/T/tag) -(Bool/F) = λa (a 1) +(Bool/F) = λa (a Bool/F/tag) + +(Bool/T/tag) = 0 + +(Bool/F/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__box.bend.snap b/tests/snapshots/encode_pattern_match__box.bend.snap index d16959a7..02f4208b 100644 --- a/tests/snapshots/encode_pattern_match__box.bend.snap +++ b/tests/snapshots/encode_pattern_match__box.bend.snap @@ -10,4 +10,6 @@ Scott NumScott (unbox) = λa (a λb switch b { 0: λc c; _: *; }) -(box/new) = λa λb (b 0 a) +(box/new) = λa λb (b box/new/tag a) + +(box/new/tag) = 0 diff --git a/tests/snapshots/encode_pattern_match__common.bend.snap b/tests/snapshots/encode_pattern_match__common.bend.snap index 06257804..802b979f 100644 --- a/tests/snapshots/encode_pattern_match__common.bend.snap +++ b/tests/snapshots/encode_pattern_match__common.bend.snap @@ -38,36 +38,70 @@ Scott (Direction/West) = λ* λ* λ* λd d NumScott -(Box/Filled) = λa λb (b 0 a) +(Box/Filled) = λa λb (b Box/Filled/tag a) -(Box/Empty) = λa (a 1) +(Box/Empty) = λa (a Box/Empty/tag) -(Option/Some) = λa λb (b 0 a) +(Option/Some) = λa λb (b Option/Some/tag a) -(Option/None) = λa (a 1) +(Option/None) = λa (a Option/None/tag) -(Result_/Ok) = λa λb (b 0 a) +(Result_/Ok) = λa λb (b Result_/Ok/tag a) -(Result_/Err) = λa λb (b 1 a) +(Result_/Err) = λa λb (b Result_/Err/tag a) -(List_/Cons) = λa λb λc (c 0 a b) +(List_/Cons) = λa λb λc (c List_/Cons/tag a b) -(List_/Nil) = λa (a 1) +(List_/Nil) = λa (a List_/Nil/tag) -(Bool/True) = λa (a 0) +(Bool/True) = λa (a Bool/True/tag) -(Bool/False) = λa (a 1) +(Bool/False) = λa (a Bool/False/tag) -(Light/Red) = λa (a 0) +(Light/Red) = λa (a Light/Red/tag) -(Light/Yellow) = λa (a 1) +(Light/Yellow) = λa (a Light/Yellow/tag) -(Light/Green) = λa (a 2) +(Light/Green) = λa (a Light/Green/tag) -(Direction/North) = λa (a 0) +(Direction/North) = λa (a Direction/North/tag) -(Direction/South) = λa (a 1) +(Direction/South) = λa (a Direction/South/tag) -(Direction/East) = λa (a 2) +(Direction/East) = λa (a Direction/East/tag) -(Direction/West) = λa (a 3) +(Direction/West) = λa (a Direction/West/tag) + +(Box/Filled/tag) = 0 + +(Box/Empty/tag) = 1 + +(Option/Some/tag) = 0 + +(Option/None/tag) = 1 + +(Result_/Ok/tag) = 0 + +(Result_/Err/tag) = 1 + +(List_/Cons/tag) = 0 + +(List_/Nil/tag) = 1 + +(Bool/True/tag) = 0 + +(Bool/False/tag) = 1 + +(Light/Red/tag) = 0 + +(Light/Yellow/tag) = 1 + +(Light/Green/tag) = 2 + +(Direction/North/tag) = 0 + +(Direction/South/tag) = 1 + +(Direction/East/tag) = 2 + +(Direction/West/tag) = 3 diff --git a/tests/snapshots/encode_pattern_match__concat.bend.snap b/tests/snapshots/encode_pattern_match__concat.bend.snap index a30b8a0e..6d634e7e 100644 --- a/tests/snapshots/encode_pattern_match__concat.bend.snap +++ b/tests/snapshots/encode_pattern_match__concat.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = (String/concat (String/Cons 97 (String/Cons 98 String/Nil)) (String/Cons 99 (String/Cons 100 String/Nil))) -(String/Nil) = λa (a 0) +(String/Nil) = λa (a String/Nil/tag) -(String/Cons) = λa λb λc (c 1 a b) +(String/Cons) = λa λb λc (c String/Cons/tag a b) + +(String/Nil/tag) = 0 + +(String/Cons/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__concat_def.bend.snap b/tests/snapshots/encode_pattern_match__concat_def.bend.snap index c718b45c..4bd08076 100644 --- a/tests/snapshots/encode_pattern_match__concat_def.bend.snap +++ b/tests/snapshots/encode_pattern_match__concat_def.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = (concat (String/Cons 97 (String/Cons 98 String/Nil)) (String/Cons 99 (String/Cons 100 String/Nil))) -(String/Nil) = λa (a 0) +(String/Nil) = λa (a String/Nil/tag) -(String/Cons) = λa λb λc (c 1 a b) +(String/Cons) = λa λb λc (c String/Cons/tag a b) + +(String/Nil/tag) = 0 + +(String/Cons/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__definition_merge.bend.snap b/tests/snapshots/encode_pattern_match__definition_merge.bend.snap index 60aa5d21..a06b69d9 100644 --- a/tests/snapshots/encode_pattern_match__definition_merge.bend.snap +++ b/tests/snapshots/encode_pattern_match__definition_merge.bend.snap @@ -16,10 +16,18 @@ Scott NumScott (Foo) = λa (a λb switch b { 0: λ* λd (d λe switch e { 0: λ* 1; _: λ* λ* 2; }); _: λ* λ* λi (i λj switch j { 0: λ* 3; _: λ* λ* 3; }); }) -(Either/Left) = λa λb (b 0 a) +(Either/Left) = λa λb (b Either/Left/tag a) -(Either/Right) = λa λb (b 1 a) +(Either/Right) = λa λb (b Either/Right/tag a) -(Bool/Bool/True) = λa (a 0) +(Bool/Bool/True) = λa (a Bool/Bool/True/tag) -(Bool/Bool/False) = λa (a 1) +(Bool/Bool/False) = λa (a Bool/Bool/False/tag) + +(Either/Left/tag) = 0 + +(Either/Right/tag) = 1 + +(Bool/Bool/True/tag) = 0 + +(Bool/Bool/False/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__expr.bend.snap b/tests/snapshots/encode_pattern_match__expr.bend.snap index a0b8cbfc..69afdf37 100644 --- a/tests/snapshots/encode_pattern_match__expr.bend.snap +++ b/tests/snapshots/encode_pattern_match__expr.bend.snap @@ -30,28 +30,54 @@ Scott (Op/Div) = λ* λ* λ* λd d NumScott -(Expr/Var) = λa λb (b 0 a) +(Expr/Var) = λa λb (b Expr/Var/tag a) -(Expr/Num) = λa λb (b 1 a) +(Expr/Num) = λa λb (b Expr/Num/tag a) -(Expr/App) = λa λb λc (c 2 a b) +(Expr/App) = λa λb λc (c Expr/App/tag a b) -(Expr/Fun) = λa λb λc (c 3 a b) +(Expr/Fun) = λa λb λc (c Expr/Fun/tag a b) -(Expr/If) = λa λb λc λd (d 4 a b c) +(Expr/If) = λa λb λc λd (d Expr/If/tag a b c) -(Expr/Let) = λa λb λc λd (d 5 a b c) +(Expr/Let) = λa λb λc λd (d Expr/Let/tag a b c) -(Expr/Dup) = λa λb λc λd λe (e 6 a b c d) +(Expr/Dup) = λa λb λc λd λe (e Expr/Dup/tag a b c d) -(Expr/Tup) = λa λb λc (c 7 a b) +(Expr/Tup) = λa λb λc (c Expr/Tup/tag a b) -(Expr/Op2) = λa λb λc λd (d 8 a b c) +(Expr/Op2) = λa λb λc λd (d Expr/Op2/tag a b c) -(Op/Add) = λa (a 0) +(Op/Add) = λa (a Op/Add/tag) -(Op/Sub) = λa (a 1) +(Op/Sub) = λa (a Op/Sub/tag) -(Op/Mul) = λa (a 2) +(Op/Mul) = λa (a Op/Mul/tag) -(Op/Div) = λa (a 3) +(Op/Div) = λa (a Op/Div/tag) + +(Expr/Var/tag) = 0 + +(Expr/Num/tag) = 1 + +(Expr/App/tag) = 2 + +(Expr/Fun/tag) = 3 + +(Expr/If/tag) = 4 + +(Expr/Let/tag) = 5 + +(Expr/Dup/tag) = 6 + +(Expr/Tup/tag) = 7 + +(Expr/Op2/tag) = 8 + +(Op/Add/tag) = 0 + +(Op/Sub/tag) = 1 + +(Op/Mul/tag) = 2 + +(Op/Div/tag) = 3 diff --git a/tests/snapshots/encode_pattern_match__is_some_some.bend.snap b/tests/snapshots/encode_pattern_match__is_some_some.bend.snap index da2ba143..45d78936 100644 --- a/tests/snapshots/encode_pattern_match__is_some_some.bend.snap +++ b/tests/snapshots/encode_pattern_match__is_some_some.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = (some_some (Option/Some 1)) -(Option/Some) = λa λb (b 0 a) +(Option/Some) = λa λb (b Option/Some/tag a) -(Option/None) = λa (a 1) +(Option/None) = λa (a Option/None/tag) + +(Option/Some/tag) = 0 + +(Option/None/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap b/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap index dc773d46..120ffc84 100644 --- a/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap +++ b/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap @@ -40,10 +40,18 @@ NumScott (Merge) = λa λb (b λc switch c { 0: λd λe λf λg (g λh switch h { 0: λi let {i i_2 i_3} = i; λj let {j j_2} = j; λk let {k k_2 k_3} = k; λl let {l l_2 l_3} = l; λm let {m m_2} = m; (If (k l i) (List_/Cons l_2 (Merge k_2 m (List_/Cons i_2 j))) (List_/Cons i_3 (Merge k_3 (List_/Cons l_3 m_2) j_2))); _: λ* λ* λq λr (List_/Cons q r); } f d e); _: λ* λ* λt t; } a) -(Bool/True) = λa (a 0) +(Bool/True) = λa (a Bool/True/tag) -(Bool/False) = λa (a 1) +(Bool/False) = λa (a Bool/False/tag) -(List_/Cons) = λa λb λc (c 0 a b) +(List_/Cons) = λa λb λc (c List_/Cons/tag a b) -(List_/Nil) = λa (a 1) +(List_/Nil) = λa (a List_/Nil/tag) + +(Bool/True/tag) = 0 + +(Bool/False/tag) = 1 + +(List_/Cons/tag) = 0 + +(List_/Nil/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_adt_unscoped_in_arm.bend.snap b/tests/snapshots/encode_pattern_match__match_adt_unscoped_in_arm.bend.snap index 90ea071a..bb3caa30 100644 --- a/tests/snapshots/encode_pattern_match__match_adt_unscoped_in_arm.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_adt_unscoped_in_arm.bend.snap @@ -12,6 +12,10 @@ Scott NumScott (main) = λ* λ$x $x -(bool/T) = λa (a 0) +(bool/T) = λa (a bool/T/tag) -(bool/F) = λa (a 1) +(bool/F) = λa (a bool/F/tag) + +(bool/T/tag) = 0 + +(bool/F/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_adt_unscoped_lambda.bend.snap b/tests/snapshots/encode_pattern_match__match_adt_unscoped_lambda.bend.snap index ccb632a0..0d83206e 100644 --- a/tests/snapshots/encode_pattern_match__match_adt_unscoped_lambda.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_adt_unscoped_lambda.bend.snap @@ -12,6 +12,10 @@ Scott NumScott (main) = (Maybe/Some 1 λa switch a { 0: λ$x *; _: λ* λb b; } $x) -(Maybe/None) = λa (a 0) +(Maybe/None) = λa (a Maybe/None/tag) -(Maybe/Some) = λa λb (b 1 a) +(Maybe/Some) = λa λb (b Maybe/Some/tag a) + +(Maybe/None/tag) = 0 + +(Maybe/Some/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_adt_unscoped_var.bend.snap b/tests/snapshots/encode_pattern_match__match_adt_unscoped_var.bend.snap index 9a660fef..7ac3cdab 100644 --- a/tests/snapshots/encode_pattern_match__match_adt_unscoped_var.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_adt_unscoped_var.bend.snap @@ -20,6 +20,10 @@ NumScott (main) = * -(Maybe/None) = λa (a 0) +(Maybe/None) = λa (a Maybe/None/tag) -(Maybe/Some) = λa λb (b 1 a) +(Maybe/Some) = λa λb (b Maybe/Some/tag a) + +(Maybe/None/tag) = 0 + +(Maybe/Some/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_auto_linearization.bend.snap b/tests/snapshots/encode_pattern_match__match_auto_linearization.bend.snap index 6dcdfade..a3959268 100644 --- a/tests/snapshots/encode_pattern_match__match_auto_linearization.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_auto_linearization.bend.snap @@ -22,4 +22,6 @@ NumScott (match_shadowed_field) = λa (a λb switch b { 0: λc λd (List/Cons c d); _: λ* λe λf λ* λ* (List/Cons e f); }) -(List/Cons) = λa λb λc (c 1 a b) +(List/Cons) = λa λb λc (c List/Cons/tag a b) + +(List/Cons/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_num_adt_tup_parser.bend.snap b/tests/snapshots/encode_pattern_match__match_num_adt_tup_parser.bend.snap index 6952de8d..e70f1f0d 100644 --- a/tests/snapshots/encode_pattern_match__match_num_adt_tup_parser.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_num_adt_tup_parser.bend.snap @@ -20,10 +20,18 @@ NumScott (main) = (Parse * (String/Cons 40 (String/Cons 43 String/Nil)) λc switch c { 0: λd let (e, f, g) = d; (e, (Parse g f)); _: λ* λh (Result_/Err h); }) -(String/Nil) = λa (a 0) +(String/Nil) = λa (a String/Nil/tag) -(String/Cons) = λa λb λc (c 1 a b) +(String/Cons) = λa λb λc (c String/Cons/tag a b) -(Result_/Ok) = λa λb (b 0 a) +(Result_/Ok) = λa λb (b Result_/Ok/tag a) -(Result_/Err) = λa λb (b 1 a) +(Result_/Err) = λa λb (b Result_/Err/tag a) + +(String/Nil/tag) = 0 + +(String/Cons/tag) = 1 + +(Result_/Ok/tag) = 0 + +(Result_/Err/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__match_syntax.bend.snap b/tests/snapshots/encode_pattern_match__match_syntax.bend.snap index badf5da4..2a92b75c 100644 --- a/tests/snapshots/encode_pattern_match__match_syntax.bend.snap +++ b/tests/snapshots/encode_pattern_match__match_syntax.bend.snap @@ -12,6 +12,10 @@ Scott NumScott (head) = λa (a λb switch b { 0: λc λ* c; _: λ* List_/Nil; }) -(List_/Cons) = λa λb λc (c 0 a b) +(List_/Cons) = λa λb λc (c List_/Cons/tag a b) -(List_/Nil) = λa (a 1) +(List_/Nil) = λa (a List_/Nil/tag) + +(List_/Cons/tag) = 0 + +(List_/Nil/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__non_matching_fst_arg.bend.snap b/tests/snapshots/encode_pattern_match__non_matching_fst_arg.bend.snap index b788424e..b7ecfc64 100644 --- a/tests/snapshots/encode_pattern_match__non_matching_fst_arg.bend.snap +++ b/tests/snapshots/encode_pattern_match__non_matching_fst_arg.bend.snap @@ -12,6 +12,10 @@ Scott NumScott (Foo) = λa λb (b λc switch c { 0: λd let {d d_2} = d; (Foo d d_2); _: λ* λe e; } a) -(bool/true) = λa (a 0) +(bool/true) = λa (a bool/true/tag) -(bool/false) = λa (a 1) +(bool/false) = λa (a bool/false/tag) + +(bool/true/tag) = 0 + +(bool/false/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__pattern_match_encoding.bend.snap b/tests/snapshots/encode_pattern_match__pattern_match_encoding.bend.snap index cd2a308d..3a81eeb1 100644 --- a/tests/snapshots/encode_pattern_match__pattern_match_encoding.bend.snap +++ b/tests/snapshots/encode_pattern_match__pattern_match_encoding.bend.snap @@ -22,12 +22,22 @@ NumScott (main) = (Foo MyType/A 2) -(MyType/A) = λa λb (b 0 a) +(MyType/A) = λa λb (b MyType/A/tag a) -(MyType/B) = λa λb (b 1 a) +(MyType/B) = λa λb (b MyType/B/tag a) -(MyType/C) = λa λb (b 2 a) +(MyType/C) = λa λb (b MyType/C/tag a) -(MyType/D) = λa λb λc (c 3 a b) +(MyType/D) = λa λb λc (c MyType/D/tag a b) -(MyType/E) = λa λb λc (c 4 a b) +(MyType/E) = λa λb λc (c MyType/E/tag a b) + +(MyType/A/tag) = 0 + +(MyType/B/tag) = 1 + +(MyType/C/tag) = 2 + +(MyType/D/tag) = 3 + +(MyType/E/tag) = 4 diff --git a/tests/snapshots/encode_pattern_match__var_only.bend.snap b/tests/snapshots/encode_pattern_match__var_only.bend.snap index fbffa89d..65c06bc2 100644 --- a/tests/snapshots/encode_pattern_match__var_only.bend.snap +++ b/tests/snapshots/encode_pattern_match__var_only.bend.snap @@ -16,6 +16,10 @@ NumScott (main) = λ* Foo -(Bool/False) = λa (a 0) +(Bool/False) = λa (a Bool/False/tag) -(Bool/True) = λa (a 1) +(Bool/True) = λa (a Bool/True/tag) + +(Bool/False/tag) = 0 + +(Bool/True/tag) = 1 diff --git a/tests/snapshots/encode_pattern_match__weekday.bend.snap b/tests/snapshots/encode_pattern_match__weekday.bend.snap index 650f3011..29858497 100644 --- a/tests/snapshots/encode_pattern_match__weekday.bend.snap +++ b/tests/snapshots/encode_pattern_match__weekday.bend.snap @@ -22,16 +22,30 @@ Scott NumScott (main) = (λa a Weekday/Saturday) -(Weekday/Monday) = λa (a 0) +(Weekday/Monday) = λa (a Weekday/Monday/tag) -(Weekday/Tuesday) = λa (a 1) +(Weekday/Tuesday) = λa (a Weekday/Tuesday/tag) -(Weekday/Wednesday) = λa (a 2) +(Weekday/Wednesday) = λa (a Weekday/Wednesday/tag) -(Weekday/Thursday) = λa (a 3) +(Weekday/Thursday) = λa (a Weekday/Thursday/tag) -(Weekday/Friday) = λa (a 4) +(Weekday/Friday) = λa (a Weekday/Friday/tag) -(Weekday/Saturday) = λa (a 5) +(Weekday/Saturday) = λa (a Weekday/Saturday/tag) -(Weekday/Sunday) = λa (a 6) +(Weekday/Sunday) = λa (a Weekday/Sunday/tag) + +(Weekday/Monday/tag) = 0 + +(Weekday/Tuesday/tag) = 1 + +(Weekday/Wednesday/tag) = 2 + +(Weekday/Thursday/tag) = 3 + +(Weekday/Friday/tag) = 4 + +(Weekday/Saturday/tag) = 5 + +(Weekday/Sunday/tag) = 6 diff --git a/tests/snapshots/examples__gen_tree.bend.snap b/tests/snapshots/examples__gen_tree.bend.snap index 8eeb0f01..0ca693db 100644 --- a/tests/snapshots/examples__gen_tree.bend.snap +++ b/tests/snapshots/examples__gen_tree.bend.snap @@ -2,4 +2,4 @@ source: tests/golden_tests.rs input_file: examples/gen_tree.bend --- -λa (a 0 1 λb (b 0 3 λc (c 0 7 λd (d 0 15 Tree/Leaf Tree/Leaf) λe (e 0 16 Tree/Leaf Tree/Leaf)) λf (f 0 8 λg (g 0 17 Tree/Leaf Tree/Leaf) λh (h 0 18 Tree/Leaf Tree/Leaf))) λi (i 0 4 λj (j 0 9 λk (k 0 19 Tree/Leaf Tree/Leaf) λl (l 0 20 Tree/Leaf Tree/Leaf)) λm (m 0 10 λn (n 0 21 Tree/Leaf Tree/Leaf) λo (o 0 22 Tree/Leaf Tree/Leaf)))) +λa (a Tree/Node/tag 1 λb (b Tree/Node/tag 3 λc (c Tree/Node/tag 7 λd (d Tree/Node/tag 15 Tree/Leaf Tree/Leaf) λe (e Tree/Node/tag 16 Tree/Leaf Tree/Leaf)) λf (f Tree/Node/tag 8 λg (g Tree/Node/tag 17 Tree/Leaf Tree/Leaf) λh (h Tree/Node/tag 18 Tree/Leaf Tree/Leaf))) λi (i Tree/Node/tag 4 λj (j Tree/Node/tag 9 λk (k Tree/Node/tag 19 Tree/Leaf Tree/Leaf) λl (l Tree/Node/tag 20 Tree/Leaf Tree/Leaf)) λm (m Tree/Node/tag 10 λn (n Tree/Node/tag 21 Tree/Leaf Tree/Leaf) λo (o Tree/Node/tag 22 Tree/Leaf Tree/Leaf)))) diff --git a/tests/snapshots/examples__insertion_sort.bend.snap b/tests/snapshots/examples__insertion_sort.bend.snap index e6d0edc4..eb3bdc0d 100644 --- a/tests/snapshots/examples__insertion_sort.bend.snap +++ b/tests/snapshots/examples__insertion_sort.bend.snap @@ -2,4 +2,4 @@ source: tests/golden_tests.rs input_file: examples/insertion_sort.bend --- -[4780, 11739, 35809, 49583, 154358, 177867, 244878, 289211, 318852, 423850] +λa (a List/Cons/tag 4780 λb (b List/Cons/tag 11739 λc (c List/Cons/tag 35809 λd (d List/Cons/tag 49583 λe (e List/Cons/tag 154358 λf (f List/Cons/tag 177867 λg (g List/Cons/tag 244878 λh (h List/Cons/tag 289211 λi (i List/Cons/tag 318852 λj (j List/Cons/tag 423850 [])))))))))) diff --git a/tests/snapshots/examples__queue.bend.snap b/tests/snapshots/examples__queue.bend.snap index 569ea985..cda80700 100644 --- a/tests/snapshots/examples__queue.bend.snap +++ b/tests/snapshots/examples__queue.bend.snap @@ -2,4 +2,4 @@ source: tests/golden_tests.rs input_file: examples/queue.bend --- -[1, 2, 3] +λa (a List/Cons/tag 1 λb (b List/Cons/tag 2 λc (c List/Cons/tag 3 []))) diff --git a/tests/snapshots/mutual_recursion__len.bend.snap b/tests/snapshots/mutual_recursion__len.bend.snap index 279fc41d..0af2bb0e 100644 --- a/tests/snapshots/mutual_recursion__len.bend.snap +++ b/tests/snapshots/mutual_recursion__len.bend.snap @@ -10,9 +10,13 @@ input_file: tests/golden_tests/mutual_recursion/len.bend @Len__C1 = (?((0 @Len__C0) a) a) -@List/Cons = (a (b ((1 (a (b c))) c))) +@List/Cons = (a (b ((@List/Cons/tag (a (b c))) c))) -@List/Nil = ((0 a) a) +@List/Cons/tag = 1 + +@List/Nil = ((@List/Nil/tag a) a) + +@List/Nil/tag = 0 @main = g & @Len ~ (f g) diff --git a/tests/snapshots/parse_file__imp_map.bend.snap b/tests/snapshots/parse_file__imp_map.bend.snap index 9e4b87d7..3f04e268 100644 --- a/tests/snapshots/parse_file__imp_map.bend.snap +++ b/tests/snapshots/parse_file__imp_map.bend.snap @@ -10,6 +10,10 @@ input_file: tests/golden_tests/parse_file/imp_map.bend (main) = let x = (Map/set (Map/set Map/empty 2 1) 3 2); let (map/get%1, x) = (Map/get x 2); let y = (id map/get%1); let z = 4; let x = (Map/set x z 4); let (map/get%0, x) = (Map/get x z); (+ y map/get%0) -(Map/Node) = λvalue λleft λright λ%x (%x 0 value left right) +(Map/Node) = λvalue λleft λright λ%x (%x Map/Node/tag value left right) -(Map/Leaf) = λ%x (%x 1) +(Map/Leaf) = λ%x (%x Map/Leaf/tag) + +(Map/Node/tag) = 0 + +(Map/Leaf/tag) = 1 diff --git a/tests/snapshots/parse_file__imp_program.bend.snap b/tests/snapshots/parse_file__imp_program.bend.snap index 09e5aa1c..efa9dfa6 100644 --- a/tests/snapshots/parse_file__imp_program.bend.snap +++ b/tests/snapshots/parse_file__imp_program.bend.snap @@ -38,16 +38,30 @@ input_file: tests/golden_tests/parse_file/imp_program.bend (main) = do IO { ask x = IO.read; x } -(List/Nil) = λ%x (%x 0) +(List/Nil) = λ%x (%x List/Nil/tag) -(List/Cons) = λhead λtail λ%x (%x 1 head tail) +(List/Cons) = λhead λtail λ%x (%x List/Cons/tag head tail) -(Map/Node) = λvalue λleft λright λ%x (%x 0 value left right) +(Map/Node) = λvalue λleft λright λ%x (%x Map/Node/tag value left right) -(Map/Leaf) = λ%x (%x 1) +(Map/Leaf) = λ%x (%x Map/Leaf/tag) -(Point/Point) = λx λy λ%x (%x 0 x y) +(Point/Point) = λx λy λ%x (%x Point/Point/tag x y) -(Bool/True) = λ%x (%x 0) +(Bool/True) = λ%x (%x Bool/True/tag) -(Bool/False) = λ%x (%x 1) +(Bool/False) = λ%x (%x Bool/False/tag) + +(List/Nil/tag) = 0 + +(List/Cons/tag) = 1 + +(Map/Node/tag) = 0 + +(Map/Leaf/tag) = 1 + +(Point/Point/tag) = 0 + +(Bool/True/tag) = 0 + +(Bool/False/tag) = 1 diff --git a/tests/snapshots/parse_file__scape_chars.bend.snap b/tests/snapshots/parse_file__scape_chars.bend.snap index f5c9a3f3..f626e7b7 100644 --- a/tests/snapshots/parse_file__scape_chars.bend.snap +++ b/tests/snapshots/parse_file__scape_chars.bend.snap @@ -4,6 +4,10 @@ input_file: tests/golden_tests/parse_file/scape_chars.bend --- (main) = (String/Cons 92 (String/Cons 32 (String/Cons 10 (String/Cons 32 (String/Cons 9 (String/Cons 32 (String/Cons 34 String/Nil))))))) -(String/Nil) = λ%x (%x 0) +(String/Nil) = λ%x (%x String/Nil/tag) -(String/Cons) = λhead λtail λ%x (%x 1 head tail) +(String/Cons) = λhead λtail λ%x (%x String/Cons/tag head tail) + +(String/Nil/tag) = 0 + +(String/Cons/tag) = 1 diff --git a/tests/snapshots/run_file__adt_match.bend.snap b/tests/snapshots/run_file__adt_match.bend.snap index 44570e0c..93a141e1 100644 --- a/tests/snapshots/run_file__adt_match.bend.snap +++ b/tests/snapshots/run_file__adt_match.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/adt_match.bend --- NumScott: -λa (a 0 2) +λa (a Opt/Some/tag 2) Scott: λa λ* (a 2) diff --git a/tests/snapshots/run_file__basic_num_ops.bend.snap b/tests/snapshots/run_file__basic_num_ops.bend.snap index fd68f633..9ae15ca5 100644 --- a/tests/snapshots/run_file__basic_num_ops.bend.snap +++ b/tests/snapshots/run_file__basic_num_ops.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/basic_num_ops.bend --- NumScott: -[30, 10, 200, 2, 0, 30, 0, 30, 0, 1, 0, 1, 65535, +30, +10, +200, +2, +0, +30, +0, +30, 0, 1, 0, 1, 65535, -30, -10, +200, +2, +0, +26, -28, -2, 0, 1, 1, 0, 65535, +10, +30, -200, -2, +0, -30, +20, -10, 0, 1, 0, 1, 65535, -10, -30, -200, -2, +0, -26, +8, -18, 0, 1, 1, 0, 65535, 30.000, 10.000, 200.000, 2.000, 0.000, 10240007340032.000, 1.107, 0.769, 0, 1, 0, 1, 65535, -30.000, -10.000, 200.000, 2.000, -0.000, 0.000, -2.034, NaN, 0, 1, 1, 0, 65535, 10.000, 30.000, -200.000, -2.000, 0.000, 0.000, 2.034, NaN, 0, 1, 0, 1, 65535, -10.000, -30.000, -200.000, -2.000, -0.000, 10240007340032.000, -1.107, NaN, 0, 1, 1, 0] +λa (a List/Cons/tag 30 λb (b List/Cons/tag 10 λc (c List/Cons/tag 200 λd (d List/Cons/tag 2 λe (e List/Cons/tag 0 λf (f List/Cons/tag 30 λg (g List/Cons/tag 0 λh (h List/Cons/tag 30 λi (i List/Cons/tag 0 λj (j List/Cons/tag 1 λk (k List/Cons/tag 0 λl (l List/Cons/tag 1 λm (m List/Cons/tag 65535 λn (n List/Cons/tag +30 λo (o List/Cons/tag +10 λp (p List/Cons/tag +200 λq (q List/Cons/tag +2 λr (r List/Cons/tag +0 λs (s List/Cons/tag +30 λt (t List/Cons/tag +0 λu (u List/Cons/tag +30 λv (v List/Cons/tag 0 λw (w List/Cons/tag 1 λx (x List/Cons/tag 0 λy (y List/Cons/tag 1 λz (z List/Cons/tag 65535 λab (ab List/Cons/tag -30 λbb (bb List/Cons/tag -10 λcb (cb List/Cons/tag +200 λdb (db List/Cons/tag +2 λeb (eb List/Cons/tag +0 λfb (fb List/Cons/tag +26 λgb (gb List/Cons/tag -28 λhb (hb List/Cons/tag -2 λib (ib List/Cons/tag 0 λjb (jb List/Cons/tag 1 λkb (kb List/Cons/tag 1 λlb (lb List/Cons/tag 0 λmb (mb List/Cons/tag 65535 λnb (nb List/Cons/tag +10 λob (ob List/Cons/tag +30 λpb (pb List/Cons/tag -200 λqb (qb List/Cons/tag -2 λrb (rb List/Cons/tag +0 λsb (sb List/Cons/tag -30 λtb (tb List/Cons/tag +20 λub (ub List/Cons/tag -10 λvb (vb List/Cons/tag 0 λwb (wb List/Cons/tag 1 λxb (xb List/Cons/tag 0 λyb (yb List/Cons/tag 1 λzb (zb List/Cons/tag 65535 λac (ac List/Cons/tag -10 λbc (bc List/Cons/tag -30 λcc (cc List/Cons/tag -200 λdc (dc List/Cons/tag -2 λec (ec List/Cons/tag +0 λfc (fc List/Cons/tag -26 λgc (gc List/Cons/tag +8 λhc (hc List/Cons/tag -18 λic (ic List/Cons/tag 0 λjc (jc List/Cons/tag 1 λkc (kc List/Cons/tag 1 λlc (lc List/Cons/tag 0 λmc (mc List/Cons/tag 65535 λnc (nc List/Cons/tag 30.000 λoc (oc List/Cons/tag 10.000 λpc (pc List/Cons/tag 200.000 λqc (qc List/Cons/tag 2.000 λrc (rc List/Cons/tag 0.000 λsc (sc List/Cons/tag 10240007340032.000 λtc (tc List/Cons/tag 1.107 λuc (uc List/Cons/tag 0.769 λvc (vc List/Cons/tag 0 λwc (wc List/Cons/tag 1 λxc (xc List/Cons/tag 0 λyc (yc List/Cons/tag 1 λzc (zc List/Cons/tag 65535 λad (ad List/Cons/tag -30.000 λbd (bd List/Cons/tag -10.000 λcd (cd List/Cons/tag 200.000 λdd (dd List/Cons/tag 2.000 λed (ed List/Cons/tag -0.000 λfd (fd List/Cons/tag 0.000 λgd (gd List/Cons/tag -2.034 λhd (hd List/Cons/tag NaN λid (id List/Cons/tag 0 λjd (jd List/Cons/tag 1 λkd (kd List/Cons/tag 1 λld (ld List/Cons/tag 0 λmd (md List/Cons/tag 65535 λnd (nd List/Cons/tag 10.000 λod (od List/Cons/tag 30.000 λpd (pd List/Cons/tag -200.000 λqd (qd List/Cons/tag -2.000 λrd (rd List/Cons/tag 0.000 λsd (sd List/Cons/tag 0.000 λtd (td List/Cons/tag 2.034 λud (ud List/Cons/tag NaN λvd (vd List/Cons/tag 0 λwd (wd List/Cons/tag 1 λxd (xd List/Cons/tag 0 λyd (yd List/Cons/tag 1 λzd (zd List/Cons/tag 65535 λae (ae List/Cons/tag -10.000 λbe (be List/Cons/tag -30.000 λce (ce List/Cons/tag -200.000 λde (de List/Cons/tag -2.000 λee (ee List/Cons/tag -0.000 λfe (fe List/Cons/tag 10240007340032.000 λge (ge List/Cons/tag -1.107 λhe (he List/Cons/tag NaN λie (ie List/Cons/tag 0 λje (je List/Cons/tag 1 λke (ke List/Cons/tag 1 λle (le List/Cons/tag 0 [])))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) Scott: [30, 10, 200, 2, 0, 30, 0, 30, 0, 1, 0, 1, 65535, +30, +10, +200, +2, +0, +30, +0, +30, 0, 1, 0, 1, 65535, -30, -10, +200, +2, +0, +26, -28, -2, 0, 1, 1, 0, 65535, +10, +30, -200, -2, +0, -30, +20, -10, 0, 1, 0, 1, 65535, -10, -30, -200, -2, +0, -26, +8, -18, 0, 1, 1, 0, 65535, 30.000, 10.000, 200.000, 2.000, 0.000, 10240007340032.000, 1.107, 0.769, 0, 1, 0, 1, 65535, -30.000, -10.000, 200.000, 2.000, -0.000, 0.000, -2.034, NaN, 0, 1, 1, 0, 65535, 10.000, 30.000, -200.000, -2.000, 0.000, 0.000, 2.034, NaN, 0, 1, 0, 1, 65535, -10.000, -30.000, -200.000, -2.000, -0.000, 10240007340032.000, -1.107, NaN, 0, 1, 1, 0] diff --git a/tests/snapshots/run_file__box.bend.snap b/tests/snapshots/run_file__box.bend.snap index 5931db3b..5c36f8a7 100644 --- a/tests/snapshots/run_file__box.bend.snap +++ b/tests/snapshots/run_file__box.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/box.bend --- NumScott: -λa (a 0 λb (b 0 10)) +λa (a _Box/Box/tag λb (b _Box/Box/tag 10)) Scott: λa (a λb (b 10)) diff --git a/tests/snapshots/run_file__chars.bend.snap b/tests/snapshots/run_file__chars.bend.snap index 41ab9ca2..29f7e712 100644 --- a/tests/snapshots/run_file__chars.bend.snap +++ b/tests/snapshots/run_file__chars.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/chars.bend --- NumScott: -"ሴ!7" +λa (a String/Cons/tag 4660 λb (b String/Cons/tag 33 λc (c String/Cons/tag 55 ""))) Scott: "ሴ!7" diff --git a/tests/snapshots/run_file__comprehension.bend.snap b/tests/snapshots/run_file__comprehension.bend.snap index 0a147d9e..37d449ac 100644 --- a/tests/snapshots/run_file__comprehension.bend.snap +++ b/tests/snapshots/run_file__comprehension.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/comprehension.bend --- NumScott: -[5, 10, 7, 6] +λa (a List/Cons/tag 5 λb (b List/Cons/tag 10 λc (c List/Cons/tag 7 λd (d List/Cons/tag 6 [])))) Scott: [5, 10, 7, 6] diff --git a/tests/snapshots/run_file__do_block_mixed.bend.snap b/tests/snapshots/run_file__do_block_mixed.bend.snap index 4412838a..430e1f7c 100644 --- a/tests/snapshots/run_file__do_block_mixed.bend.snap +++ b/tests/snapshots/run_file__do_block_mixed.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/do_block_mixed.bend --- NumScott: -λa (a 0 1) +λa (a Result/Ok/tag 1) Scott: λa λ* (a 1) diff --git a/tests/snapshots/run_file__escape_sequences.bend.snap b/tests/snapshots/run_file__escape_sequences.bend.snap index 74193078..29d1df52 100644 --- a/tests/snapshots/run_file__escape_sequences.bend.snap +++ b/tests/snapshots/run_file__escape_sequences.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/escape_sequences.bend --- NumScott: -"\n\r\t\0\"'\u{afe}\\\n\r\t\0\"'\u{afe}\\" +λa (a String/Cons/tag 10 λb (b String/Cons/tag 13 λc (c String/Cons/tag 9 λd (d String/Cons/tag 0 λe (e String/Cons/tag 34 λf (f String/Cons/tag 39 λg (g String/Cons/tag 2814 λh (h String/Cons/tag 92 λi (i String/Cons/tag 10 λj (j String/Cons/tag 13 λk (k String/Cons/tag 9 λl (l String/Cons/tag 0 λm (m String/Cons/tag 34 λn (n String/Cons/tag 39 λo (o String/Cons/tag 2814 λp (p String/Cons/tag 92 "")))))))))))))))) Scott: "\n\r\t\0\"'\u{afe}\\\n\r\t\0\"'\u{afe}\\" diff --git a/tests/snapshots/run_file__fold_with_state.bend.snap b/tests/snapshots/run_file__fold_with_state.bend.snap index 6744b2ea..614df968 100644 --- a/tests/snapshots/run_file__fold_with_state.bend.snap +++ b/tests/snapshots/run_file__fold_with_state.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/fold_with_state.bend --- NumScott: -[1, 2, 3] +λa (a List/Cons/tag 1 λb (b List/Cons/tag 2 λc (c List/Cons/tag 3 []))) Scott: [1, 2, 3] diff --git a/tests/snapshots/run_file__guide_bend_7tree.bend.snap b/tests/snapshots/run_file__guide_bend_7tree.bend.snap index 6b0ab942..529fa580 100644 --- a/tests/snapshots/run_file__guide_bend_7tree.bend.snap +++ b/tests/snapshots/run_file__guide_bend_7tree.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_bend_7tree.bend --- NumScott: -λa (a 0 λb (b 0 λc (c 0 λd (d 1 7) λe (e 1 7)) λf (f 0 λg (g 1 7) λh (h 1 7))) λi (i 0 λj (j 0 λk (k 1 7) λl (l 1 7)) λm (m 0 λn (n 1 7) λo (o 1 7)))) +λa (a Tree/Node/tag λb (b Tree/Node/tag λc (c Tree/Node/tag λd (d Tree/Leaf/tag 7) λe (e Tree/Leaf/tag 7)) λf (f Tree/Node/tag λg (g Tree/Leaf/tag 7) λh (h Tree/Leaf/tag 7))) λi (i Tree/Node/tag λj (j Tree/Node/tag λk (k Tree/Leaf/tag 7) λl (l Tree/Leaf/tag 7)) λm (m Tree/Node/tag λn (n Tree/Leaf/tag 7) λo (o Tree/Leaf/tag 7)))) Scott: λa λ* (a λb λ* (b λc λ* (c λ* λd (d 7) λ* λe (e 7)) λf λ* (f λ* λg (g 7) λ* λh (h 7))) λi λ* (i λj λ* (j λ* λk (k 7) λ* λl (l 7)) λm λ* (m λ* λn (n 7) λ* λo (o 7)))) diff --git a/tests/snapshots/run_file__guide_enumerate.bend.snap b/tests/snapshots/run_file__guide_enumerate.bend.snap index 6520881c..a8fdec40 100644 --- a/tests/snapshots/run_file__guide_enumerate.bend.snap +++ b/tests/snapshots/run_file__guide_enumerate.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_enumerate.bend --- NumScott: -λa (a 0 λb (b 0 λc (c 1 (0, 1)) λd (d 1 (1, 2))) λe (e 0 λf (f 1 (2, 3)) λg (g 1 (3, 4)))) +λa (a Tree/Node/tag λb (b Tree/Node/tag λc (c Tree/Leaf/tag (0, 1)) λd (d Tree/Leaf/tag (1, 2))) λe (e Tree/Node/tag λf (f Tree/Leaf/tag (2, 3)) λg (g Tree/Leaf/tag (3, 4)))) Scott: λa λ* (a λb λ* (b λ* λc (c (0, 1)) λ* λd (d (1, 2))) λe λ* (e λ* λf (f (2, 3)) λ* λg (g (3, 4)))) diff --git a/tests/snapshots/run_file__guide_if_age.bend.snap b/tests/snapshots/run_file__guide_if_age.bend.snap index e37e24d9..05f51af9 100644 --- a/tests/snapshots/run_file__guide_if_age.bend.snap +++ b/tests/snapshots/run_file__guide_if_age.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_if_age.bend --- NumScott: -"you're an adult" +λa (a String/Cons/tag 121 λb (b String/Cons/tag 111 λc (c String/Cons/tag 117 λd (d String/Cons/tag 39 λe (e String/Cons/tag 114 λf (f String/Cons/tag 101 λg (g String/Cons/tag 32 λh (h String/Cons/tag 97 λi (i String/Cons/tag 110 λj (j String/Cons/tag 32 λk (k String/Cons/tag 97 λl (l String/Cons/tag 100 λm (m String/Cons/tag 117 λn (n String/Cons/tag 108 λo (o String/Cons/tag 116 ""))))))))))))))) Scott: "you're an adult" diff --git a/tests/snapshots/run_file__guide_is_even_str.bend.snap b/tests/snapshots/run_file__guide_is_even_str.bend.snap index 3f40f32d..800daa74 100644 --- a/tests/snapshots/run_file__guide_is_even_str.bend.snap +++ b/tests/snapshots/run_file__guide_is_even_str.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_is_even_str.bend --- NumScott: -"odd" +λa (a String/Cons/tag 111 λb (b String/Cons/tag 100 λc (c String/Cons/tag 100 ""))) Scott: "odd" diff --git a/tests/snapshots/run_file__guide_list_ctrs.bend.snap b/tests/snapshots/run_file__guide_list_ctrs.bend.snap index 34adaf9e..999830ce 100644 --- a/tests/snapshots/run_file__guide_list_ctrs.bend.snap +++ b/tests/snapshots/run_file__guide_list_ctrs.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_list_ctrs.bend --- NumScott: -[1, 2, 3] +λa (a List/Cons/tag 1 λb (b List/Cons/tag 2 λc (c List/Cons/tag 3 []))) Scott: [1, 2, 3] diff --git a/tests/snapshots/run_file__guide_list_sugar.bend.snap b/tests/snapshots/run_file__guide_list_sugar.bend.snap index e7e1899f..cc14d0e6 100644 --- a/tests/snapshots/run_file__guide_list_sugar.bend.snap +++ b/tests/snapshots/run_file__guide_list_sugar.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/guide_list_sugar.bend --- NumScott: -[1, 2, 3] +λa (a List/Cons/tag 1 λb (b List/Cons/tag 2 λc (c List/Cons/tag 3 []))) Scott: [1, 2, 3] diff --git a/tests/snapshots/run_file__list_resugar.bend.snap b/tests/snapshots/run_file__list_resugar.bend.snap index 05fa4972..23c1cadb 100644 --- a/tests/snapshots/run_file__list_resugar.bend.snap +++ b/tests/snapshots/run_file__list_resugar.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/list_resugar.bend --- NumScott: -[42, [λd d]] +λa (a List/Cons/tag 42 λb (b List/Cons/tag λc (c List/Cons/tag λd d []) [])) Scott: [42, [λd d]] diff --git a/tests/snapshots/run_file__list_reverse.bend.snap b/tests/snapshots/run_file__list_reverse.bend.snap index 970c7d6e..ae637074 100644 --- a/tests/snapshots/run_file__list_reverse.bend.snap +++ b/tests/snapshots/run_file__list_reverse.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/list_reverse.bend --- NumScott: -λa (a 0 1 λb (b 0 2 λc (c 0 3 list/nil))) +λa (a list/cons/tag 1 λb (b list/cons/tag 2 λc (c list/cons/tag 3 list/nil))) Scott: λa λ* (a 1 λb λ* (b 2 λc λ* (c 3 list/nil))) diff --git a/tests/snapshots/run_file__list_take.bend.snap b/tests/snapshots/run_file__list_take.bend.snap index 10bb924b..f6d3ee72 100644 --- a/tests/snapshots/run_file__list_take.bend.snap +++ b/tests/snapshots/run_file__list_take.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/list_take.bend --- NumScott: -[3, 2] +λa (a List/Cons/tag 3 λb (b List/Cons/tag 2 [])) Scott: [3, 2] diff --git a/tests/snapshots/run_file__match_builtins.bend.snap b/tests/snapshots/run_file__match_builtins.bend.snap index 57669dc5..8d95d135 100644 --- a/tests/snapshots/run_file__match_builtins.bend.snap +++ b/tests/snapshots/run_file__match_builtins.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/match_builtins.bend --- NumScott: -{"ello" "world"} +{λa (a String/Cons/tag 101 λb (b String/Cons/tag 108 λc (c String/Cons/tag 108 λd (d String/Cons/tag 111 "")))) λe (e String/Cons/tag 119 λf (f String/Cons/tag 111 λg (g String/Cons/tag 114 λh (h String/Cons/tag 108 λi (i String/Cons/tag 100 "")))))} Scott: {"ello" "world"} diff --git a/tests/snapshots/run_file__match_num_adt_tup_parser.bend.snap b/tests/snapshots/run_file__match_num_adt_tup_parser.bend.snap index 332cc138..89fbda23 100644 --- a/tests/snapshots/run_file__match_num_adt_tup_parser.bend.snap +++ b/tests/snapshots/run_file__match_num_adt_tup_parser.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/match_num_adt_tup_parser.bend --- NumScott: -λa (a 1 {"(+" *}) +λa (a Result_/Err/tag {λb (b String/Cons/tag 40 λc (c String/Cons/tag 43 "")) *}) Scott: λ* λa (a {"(+" *}) diff --git a/tests/snapshots/run_file__match_num_num_to_char.bend.snap b/tests/snapshots/run_file__match_num_num_to_char.bend.snap index c55898b1..30c3c84f 100644 --- a/tests/snapshots/run_file__match_num_num_to_char.bend.snap +++ b/tests/snapshots/run_file__match_num_num_to_char.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/match_num_num_to_char.bend --- NumScott: -{{[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16777215]} [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0]} +{{λa (a List/Cons/tag 0 λb (b List/Cons/tag 1 λc (c List/Cons/tag 2 λd (d List/Cons/tag 3 λe (e List/Cons/tag 4 λf (f List/Cons/tag 5 λg (g List/Cons/tag 6 λh (h List/Cons/tag 7 λi (i List/Cons/tag 8 λj (j List/Cons/tag 9 λk (k List/Cons/tag 10 []))))))))))) λl (l List/Cons/tag 0 λm (m List/Cons/tag 1 λn (n List/Cons/tag 2 λo (o List/Cons/tag 3 λp (p List/Cons/tag 4 λq (q List/Cons/tag 5 λr (r List/Cons/tag 6 λs (s List/Cons/tag 7 λt (t List/Cons/tag 8 λu (u List/Cons/tag 9 λv (v List/Cons/tag 16777215 [])))))))))))} λw (w List/Cons/tag 48 λx (x List/Cons/tag 49 λy (y List/Cons/tag 50 λz (z List/Cons/tag 51 λab (ab List/Cons/tag 52 λbb (bb List/Cons/tag 53 λcb (cb List/Cons/tag 54 λdb (db List/Cons/tag 55 λeb (eb List/Cons/tag 56 λfb (fb List/Cons/tag 57 λgb (gb List/Cons/tag 0 [])))))))))))} Scott: {{[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16777215]} [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0]} diff --git a/tests/snapshots/run_file__match_num_succ_complex.bend.snap b/tests/snapshots/run_file__match_num_succ_complex.bend.snap index 3bb1042d..63750c27 100644 --- a/tests/snapshots/run_file__match_num_succ_complex.bend.snap +++ b/tests/snapshots/run_file__match_num_succ_complex.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/match_num_succ_complex.bend --- NumScott: -[[5, 5, 0, 12, 0, 6], [5, 5, 0, 12, 0, 6]] +λa (a List/Cons/tag λb (b List/Cons/tag 5 λc (c List/Cons/tag 5 λd (d List/Cons/tag 0 λe (e List/Cons/tag 12 λf (f List/Cons/tag 0 λg (g List/Cons/tag 6 [])))))) λh (h List/Cons/tag λi (i List/Cons/tag 5 λj (j List/Cons/tag 5 λk (k List/Cons/tag 0 λl (l List/Cons/tag 12 λm (m List/Cons/tag 0 λn (n List/Cons/tag 6 [])))))) [])) Scott: [[5, 5, 0, 12, 0, 6], [5, 5, 0, 12, 0, 6]] diff --git a/tests/snapshots/run_file__match_str.bend.snap b/tests/snapshots/run_file__match_str.bend.snap index f58e07d9..aee72cc2 100644 --- a/tests/snapshots/run_file__match_str.bend.snap +++ b/tests/snapshots/run_file__match_str.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/match_str.bend --- NumScott: -[2, 2, 1, 0, 0, 0] +λa (a List/Cons/tag 2 λb (b List/Cons/tag 2 λc (c List/Cons/tag 1 λd (d List/Cons/tag 0 λe (e List/Cons/tag 0 λf (f List/Cons/tag 0 [])))))) Scott: [2, 2, 1, 0, 0, 0] diff --git a/tests/snapshots/run_file__names_hyphen_toplevel.bend.snap b/tests/snapshots/run_file__names_hyphen_toplevel.bend.snap index 30787509..1e130e98 100644 --- a/tests/snapshots/run_file__names_hyphen_toplevel.bend.snap +++ b/tests/snapshots/run_file__names_hyphen_toplevel.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/names_hyphen_toplevel.bend --- NumScott: -λa (a 0 fun-with-hyphen) +λa (a Foo-Bar/Baz-Qux/tag fun-with-hyphen) Scott: λa (a fun-with-hyphen) diff --git a/tests/snapshots/run_file__nested_list_and_string.bend.snap b/tests/snapshots/run_file__nested_list_and_string.bend.snap index 5a7e0c7a..956b7709 100644 --- a/tests/snapshots/run_file__nested_list_and_string.bend.snap +++ b/tests/snapshots/run_file__nested_list_and_string.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/nested_list_and_string.bend --- NumScott: -λa [a, λ* 2, λe (e 1 [7, "1234", 9] λm (m 1 a λn (n 1 * "42")))] +λa λb (b List/Cons/tag a λc (c List/Cons/tag λ* 2 λd (d List/Cons/tag λe (e String/Cons/tag λf (f List/Cons/tag 7 λg (g List/Cons/tag λh (h String/Cons/tag 49 λi (i String/Cons/tag 50 λj (j String/Cons/tag 51 λk (k String/Cons/tag 52 "")))) λl (l List/Cons/tag 9 []))) λm (m String/Cons/tag a λn (n String/Cons/tag * λo (o String/Cons/tag 52 λp (p String/Cons/tag 50 ""))))) []))) Scott: λa [a, λ* 2, λ* λe (e [7, "1234", 9] λ* λm (m a λ* λn (n * "42")))] diff --git a/tests/snapshots/run_file__nested_str.bend.snap b/tests/snapshots/run_file__nested_str.bend.snap index f37d1a22..21f71d9c 100644 --- a/tests/snapshots/run_file__nested_str.bend.snap +++ b/tests/snapshots/run_file__nested_str.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/nested_str.bend --- NumScott: -(λa (a 1 "a" ""), (λc (c 1 97 λd (d 1 "bc" "")), (λg (g 1 "ab" "c"), λk (k 1 "ab" λn (n 1 "cd" ""))))) +(λa (a String/Cons/tag λb (b String/Cons/tag 97 "") ""), (λc (c String/Cons/tag 97 λd (d String/Cons/tag λe (e String/Cons/tag 98 λf (f String/Cons/tag 99 "")) "")), (λg (g String/Cons/tag λh (h String/Cons/tag 97 λi (i String/Cons/tag 98 "")) λj (j String/Cons/tag 99 "")), λk (k String/Cons/tag λl (l String/Cons/tag 97 λm (m String/Cons/tag 98 "")) λn (n String/Cons/tag λo (o String/Cons/tag 99 λp (p String/Cons/tag 100 "")) ""))))) Scott: (λ* λa (a "a" ""), (λ* λc (c 97 λ* λd (d "bc" "")), (λ* λg (g "ab" "c"), λ* λk (k "ab" λ* λn (n "cd" ""))))) diff --git a/tests/snapshots/run_file__open.bend.snap b/tests/snapshots/run_file__open.bend.snap index b2ed7b1d..ed6dc704 100644 --- a/tests/snapshots/run_file__open.bend.snap +++ b/tests/snapshots/run_file__open.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/open.bend --- NumScott: -{λa (a 0 1 2) 1} +{λa (a State/new/tag 1 2) 1} Scott: {λa (a 1 2) 1} diff --git a/tests/snapshots/run_file__ops.bend.snap b/tests/snapshots/run_file__ops.bend.snap index 961c54e6..4d0c19bb 100644 --- a/tests/snapshots/run_file__ops.bend.snap +++ b/tests/snapshots/run_file__ops.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/ops.bend --- NumScott: -[1, 1, 1, 1, 1] +λa (a List/Cons/tag 1 λb (b List/Cons/tag 1 λc (c List/Cons/tag 1 λd (d List/Cons/tag 1 λe (e List/Cons/tag 1 []))))) Scott: [1, 1, 1, 1, 1] diff --git a/tests/snapshots/run_file__readback_list_other_ctr.bend.snap b/tests/snapshots/run_file__readback_list_other_ctr.bend.snap index 3cc29411..8b03506b 100644 --- a/tests/snapshots/run_file__readback_list_other_ctr.bend.snap +++ b/tests/snapshots/run_file__readback_list_other_ctr.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/readback_list_other_ctr.bend --- NumScott: -λa (a 1 λb (b 1 97 λc (c 0 98 "c")) λe (e 1 1 λf (f 0 2 [3, 4]))) +λa (a List/Cons/tag λb (b String/Cons/tag 97 λc (c tup/pair/tag 98 λd (d String/Cons/tag 99 ""))) λe (e List/Cons/tag 1 λf (f tup/pair/tag 2 λg (g List/Cons/tag 3 λh (h List/Cons/tag 4 []))))) Scott: λ* λa (a λ* λb (b 97 λc (c 98 "c")) λ* λe (e 1 λf (f 2 [3, 4]))) diff --git a/tests/snapshots/run_file__str_concat.bend.snap b/tests/snapshots/run_file__str_concat.bend.snap index cd356fc6..b91e1269 100644 --- a/tests/snapshots/run_file__str_concat.bend.snap +++ b/tests/snapshots/run_file__str_concat.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/str_concat.bend --- NumScott: -"hello world" +λa (a String/Cons/tag 104 λb (b String/Cons/tag 101 λc (c String/Cons/tag 108 λd (d String/Cons/tag 108 λe (e String/Cons/tag 111 λf (f String/Cons/tag 32 λg (g String/Cons/tag 119 λh (h String/Cons/tag 111 λi (i String/Cons/tag 114 λj (j String/Cons/tag 108 λk (k String/Cons/tag 100 ""))))))))))) Scott: "hello world" diff --git a/tests/snapshots/run_file__tup_list_strings.bend.snap b/tests/snapshots/run_file__tup_list_strings.bend.snap index 0c54944e..2050ac28 100644 --- a/tests/snapshots/run_file__tup_list_strings.bend.snap +++ b/tests/snapshots/run_file__tup_list_strings.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/tup_list_strings.bend --- NumScott: -{[{"foo" 0}, {"foo" 0}, {"foo" 1}] 4} +{λa (a List/Cons/tag {λb (b String/Cons/tag 102 λc (c String/Cons/tag 111 λd (d String/Cons/tag 111 ""))) 0} λe (e List/Cons/tag {λf (f String/Cons/tag 102 λg (g String/Cons/tag 111 λh (h String/Cons/tag 111 ""))) 0} λi (i List/Cons/tag {λj (j String/Cons/tag 102 λk (k String/Cons/tag 111 λl (l String/Cons/tag 111 ""))) 1} []))) 4} Scott: {[{"foo" 0}, {"foo" 0}, {"foo" 1}] 4} diff --git a/tests/snapshots/run_file__unaplied_str.bend.snap b/tests/snapshots/run_file__unaplied_str.bend.snap index 21f4d8f5..de91f8b7 100644 --- a/tests/snapshots/run_file__unaplied_str.bend.snap +++ b/tests/snapshots/run_file__unaplied_str.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/unaplied_str.bend --- NumScott: -λa λb λc (c 1 a λd (d 1 98 λe (e 1 99 λf (f 1 b "")))) +λa λb λc (c String/Cons/tag a λd (d String/Cons/tag 98 λe (e String/Cons/tag 99 λf (f String/Cons/tag b "")))) Scott: λa λb λ* λc (c a λ* λd (d 98 λ* λe (e 99 λ* λf (f b "")))) diff --git a/tests/snapshots/run_file__world.bend.snap b/tests/snapshots/run_file__world.bend.snap index 0ed7518e..610c98a7 100644 --- a/tests/snapshots/run_file__world.bend.snap +++ b/tests/snapshots/run_file__world.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/world.bend --- NumScott: -"🌎" +λa (a String/Cons/tag 127758 "") Scott: "🌎" diff --git a/tests/snapshots/run_file__wrong_string.bend.snap b/tests/snapshots/run_file__wrong_string.bend.snap index 65629cbd..ffc1ee3c 100644 --- a/tests/snapshots/run_file__wrong_string.bend.snap +++ b/tests/snapshots/run_file__wrong_string.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/wrong_string.bend --- NumScott: -λa (a 1 λ* 4 λb (b 1 * "")) +λa (a String/Cons/tag λ* 4 λb (b String/Cons/tag * "")) Scott: λ* λa (a λ* 4 λ* λb (b * "")) diff --git a/tests/snapshots/scott_triggers_unused__test.bend.snap b/tests/snapshots/scott_triggers_unused__test.bend.snap index fd578f65..e94d7ece 100644 --- a/tests/snapshots/scott_triggers_unused__test.bend.snap +++ b/tests/snapshots/scott_triggers_unused__test.bend.snap @@ -2,10 +2,8 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/scott_triggers_unused/test.bend --- -@bool/f = ((1 a) a) - -@bool/t = ((0 a) a) - -@main = ((@main__C0 a) a) - -@main__C0 = (?((0 (* 1)) a) a) +Errors: +In definition 'bool/f/tag': + Definition is unused. +In definition 'bool/t/tag': + Definition is unused. diff --git a/tests/snapshots/simplify_matches__adt_tup_era.bend.snap b/tests/snapshots/simplify_matches__adt_tup_era.bend.snap index 91823801..33931e50 100644 --- a/tests/snapshots/simplify_matches__adt_tup_era.bend.snap +++ b/tests/snapshots/simplify_matches__adt_tup_era.bend.snap @@ -6,4 +6,6 @@ input_file: tests/golden_tests/simplify_matches/adt_tup_era.bend (Main) = (Foo (Tuple/Pair 1 5)) -(Tuple/Pair) = λa λb λc (c 0 a b) +(Tuple/Pair) = λa λb λc (c Tuple/Pair/tag a b) + +(Tuple/Pair/tag) = 0 diff --git a/tests/snapshots/simplify_matches__already_flat.bend.snap b/tests/snapshots/simplify_matches__already_flat.bend.snap index c0da25ff..1b57c1cd 100644 --- a/tests/snapshots/simplify_matches__already_flat.bend.snap +++ b/tests/snapshots/simplify_matches__already_flat.bend.snap @@ -14,20 +14,38 @@ input_file: tests/golden_tests/simplify_matches/already_flat.bend (Rule6) = λa a -(Foo/CtrA) = λa (a 0) +(Foo/CtrA) = λa (a Foo/CtrA/tag) -(Foo/CtrB) = λa λb (b 1 a) +(Foo/CtrB) = λa λb (b Foo/CtrB/tag a) -(Bar/CtrA1) = λa λb (b 0 a) +(Bar/CtrA1) = λa λb (b Bar/CtrA1/tag a) -(Bar/CtrA2) = λa λb λc (c 1 a b) +(Bar/CtrA2) = λa λb λc (c Bar/CtrA2/tag a b) -(Bar/CtrA3) = λa λb (b 2 a) +(Bar/CtrA3) = λa λb (b Bar/CtrA3/tag a) -(Baz/CtrB0) = λa (a 0) +(Baz/CtrB0) = λa (a Baz/CtrB0/tag) -(Baz/CtrB1) = λa λb (b 1 a) +(Baz/CtrB1) = λa λb (b Baz/CtrB1/tag a) -(Baz/CtrB2) = λa λb (b 2 a) +(Baz/CtrB2) = λa λb (b Baz/CtrB2/tag a) -(Baz/CtrB3) = λa λb (b 3 a) +(Baz/CtrB3) = λa λb (b Baz/CtrB3/tag a) + +(Foo/CtrA/tag) = 0 + +(Foo/CtrB/tag) = 1 + +(Bar/CtrA1/tag) = 0 + +(Bar/CtrA2/tag) = 1 + +(Bar/CtrA3/tag) = 2 + +(Baz/CtrB0/tag) = 0 + +(Baz/CtrB1/tag) = 1 + +(Baz/CtrB2/tag) = 2 + +(Baz/CtrB3/tag) = 3 diff --git a/tests/snapshots/simplify_matches__bits_dec.bend.snap b/tests/snapshots/simplify_matches__bits_dec.bend.snap index 38d24828..d8d452d2 100644 --- a/tests/snapshots/simplify_matches__bits_dec.bend.snap +++ b/tests/snapshots/simplify_matches__bits_dec.bend.snap @@ -4,8 +4,14 @@ input_file: tests/golden_tests/simplify_matches/bits_dec.bend --- (Data.Bits.dec) = λa match a { Data/Bits/e: Data/Bits/e; Data/Bits/o b: match b { Data/Bits/e: Data/Bits/e; Data/Bits/o c: (Data/Bits/i (Data.Bits.dec c)); Data/Bits/i d: (Data/Bits/i (Data.Bits.dec d)); }; Data/Bits/i e: match e { Data/Bits/e: (Data/Bits/o Data/Bits/e); Data/Bits/o f: (Data/Bits/o f); Data/Bits/i g: (Data/Bits/o g); }; } -(Data/Bits/e) = λa (a 0) +(Data/Bits/e) = λa (a Data/Bits/e/tag) -(Data/Bits/o) = λa λb (b 1 a) +(Data/Bits/o) = λa λb (b Data/Bits/o/tag a) -(Data/Bits/i) = λa λb (b 2 a) +(Data/Bits/i) = λa λb (b Data/Bits/i/tag a) + +(Data/Bits/e/tag) = 0 + +(Data/Bits/o/tag) = 1 + +(Data/Bits/i/tag) = 2 diff --git a/tests/snapshots/simplify_matches__complex_with_case.bend.snap b/tests/snapshots/simplify_matches__complex_with_case.bend.snap index 4d96395b..24dc9ef7 100644 --- a/tests/snapshots/simplify_matches__complex_with_case.bend.snap +++ b/tests/snapshots/simplify_matches__complex_with_case.bend.snap @@ -6,6 +6,10 @@ input_file: tests/golden_tests/simplify_matches/complex_with_case.bend (main) = map -(Tree/Node) = λa λb λc λd λe (e 0 a b c d) +(Tree/Node) = λa λb λc λd λe (e Tree/Node/tag a b c d) -(Tree/Leaf) = λa λb (b 1 a) +(Tree/Leaf) = λa λb (b Tree/Leaf/tag a) + +(Tree/Node/tag) = 0 + +(Tree/Leaf/tag) = 1 diff --git a/tests/snapshots/simplify_matches__double_unwrap_box.bend.snap b/tests/snapshots/simplify_matches__double_unwrap_box.bend.snap index 678f6624..9d51b52e 100644 --- a/tests/snapshots/simplify_matches__double_unwrap_box.bend.snap +++ b/tests/snapshots/simplify_matches__double_unwrap_box.bend.snap @@ -6,4 +6,6 @@ input_file: tests/golden_tests/simplify_matches/double_unwrap_box.bend (Main) = (DoubleUnbox (Boxed/Box (Boxed/Box 0)) 5) -(Boxed/Box) = λa λb (b 0 a) +(Boxed/Box) = λa λb (b Boxed/Box/tag a) + +(Boxed/Box/tag) = 0 diff --git a/tests/snapshots/simplify_matches__double_unwrap_maybe.bend.snap b/tests/snapshots/simplify_matches__double_unwrap_maybe.bend.snap index bd36942f..5dbb1419 100644 --- a/tests/snapshots/simplify_matches__double_unwrap_maybe.bend.snap +++ b/tests/snapshots/simplify_matches__double_unwrap_maybe.bend.snap @@ -6,6 +6,10 @@ input_file: tests/golden_tests/simplify_matches/double_unwrap_maybe.bend (Main) = (DoubleUnwrap (Maybe/Some Maybe/None) 5) -(Maybe/Some) = λa λb (b 0 a) +(Maybe/Some) = λa λb (b Maybe/Some/tag a) -(Maybe/None) = λa (a 1) +(Maybe/None) = λa (a Maybe/None/tag) + +(Maybe/Some/tag) = 0 + +(Maybe/None/tag) = 1 diff --git a/tests/snapshots/simplify_matches__flatten_with_terminal.bend.snap b/tests/snapshots/simplify_matches__flatten_with_terminal.bend.snap index 32dfc493..5513fb0e 100644 --- a/tests/snapshots/simplify_matches__flatten_with_terminal.bend.snap +++ b/tests/snapshots/simplify_matches__flatten_with_terminal.bend.snap @@ -6,6 +6,10 @@ input_file: tests/golden_tests/simplify_matches/flatten_with_terminal.bend (main) = (Foo 2 (A_t/A B_t/B)) -(A_t/A) = λa λb (b 0 a) +(A_t/A) = λa λb (b A_t/A/tag a) -(B_t/B) = λa (a 0) +(B_t/B) = λa (a B_t/B/tag) + +(A_t/A/tag) = 0 + +(B_t/B/tag) = 0 diff --git a/tests/snapshots/simplify_matches__linearize_match_all.bend.snap b/tests/snapshots/simplify_matches__linearize_match_all.bend.snap index 846ebc6e..78f6b709 100644 --- a/tests/snapshots/simplify_matches__linearize_match_all.bend.snap +++ b/tests/snapshots/simplify_matches__linearize_match_all.bend.snap @@ -22,6 +22,10 @@ input_file: tests/golden_tests/simplify_matches/linearize_match_all.bend (main) = * -(ConsList/Cons) = λa λb λc (c 0 a b) +(ConsList/Cons) = λa λb λc (c ConsList/Cons/tag a b) -(ConsList/Nil) = λa (a 1) +(ConsList/Nil) = λa (a ConsList/Nil/tag) + +(ConsList/Cons/tag) = 0 + +(ConsList/Nil/tag) = 1 diff --git a/tests/snapshots/simplify_matches__nested.bend.snap b/tests/snapshots/simplify_matches__nested.bend.snap index 6fa0146e..05ada9d7 100644 --- a/tests/snapshots/simplify_matches__nested.bend.snap +++ b/tests/snapshots/simplify_matches__nested.bend.snap @@ -4,12 +4,22 @@ input_file: tests/golden_tests/simplify_matches/nested.bend --- (Rule) = λa match a { Foo/CtrA b c: (match c { Bar/CtrB1 d: λe (e d); Bar/CtrB2 f g: λh (match f { Baz/CtrC: λi λj (i j); } h g); } b); Foo/CtrB k: k; } -(Foo/CtrA) = λa λb λc (c 0 a b) +(Foo/CtrA) = λa λb λc (c Foo/CtrA/tag a b) -(Foo/CtrB) = λa λb (b 1 a) +(Foo/CtrB) = λa λb (b Foo/CtrB/tag a) -(Bar/CtrB1) = λa λb (b 0 a) +(Bar/CtrB1) = λa λb (b Bar/CtrB1/tag a) -(Bar/CtrB2) = λa λb λc (c 1 a b) +(Bar/CtrB2) = λa λb λc (c Bar/CtrB2/tag a b) -(Baz/CtrC) = λa (a 0) +(Baz/CtrC) = λa (a Baz/CtrC/tag) + +(Foo/CtrA/tag) = 0 + +(Foo/CtrB/tag) = 1 + +(Bar/CtrB1/tag) = 0 + +(Bar/CtrB2/tag) = 1 + +(Baz/CtrC/tag) = 0 diff --git a/tests/snapshots/simplify_matches__nested2.bend.snap b/tests/snapshots/simplify_matches__nested2.bend.snap index fb17a2f0..d4d73123 100644 --- a/tests/snapshots/simplify_matches__nested2.bend.snap +++ b/tests/snapshots/simplify_matches__nested2.bend.snap @@ -4,6 +4,10 @@ input_file: tests/golden_tests/simplify_matches/nested2.bend --- (Foo) = λa λb (match b { List/Nil: λc (c List/Nil); List/Cons d e: λf (match e { List/Nil: λg λh (g (List/Cons h List/Nil)); List/Cons i j: λk λl (k l i j); } f d); } a) -(List/Nil) = λa (a 0) +(List/Nil) = λa (a List/Nil/tag) -(List/Cons) = λa λb λc (c 1 a b) +(List/Cons) = λa λb λc (c List/Cons/tag a b) + +(List/Nil/tag) = 0 + +(List/Cons/tag) = 1 diff --git a/tests/snapshots/simplify_matches__nested_0ary.bend.snap b/tests/snapshots/simplify_matches__nested_0ary.bend.snap index 23a9edcc..2f188c93 100644 --- a/tests/snapshots/simplify_matches__nested_0ary.bend.snap +++ b/tests/snapshots/simplify_matches__nested_0ary.bend.snap @@ -4,6 +4,10 @@ input_file: tests/golden_tests/simplify_matches/nested_0ary.bend --- (Unpack) = λa λb (match b { list/Cons c d: λe (match d { list/Cons f g: λh λi (h (list/Cons i (list/Cons f g))); list/Nil: λj λk k; } e c); list/Nil: λl list/Nil; } a) -(list/Cons) = λa λb λc (c 0 a b) +(list/Cons) = λa λb λc (c list/Cons/tag a b) -(list/Nil) = λa (a 1) +(list/Nil) = λa (a list/Nil/tag) + +(list/Cons/tag) = 0 + +(list/Nil/tag) = 1