Generate definitions for constructor tags

This commit is contained in:
imaqtkatt 2024-05-27 15:09:23 -03:00
parent 043331190d
commit b74c3e2693
83 changed files with 511 additions and 198 deletions

View File

@ -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<Item = &'a Name> + Clone,
ctr_idx: usize,
) -> Term {
fn encode_ctr_num_scott<'a>(ctr_args: impl DoubleEndedIterator<Item = &'a Name> + 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 }
}

View File

@ -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)

View File

@ -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)

View File

@ -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 "")));
}

View File

@ -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))))

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))))

View File

@ -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 []))))))))))

View File

@ -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 [])))

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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]

View File

@ -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))

View File

@ -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"

View File

@ -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]

View File

@ -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)

View File

@ -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}\\"

View File

@ -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]

View File

@ -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))))

View File

@ -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))))

View File

@ -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"

View File

@ -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"

View File

@ -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]

View File

@ -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]

View File

@ -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]]

View File

@ -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)))

View File

@ -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]

View File

@ -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"}

View File

@ -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 {"(+" *})

View File

@ -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]}

View File

@ -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]]

View File

@ -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]

View File

@ -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)

View File

@ -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")))]

View File

@ -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" "")))))

View File

@ -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}

View File

@ -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]

View File

@ -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])))

View File

@ -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"

View File

@ -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}

View File

@ -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 ""))))

View File

@ -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:
"🌎"

View File

@ -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 * ""))

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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