diff --git a/examples/example_fun.bend b/examples/example_fun.bend index 8d701be0c..4e1b73568 100644 --- a/examples/example_fun.bend +++ b/examples/example_fun.bend @@ -44,7 +44,6 @@ bad_nums : Any = (+ id 1) # Write new data types like this type Option = (Some val) | None -type Bool = True | False # You can have pattern matching on definitions # Use `*` to ignore a pattern diff --git a/examples/parallel_and.bend b/examples/parallel_and.bend index bd41552da..2dcd9cdd6 100644 --- a/examples/parallel_and.bend +++ b/examples/parallel_and.bend @@ -1,8 +1,4 @@ # This program allocates a tree with True at the leaves then parallel ANDs them. -type Bool: - True - False - def and(a: Bool, b: Bool) -> Bool: match a: case Bool/True: diff --git a/src/fun/builtins.bend b/src/fun/builtins.bend index 3812f51b6..3495616bb 100644 --- a/src/fun/builtins.bend +++ b/src/fun/builtins.bend @@ -170,6 +170,11 @@ def Tree/reverse(tree: Tree(T)) -> Tree(T): case Tree/Node: return ![tree.right, tree.left] +# BOOL Impl +type Bool: + True + False + # MAYBE Impl diff --git a/tests/golden_tests/compile_file/mismatched_ask_statements.bend b/tests/golden_tests/compile_file/mismatched_ask_statements.bend index ba41a78ff..86b2504c1 100644 --- a/tests/golden_tests/compile_file/mismatched_ask_statements.bend +++ b/tests/golden_tests/compile_file/mismatched_ask_statements.bend @@ -1,12 +1,8 @@ -type Bool: - T - F - def main: with IO: - match _ = Bool/T: - case Bool/T: + match _ = Bool/True: + case Bool/False: x <- wrap(0) - case Bool/F: + case Bool/False: x = wrap(0) return wrap(x) diff --git a/tests/golden_tests/compile_file_o_all/list_merge_sort.bend b/tests/golden_tests/compile_file_o_all/list_merge_sort.bend index a11946b93..9528ff9b8 100644 --- a/tests/golden_tests/compile_file_o_all/list_merge_sort.bend +++ b/tests/golden_tests/compile_file_o_all/list_merge_sort.bend @@ -1,4 +1,3 @@ -type Bool = True | False type List_ = (Cons head tail) | Nil If Bool/True then else = then diff --git a/tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend b/tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend index fe6b4fe92..c897858ec 100644 --- a/tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend +++ b/tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend @@ -1,6 +1,4 @@ -type Bool = T | F - -Bool.and Bool/T Bool/T = Bool/T -Bool.and Bool/F Bool/F = Bool/F +Bool.and Bool/True Bool/True = Bool/True +Bool.and Bool/False Bool/False = Bool/False Main = * diff --git a/tests/golden_tests/desugar_file/ask_branch.bend b/tests/golden_tests/desugar_file/ask_branch.bend index ce8fcbe89..98f5871c6 100644 --- a/tests/golden_tests/desugar_file/ask_branch.bend +++ b/tests/golden_tests/desugar_file/ask_branch.bend @@ -1,12 +1,8 @@ -type Bool: - T - F - def main: with IO: - match _ = Bool/T: - case Bool/T: + match _ = Bool/True: + case Bool/True: x <- wrap(0) - case Bool/F: + case Bool/False: x <- wrap(0) return wrap(x) diff --git a/tests/golden_tests/encode_pattern_match/and3.bend b/tests/golden_tests/encode_pattern_match/and3.bend index 670e709eb..b6f465f08 100644 --- a/tests/golden_tests/encode_pattern_match/and3.bend +++ b/tests/golden_tests/encode_pattern_match/and3.bend @@ -1,6 +1,5 @@ -type Bool = T | F -And (Bool/T, Bool/T, Bool/T) = Bool/T -And * = Bool/F +And (Bool/True, Bool/True, Bool/True) = Bool/True +And * = Bool/False -main = (And (Bool/F, Bool/T, Bool/F)) +main = (And (Bool/False, Bool/True, Bool/False)) diff --git a/tests/golden_tests/encode_pattern_match/bool_tup.bend b/tests/golden_tests/encode_pattern_match/bool_tup.bend index efc7af9c8..9136cfb76 100644 --- a/tests/golden_tests/encode_pattern_match/bool_tup.bend +++ b/tests/golden_tests/encode_pattern_match/bool_tup.bend @@ -1,6 +1,4 @@ -type Bool = T | F +foo (Bool/True, x) = x +foo * = Bool/False -foo (Bool/T, x) = x -foo * = Bool/F - -main = (foo (Bool/F, Bool/T)) +main = (foo (Bool/False, Bool/True)) diff --git a/tests/golden_tests/encode_pattern_match/common.bend b/tests/golden_tests/encode_pattern_match/common.bend index 4667e42cf..082497187 100644 --- a/tests/golden_tests/encode_pattern_match/common.bend +++ b/tests/golden_tests/encode_pattern_match/common.bend @@ -14,8 +14,6 @@ type List_ = (Cons x xs) | Nil -type Bool = True | False - type Light = Red | Yellow | Green type Direction diff --git a/tests/golden_tests/encode_pattern_match/definition_merge.bend b/tests/golden_tests/encode_pattern_match/definition_merge.bend index 052cfe252..c63c0aaca 100644 --- a/tests/golden_tests/encode_pattern_match/definition_merge.bend +++ b/tests/golden_tests/encode_pattern_match/definition_merge.bend @@ -1,5 +1,4 @@ type Either = (Left value) | (Right value) -type Bool = True | False Foo (Either/Left Bool/False) (Either/Left Bool/False) = 1 Foo (Either/Left Bool/False) (Either/Left Bool/True) = 1 diff --git a/tests/golden_tests/encode_pattern_match/list_merge_sort.bend b/tests/golden_tests/encode_pattern_match/list_merge_sort.bend index 6507e6616..dcf3d3899 100644 --- a/tests/golden_tests/encode_pattern_match/list_merge_sort.bend +++ b/tests/golden_tests/encode_pattern_match/list_merge_sort.bend @@ -1,4 +1,3 @@ -type Bool = True | False type List_ = (Cons head tail) | Nil If Bool/True then else = then diff --git a/tests/golden_tests/encode_pattern_match/var_only.bend b/tests/golden_tests/encode_pattern_match/var_only.bend index 5876a4d15..b1d742a9a 100644 --- a/tests/golden_tests/encode_pattern_match/var_only.bend +++ b/tests/golden_tests/encode_pattern_match/var_only.bend @@ -1,5 +1,3 @@ -type Bool = False | True - (Foo a b) = λf (f a) (Foo a b) = b diff --git a/tests/golden_tests/mutual_recursion/odd_even.bend b/tests/golden_tests/mutual_recursion/odd_even.bend index 612e01f55..600b085a5 100644 --- a/tests/golden_tests/mutual_recursion/odd_even.bend +++ b/tests/golden_tests/mutual_recursion/odd_even.bend @@ -1,5 +1,3 @@ -type Bool = True | False - (if_ 0 then else) = else (if_ _ then else) = then diff --git a/tests/golden_tests/run_file/example.bend b/tests/golden_tests/run_file/example.bend index fe374cd63..92a1124a3 100644 --- a/tests/golden_tests/run_file/example.bend +++ b/tests/golden_tests/run_file/example.bend @@ -27,7 +27,6 @@ # Write new data types like this type Option = (Some val) | None -type Bool = True | False # You can have pattern matching on definitions # Use `*` to ignore a pattern diff --git a/tests/golden_tests/run_file/filter_bool_id.bend b/tests/golden_tests/run_file/filter_bool_id.bend index f8d49cd40..ba2e6b3c7 100644 --- a/tests/golden_tests/run_file/filter_bool_id.bend +++ b/tests/golden_tests/run_file/filter_bool_id.bend @@ -1,17 +1,13 @@ -type Bool: - T - F - def filter(f, ls): match ls: case List/Nil: return List/Nil case List/Cons: match f(ls.head): - case Bool/T: + case Bool/True: return List/Cons(ls.head, filter(f, ls.tail)) - case Bool/F: + case Bool/False: return filter(f, ls.tail) def main: - return filter(lambda x: x, [Bool/T]) + return filter(lambda x: x, [Bool/True]) diff --git a/tests/golden_tests/run_file/mixed_syntax.bend b/tests/golden_tests/run_file/mixed_syntax.bend index 766d3bed9..6b47e8b56 100644 --- a/tests/golden_tests/run_file/mixed_syntax.bend +++ b/tests/golden_tests/run_file/mixed_syntax.bend @@ -1,7 +1,3 @@ -type Bool: - True - False - type MyTree = (node ~lft ~rgt) | (leaf val) def tree_xor(tree): diff --git a/tests/golden_tests/run_file/unscoped_never_used.bend b/tests/golden_tests/run_file/unscoped_never_used.bend index 07edaa7a2..685863e55 100644 --- a/tests/golden_tests/run_file/unscoped_never_used.bend +++ b/tests/golden_tests/run_file/unscoped_never_used.bend @@ -1,6 +1,4 @@ -type Bool = T | F - main = @x match x { - Bool/T : @$x * - Bool/F : @x * + Bool/True : @$x * + Bool/False : @x * } diff --git a/tests/snapshots/compile_file_o_all__non_exhaustive_and.bend.snap b/tests/snapshots/compile_file_o_all__non_exhaustive_and.bend.snap index d75690cbd..b5509c980 100644 --- a/tests/snapshots/compile_file_o_all__non_exhaustive_and.bend.snap +++ b/tests/snapshots/compile_file_o_all__non_exhaustive_and.bend.snap @@ -5,4 +5,4 @@ input_file: tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend Errors: In tests/golden_tests/compile_file_o_all/non_exhaustive_and.bend : In definition 'Bool.and': - Non-exhaustive pattern matching rule. Constructor 'Bool/F' of type 'Bool' not covered + Non-exhaustive pattern matching rule. Constructor 'Bool/False' of type 'Bool' not covered diff --git a/tests/snapshots/desugar_file__ask_branch.bend.snap b/tests/snapshots/desugar_file__ask_branch.bend.snap index 27e80ee09..13735593e 100644 --- a/tests/snapshots/desugar_file__ask_branch.bend.snap +++ b/tests/snapshots/desugar_file__ask_branch.bend.snap @@ -15,7 +15,13 @@ undefer: (((a -> a) -> b) -> b) (undefer) = λa (a λb b) unchecked main: Any -(main) = (IO/bind (Bool/T λa switch a { 0: (IO/wrap 0); _: λ* (IO/wrap 0); }) λb (b λc λd (c d) IO/wrap)) +(main) = (IO/bind (Bool/True λa switch a { 0: (IO/wrap 0); _: λ* (IO/wrap 0); }) λb (b λc λd (c d) IO/wrap)) + +Bool/True/tag: u24 +(Bool/True/tag) = 0 + +Bool/True: Bool +(Bool/True) = λa (a Bool/True/tag) IO/Done/tag: u24 (IO/Done/tag) = 0 @@ -29,18 +35,6 @@ IO/Call/tag: u24 IO/Call: ((u24, u24) -> String -> Any -> ((Result Any (IOError Any)) -> (IO a)) -> (IO a)) (IO/Call) = λa λb λc λd λe (e IO/Call/tag a b c d) -Bool/T/tag: u24 -(Bool/T/tag) = 0 - -Bool/T: Bool -(Bool/T) = λa (a Bool/T/tag) - -Bool/F/tag: u24 -(Bool/F/tag) = 1 - -Bool/F: Bool -(Bool/F) = λa (a Bool/F/tag) - IO/bind__C0: _ (IO/bind__C0) = λ* λa λb (undefer b a) diff --git a/tests/snapshots/encode_pattern_match__and3.bend.snap b/tests/snapshots/encode_pattern_match__and3.bend.snap index 1b6a84c82..952a20279 100644 --- a/tests/snapshots/encode_pattern_match__and3.bend.snap +++ b/tests/snapshots/encode_pattern_match__and3.bend.snap @@ -4,32 +4,32 @@ input_file: tests/golden_tests/encode_pattern_match/and3.bend --- Scott unchecked And: Any -(And) = λa let (b, c, d) = a; (b λe λf (e λg (g Bool/T Bool/F) λ* Bool/F f) λ* λ* Bool/F c d) +(And) = λa let (b, c, d) = a; (b λe λf (e λg (g Bool/True Bool/False) λ* Bool/False f) λ* λ* Bool/False c d) unchecked main: Any -(main) = (And (Bool/F, Bool/T, Bool/F)) +(main) = (And (Bool/False, Bool/True, Bool/False)) -Bool/T: Bool -(Bool/T) = λa λ* a +Bool/True: Bool +(Bool/True) = λa λ* a -Bool/F: Bool -(Bool/F) = λ* λb b +Bool/False: Bool +(Bool/False) = λ* λb b NumScott unchecked And: Any -(And) = λa let (b, c, d) = a; (b λe switch e { 0: λf λg (f λh switch h { 0: λi (i λj switch j { 0: Bool/T; _: λ* Bool/F; }); _: λ* λ* Bool/F; } g); _: λ* λ* λ* Bool/F; } c d) +(And) = λa let (b, c, d) = a; (b λe switch e { 0: λf λg (f λh switch h { 0: λi (i λj switch j { 0: Bool/True; _: λ* Bool/False; }); _: λ* λ* Bool/False; } g); _: λ* λ* λ* Bool/False; } c d) unchecked main: Any -(main) = (And (Bool/F, Bool/T, Bool/F)) +(main) = (And (Bool/False, Bool/True, Bool/False)) -Bool/T/tag: _ -(Bool/T/tag) = 0 +Bool/True/tag: _ +(Bool/True/tag) = 0 -Bool/T: Bool -(Bool/T) = λa (a Bool/T/tag) +Bool/True: Bool +(Bool/True) = λa (a Bool/True/tag) -Bool/F/tag: _ -(Bool/F/tag) = 1 +Bool/False/tag: _ +(Bool/False/tag) = 1 -Bool/F: Bool -(Bool/F) = λa (a Bool/F/tag) +Bool/False: Bool +(Bool/False) = λa (a Bool/False/tag) diff --git a/tests/snapshots/encode_pattern_match__bool_tup.bend.snap b/tests/snapshots/encode_pattern_match__bool_tup.bend.snap index ae4e71b54..c6274d188 100644 --- a/tests/snapshots/encode_pattern_match__bool_tup.bend.snap +++ b/tests/snapshots/encode_pattern_match__bool_tup.bend.snap @@ -4,32 +4,32 @@ input_file: tests/golden_tests/encode_pattern_match/bool_tup.bend --- Scott unchecked foo: Any -(foo) = λa let (b, c) = a; (b λd d λ* Bool/F c) +(foo) = λa let (b, c) = a; (b λd d λ* Bool/False c) unchecked main: Any -(main) = (foo (Bool/F, Bool/T)) +(main) = (foo (Bool/False, Bool/True)) -Bool/T: Bool -(Bool/T) = λa λ* a +Bool/True: Bool +(Bool/True) = λa λ* a -Bool/F: Bool -(Bool/F) = λ* λb b +Bool/False: Bool +(Bool/False) = λ* λb b NumScott unchecked foo: Any -(foo) = λa let (b, c) = a; (b λd switch d { 0: λe e; _: λ* λ* Bool/F; } c) +(foo) = λa let (b, c) = a; (b λd switch d { 0: λe e; _: λ* λ* Bool/False; } c) unchecked main: Any -(main) = (foo (Bool/F, Bool/T)) +(main) = (foo (Bool/False, Bool/True)) -Bool/T/tag: _ -(Bool/T/tag) = 0 +Bool/True/tag: _ +(Bool/True/tag) = 0 -Bool/T: Bool -(Bool/T) = λa (a Bool/T/tag) +Bool/True: Bool +(Bool/True) = λa (a Bool/True/tag) -Bool/F/tag: _ -(Bool/F/tag) = 1 +Bool/False/tag: _ +(Bool/False/tag) = 1 -Bool/F: Bool -(Bool/F) = λa (a Bool/F/tag) +Bool/False: Bool +(Bool/False) = λa (a Bool/False/tag) diff --git a/tests/snapshots/encode_pattern_match__common.bend.snap b/tests/snapshots/encode_pattern_match__common.bend.snap index 8ba0880f0..d01e03d16 100644 --- a/tests/snapshots/encode_pattern_match__common.bend.snap +++ b/tests/snapshots/encode_pattern_match__common.bend.snap @@ -27,12 +27,6 @@ List_/Cons: (Any -> Any -> List_) List_/Nil: List_ (List_/Nil) = λ* λb b -Bool/True: Bool -(Bool/True) = λa λ* a - -Bool/False: Bool -(Bool/False) = λ* λb b - Light/Red: Light (Light/Red) = λa λ* λ* a @@ -103,18 +97,6 @@ List_/Nil/tag: _ List_/Nil: List_ (List_/Nil) = λa (a List_/Nil/tag) -Bool/True/tag: _ -(Bool/True/tag) = 0 - -Bool/True: Bool -(Bool/True) = λa (a Bool/True/tag) - -Bool/False/tag: _ -(Bool/False/tag) = 1 - -Bool/False: Bool -(Bool/False) = λa (a Bool/False/tag) - Light/Red/tag: _ (Light/Red/tag) = 0 diff --git a/tests/snapshots/encode_pattern_match__definition_merge.bend.snap b/tests/snapshots/encode_pattern_match__definition_merge.bend.snap index ba5305920..2a753e7fb 100644 --- a/tests/snapshots/encode_pattern_match__definition_merge.bend.snap +++ b/tests/snapshots/encode_pattern_match__definition_merge.bend.snap @@ -12,12 +12,6 @@ Either/Left: (Any -> Either) Either/Right: (Any -> Either) (Either/Right) = λa λ* λc (c a) -Bool/True: Bool -(Bool/True) = λa λ* a - -Bool/False: Bool -(Bool/False) = λ* λb b - NumScott unchecked Foo: Any (Foo) = λa (a λb switch b { 0: λc (c λd switch d { 0: λe (e λh switch h { 0: λi (i λj switch j { 0: 1; _: λ* 1; }); _: λ* λk (k λl switch l { 0: 2; _: λ* 2; }); }); _: λ* λm (m λp switch p { 0: λq (q λr switch r { 0: 1; _: λ* 1; }); _: λ* λs (s λt switch t { 0: 2; _: λ* 2; }); }); }); _: λ* λu (u λv switch v { 0: λw (w λz switch z { 0: λab (ab λbb switch bb { 0: 3; _: λ* 3; }); _: λ* λcb (cb λdb switch db { 0: 3; _: λ* 3; }); }); _: λ* λeb (eb λhb switch hb { 0: λib (ib λjb switch jb { 0: 3; _: λ* 3; }); _: λ* λkb (kb λlb switch lb { 0: 3; _: λ* 3; }); }); }); }) @@ -33,15 +27,3 @@ Either/Right/tag: _ Either/Right: (Any -> Either) (Either/Right) = λa λb (b Either/Right/tag a) - -Bool/True/tag: _ -(Bool/True/tag) = 0 - -Bool/True: Bool -(Bool/True) = λa (a Bool/True/tag) - -Bool/False/tag: _ -(Bool/False/tag) = 1 - -Bool/False: Bool -(Bool/False) = λa (a Bool/False/tag) 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 d1e56e142..90e833ca3 100644 --- a/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap +++ b/tests/snapshots/encode_pattern_match__list_merge_sort.bend.snap @@ -24,12 +24,6 @@ unchecked MergePair: Any unchecked Merge: Any (Merge) = λa λb (b λc λd λe λf (f λh let {h h_2 h_3} = h; λi let {i i_2} = i; λj let {j j_2 j_3} = j; λk let {k k_2 k_3} = k; λl let {l l_2} = l; (If (j k h) (List_/Cons k_2 (Merge j_2 l (List_/Cons h_2 i))) (List_/Cons h_3 (Merge j_3 (List_/Cons k_3 l_2) i_2))) λ* λp λq (List_/Cons p q) e c d) λ* λs s a) -Bool/True: Bool -(Bool/True) = λa λ* a - -Bool/False: Bool -(Bool/False) = λ* λb b - List_/Cons: (Any -> Any -> List_) (List_/Cons) = λa λb λc λ* (c a b) @@ -58,18 +52,6 @@ unchecked MergePair: Any unchecked Merge: Any (Merge) = λa λb (b λc switch c { 0: λd λe λf λg (g λi switch i { 0: λj let {j j_2 j_3} = j; λk let {k k_2} = k; λl let {l l_2 l_3} = l; λm let {m m_2 m_3} = m; λn let {n n_2} = n; (If (l m j) (List_/Cons m_2 (Merge l_2 n (List_/Cons j_2 k))) (List_/Cons j_3 (Merge l_3 (List_/Cons m_3 n_2) k_2))); _: λ* λ* λr λs (List_/Cons r s); } f d e); _: λ* λ* λu u; } a) -Bool/True/tag: _ -(Bool/True/tag) = 0 - -Bool/True: Bool -(Bool/True) = λa (a Bool/True/tag) - -Bool/False/tag: _ -(Bool/False/tag) = 1 - -Bool/False: Bool -(Bool/False) = λa (a Bool/False/tag) - List_/Cons/tag: _ (List_/Cons/tag) = 0 diff --git a/tests/snapshots/encode_pattern_match__var_only.bend.snap b/tests/snapshots/encode_pattern_match__var_only.bend.snap index 9780a609b..01e50e07b 100644 --- a/tests/snapshots/encode_pattern_match__var_only.bend.snap +++ b/tests/snapshots/encode_pattern_match__var_only.bend.snap @@ -9,27 +9,9 @@ unchecked Foo: Any unchecked main: Any (main) = λ* Foo -Bool/False: Bool -(Bool/False) = λa λ* a - -Bool/True: Bool -(Bool/True) = λ* λb b - NumScott unchecked Foo: Any (Foo) = λa λ* λc (c a) unchecked main: Any (main) = λ* Foo - -Bool/False/tag: _ -(Bool/False/tag) = 0 - -Bool/False: Bool -(Bool/False) = λa (a Bool/False/tag) - -Bool/True/tag: _ -(Bool/True/tag) = 1 - -Bool/True: Bool -(Bool/True) = λa (a Bool/True/tag) diff --git a/tests/snapshots/run_file__filter_bool_id.bend.snap b/tests/snapshots/run_file__filter_bool_id.bend.snap index 760ed391e..8b995e9c2 100644 --- a/tests/snapshots/run_file__filter_bool_id.bend.snap +++ b/tests/snapshots/run_file__filter_bool_id.bend.snap @@ -3,7 +3,7 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/run_file/filter_bool_id.bend --- NumScott: -[Bool/T] +[Bool/True] Scott: -[Bool/T] +[Bool/True]