mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-04 00:55:00 +00:00
commit
211c297230
81 changed files with 1835 additions and 1744 deletions
|
|
@ -118,9 +118,9 @@ fn eq_bool_tag() {
|
|||
indoc!(
|
||||
r#"
|
||||
true : Bool
|
||||
true = True
|
||||
true = Bool.true
|
||||
|
||||
true == True
|
||||
true == Bool.true
|
||||
"#
|
||||
),
|
||||
true,
|
||||
|
|
@ -135,9 +135,9 @@ fn neq_bool_tag() {
|
|||
indoc!(
|
||||
r#"
|
||||
true : Bool
|
||||
true = True
|
||||
true = Bool.true
|
||||
|
||||
true == False
|
||||
true == Bool.false
|
||||
"#
|
||||
),
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -54,15 +54,10 @@ fn int_list_literal() {
|
|||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn bool_list_literal() {
|
||||
// NOTE: make sure to explicitly declare the elements to be of type bool, or
|
||||
// use both True and False; only using one of them causes the list to in practice be
|
||||
// of type `List [True]` or `List [False]`, those are tag unions with one constructor
|
||||
// and not fields, and don't have a runtime representation.
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
false : Bool
|
||||
false = False
|
||||
false = Bool.false
|
||||
|
||||
[false]
|
||||
"#
|
||||
|
|
@ -72,7 +67,7 @@ fn bool_list_literal() {
|
|||
);
|
||||
|
||||
assert_evals_to!(
|
||||
"[True, False, True]",
|
||||
"[Bool.true, Bool.false, Bool.true]",
|
||||
RocList::from_slice(&[true, false, true]),
|
||||
RocList<bool>
|
||||
);
|
||||
|
|
@ -81,7 +76,7 @@ fn bool_list_literal() {
|
|||
indoc!(
|
||||
r#"
|
||||
false : Bool
|
||||
false = False
|
||||
false = Bool.false
|
||||
|
||||
[false]
|
||||
"#
|
||||
|
|
@ -94,7 +89,7 @@ fn bool_list_literal() {
|
|||
indoc!(
|
||||
r#"
|
||||
true : Bool
|
||||
true = True
|
||||
true = Bool.true
|
||||
|
||||
List.repeat true 23
|
||||
"#
|
||||
|
|
@ -107,7 +102,7 @@ fn bool_list_literal() {
|
|||
indoc!(
|
||||
r#"
|
||||
true : Bool
|
||||
true = True
|
||||
true = Bool.true
|
||||
|
||||
List.repeat { x: true, y: true } 23
|
||||
"#
|
||||
|
|
@ -120,7 +115,7 @@ fn bool_list_literal() {
|
|||
indoc!(
|
||||
r#"
|
||||
true : Bool
|
||||
true = True
|
||||
true = Bool.true
|
||||
|
||||
List.repeat { x: true, y: true, a: true, b: true, c: true, d : true, e: true, f: true } 23
|
||||
"#
|
||||
|
|
@ -503,7 +498,7 @@ fn list_drop_at_shared() {
|
|||
indoc!(
|
||||
r#"
|
||||
list : List I64
|
||||
list = [if True then 4 else 4, 5, 6]
|
||||
list = [if Bool.true then 4 else 4, 5, 6]
|
||||
|
||||
{ newList: List.dropAt list 0, original: list }
|
||||
"#
|
||||
|
|
@ -527,7 +522,7 @@ fn list_drop_if_empty_list_of_int() {
|
|||
empty : List I64
|
||||
empty = []
|
||||
|
||||
List.dropIf empty \_ -> True
|
||||
List.dropIf empty \_ -> Bool.true
|
||||
"#
|
||||
),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
|
|
@ -542,7 +537,7 @@ fn list_drop_if_empty_list() {
|
|||
indoc!(
|
||||
r#"
|
||||
alwaysTrue : I64 -> Bool
|
||||
alwaysTrue = \_ -> True
|
||||
alwaysTrue = \_ -> Bool.true
|
||||
|
||||
List.dropIf [] alwaysTrue
|
||||
"#
|
||||
|
|
@ -558,7 +553,7 @@ fn list_drop_if_always_false_for_non_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
List.dropIf [1,2,3,4,5,6,7,8] (\_ -> False)
|
||||
List.dropIf [1,2,3,4,5,6,7,8] (\_ -> Bool.false)
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
|
|
@ -572,7 +567,7 @@ fn list_drop_if_always_true_for_non_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
List.dropIf [1,2,3,4,5,6,7,8] (\_ -> True)
|
||||
List.dropIf [1,2,3,4,5,6,7,8] (\_ -> Bool.true)
|
||||
"#
|
||||
),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
|
|
@ -635,7 +630,7 @@ fn list_drop_last_mutable() {
|
|||
indoc!(
|
||||
r#"
|
||||
list : List I64
|
||||
list = [if True then 4 else 4, 5, 6]
|
||||
list = [if Bool.true then 4 else 4, 5, 6]
|
||||
|
||||
{ newList: List.dropLast list, original: list }
|
||||
"#
|
||||
|
|
@ -734,7 +729,7 @@ fn list_append_to_empty_list_of_int() {
|
|||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn list_append_bools() {
|
||||
assert_evals_to!(
|
||||
"List.append [True, False] True",
|
||||
"List.append [Bool.true, Bool.false] Bool.true",
|
||||
RocList::from_slice(&[true, false, true]),
|
||||
RocList<bool>
|
||||
);
|
||||
|
|
@ -793,7 +788,7 @@ fn list_prepend() {
|
|||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn list_prepend_bools() {
|
||||
assert_evals_to!(
|
||||
"List.prepend [True, False] True",
|
||||
"List.prepend [Bool.true, Bool.false] Bool.true",
|
||||
RocList::from_slice(&[true, true, false]),
|
||||
RocList<bool>
|
||||
);
|
||||
|
|
@ -971,7 +966,7 @@ fn list_keep_if_empty_list_of_int() {
|
|||
empty =
|
||||
[]
|
||||
|
||||
List.keepIf empty \_ -> True
|
||||
List.keepIf empty \_ -> Bool.true
|
||||
"#
|
||||
),
|
||||
RocList::<i64>::from_slice(&[]),
|
||||
|
|
@ -987,7 +982,7 @@ fn list_keep_if_empty_list() {
|
|||
r#"
|
||||
alwaysTrue : I64 -> Bool
|
||||
alwaysTrue = \_ ->
|
||||
True
|
||||
Bool.true
|
||||
|
||||
|
||||
List.keepIf [] alwaysTrue
|
||||
|
|
@ -1006,7 +1001,7 @@ fn list_keep_if_always_true_for_non_empty_list() {
|
|||
r#"
|
||||
alwaysTrue : I64 -> Bool
|
||||
alwaysTrue = \_ ->
|
||||
True
|
||||
Bool.true
|
||||
|
||||
oneThroughEight : List I64
|
||||
oneThroughEight =
|
||||
|
|
@ -1028,7 +1023,7 @@ fn list_keep_if_always_false_for_non_empty_list() {
|
|||
r#"
|
||||
alwaysFalse : I64 -> Bool
|
||||
alwaysFalse = \_ ->
|
||||
False
|
||||
Bool.false
|
||||
|
||||
List.keepIf [1,2,3,4,5,6,7,8] alwaysFalse
|
||||
"#
|
||||
|
|
@ -2308,7 +2303,7 @@ fn quicksort() {
|
|||
partitionHelp : Nat, Nat, List (Num a), Nat, Num a -> [Pair Nat (List (Num a))]
|
||||
partitionHelp = \i, j, list, high, pivot ->
|
||||
# if j < high then
|
||||
if False then
|
||||
if Bool.false then
|
||||
when List.get list j is
|
||||
Ok value ->
|
||||
if value <= pivot then
|
||||
|
|
@ -2791,7 +2786,7 @@ fn list_any() {
|
|||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_any_empty_with_unknown_element_type() {
|
||||
assert_evals_to!("List.any [] (\\_ -> True)", false, bool);
|
||||
assert_evals_to!("List.any [] (\\_ -> Bool.true)", false, bool);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -2806,7 +2801,7 @@ fn list_all() {
|
|||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_all_empty_with_unknown_element_type() {
|
||||
assert_evals_to!("List.all [] (\\_ -> True)", true, bool);
|
||||
assert_evals_to!("List.all [] (\\_ -> Bool.true)", true, bool);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -2825,7 +2820,7 @@ fn lists_with_incompatible_type_param_in_if() {
|
|||
|
||||
list2 = [""]
|
||||
|
||||
x = if True then list1 else list2
|
||||
x = if Bool.true then list1 else list2
|
||||
|
||||
""
|
||||
"#
|
||||
|
|
@ -2864,7 +2859,7 @@ fn empty_list_of_function_type() {
|
|||
myClosure = \_ -> "bar"
|
||||
|
||||
choose =
|
||||
if False then
|
||||
if Bool.false then
|
||||
myList
|
||||
else
|
||||
[myClosure]
|
||||
|
|
@ -3003,7 +2998,7 @@ fn list_find_empty_layout() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
List.findFirst [] \_ -> True
|
||||
List.findFirst [] \_ -> Bool.true
|
||||
"#
|
||||
),
|
||||
// [Ok [], Err [NotFound]] gets unwrapped all the way to just [NotFound],
|
||||
|
|
@ -3015,7 +3010,7 @@ fn list_find_empty_layout() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
List.findLast [] \_ -> True
|
||||
List.findLast [] \_ -> Bool.true
|
||||
"#
|
||||
),
|
||||
// [Ok [], Err [NotFound]] gets unwrapped all the way to just [NotFound],
|
||||
|
|
|
|||
|
|
@ -3800,7 +3800,7 @@ fn condition_polymorphic_num_becomes_float() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
x = if True then 2 else 3
|
||||
x = if Bool.true then 2 else 3
|
||||
x * 5f32
|
||||
"#
|
||||
),
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ fn undefined_variable() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
if True then
|
||||
if Bool.true then
|
||||
x + z
|
||||
else
|
||||
y + z
|
||||
|
|
@ -1262,10 +1262,10 @@ fn linked_list_is_singleton() {
|
|||
isSingleton = \list ->
|
||||
when list is
|
||||
Cons _ Nil ->
|
||||
True
|
||||
Bool.true
|
||||
|
||||
_ ->
|
||||
False
|
||||
Bool.false
|
||||
|
||||
main : Bool
|
||||
main =
|
||||
|
|
@ -1297,10 +1297,10 @@ fn linked_list_is_empty_1() {
|
|||
isEmpty = \list ->
|
||||
when list is
|
||||
Cons _ _ ->
|
||||
False
|
||||
Bool.false
|
||||
|
||||
Nil ->
|
||||
True
|
||||
Bool.true
|
||||
|
||||
main : Bool
|
||||
main =
|
||||
|
|
@ -1329,10 +1329,10 @@ fn linked_list_is_empty_2() {
|
|||
isEmpty = \list ->
|
||||
when list is
|
||||
Cons _ _ ->
|
||||
False
|
||||
Bool.false
|
||||
|
||||
Nil ->
|
||||
True
|
||||
Bool.true
|
||||
|
||||
main : Bool
|
||||
main =
|
||||
|
|
@ -2006,9 +2006,9 @@ fn hof_conditional() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
passTrue = \f -> f True
|
||||
passTrue = \f -> f Bool.true
|
||||
|
||||
passTrue (\trueVal -> if trueVal then False else True)
|
||||
passTrue (\trueVal -> if trueVal then Bool.false else Bool.true)
|
||||
"#
|
||||
),
|
||||
0,
|
||||
|
|
@ -2087,8 +2087,8 @@ fn fingertree_basic() {
|
|||
main : Bool
|
||||
main =
|
||||
when cons 0x1 Nil is
|
||||
Unit 1 -> True
|
||||
_ -> False
|
||||
Unit 1 -> Bool.true
|
||||
_ -> Bool.false
|
||||
"#
|
||||
),
|
||||
true,
|
||||
|
|
@ -2136,8 +2136,8 @@ fn rosetree_basic() {
|
|||
x : Tree F64
|
||||
x = singleton 3
|
||||
when x is
|
||||
Tree 3.0 _ -> True
|
||||
_ -> False
|
||||
Tree 3.0 _ -> Bool.true
|
||||
_ -> Bool.false
|
||||
"#
|
||||
),
|
||||
true,
|
||||
|
|
@ -2338,7 +2338,7 @@ fn multiple_increment() {
|
|||
leaf = Leaf
|
||||
|
||||
m : Map
|
||||
m = Node Black (Node Black leaf 10 False leaf) 11 False (Node Black leaf 12 False (Node Red leaf 13 False leaf))
|
||||
m = Node Black (Node Black leaf 10 Bool.false leaf) 11 Bool.false (Node Black leaf 12 Bool.false (Node Red leaf 13 Bool.false leaf))
|
||||
|
||||
when m is
|
||||
Leaf -> 0
|
||||
|
|
@ -2550,7 +2550,7 @@ fn increment_or_double_closure() {
|
|||
two = 2
|
||||
|
||||
b : Bool
|
||||
b = True
|
||||
b = Bool.true
|
||||
|
||||
increment : I64 -> I64
|
||||
increment = \x -> x + one
|
||||
|
|
@ -2558,7 +2558,7 @@ fn increment_or_double_closure() {
|
|||
double : I64 -> I64
|
||||
double = \x -> if b then x * two else x
|
||||
|
||||
f = (if True then increment else double)
|
||||
f = (if Bool.true then increment else double)
|
||||
|
||||
apply f 42
|
||||
"#
|
||||
|
|
@ -2879,7 +2879,7 @@ fn unresolved_tvar_when_capture_is_unused() {
|
|||
main : I64
|
||||
main =
|
||||
r : Bool
|
||||
r = False
|
||||
r = Bool.false
|
||||
|
||||
p1 = (\_ -> r == (1 == 1))
|
||||
oneOfResult = List.map [p1] (\p -> p Green)
|
||||
|
|
@ -3399,7 +3399,7 @@ fn polymorphic_lambda_set_usage() {
|
|||
r#"
|
||||
id1 = \x -> x
|
||||
id2 = \y -> y
|
||||
id = if True then id1 else id2
|
||||
id = if Bool.true then id1 else id2
|
||||
|
||||
id 9u8
|
||||
"#
|
||||
|
|
@ -3417,7 +3417,7 @@ fn polymorphic_lambda_set_multiple_specializations() {
|
|||
r#"
|
||||
id1 = \x -> x
|
||||
id2 = \y -> y
|
||||
id = if True then id1 else id2
|
||||
id = if Bool.true then id1 else id2
|
||||
|
||||
(id 9u8) + Num.toU8 (id 16u16)
|
||||
"#
|
||||
|
|
@ -3449,7 +3449,7 @@ fn list_map2_conslist() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn mutual_recursion_top_level_defs() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
@ -3458,14 +3458,14 @@ fn mutual_recursion_top_level_defs() {
|
|||
|
||||
isEven = \n ->
|
||||
when n is
|
||||
0 -> True
|
||||
1 -> False
|
||||
0 -> Bool.true
|
||||
1 -> Bool.false
|
||||
_ -> isOdd (n - 1)
|
||||
|
||||
isOdd = \n ->
|
||||
when n is
|
||||
0 -> False
|
||||
1 -> True
|
||||
0 -> Bool.false
|
||||
1 -> Bool.true
|
||||
_ -> isEven (n - 1)
|
||||
|
||||
main = isOdd 11
|
||||
|
|
@ -3486,7 +3486,7 @@ fn polymorphic_lambda_captures_polymorphic_value() {
|
|||
|
||||
f1 = \_ -> x
|
||||
|
||||
f = if True then f1 else f1
|
||||
f = if Bool.true then f1 else f1
|
||||
f {}
|
||||
"#
|
||||
),
|
||||
|
|
@ -3506,13 +3506,14 @@ fn lambda_capture_niche_u64_vs_u8_capture() {
|
|||
\{} ->
|
||||
Num.toStr val
|
||||
|
||||
x : [True, False]
|
||||
x = True
|
||||
x : Bool
|
||||
x = Bool.true
|
||||
|
||||
fun =
|
||||
when x is
|
||||
True -> capture 123u64
|
||||
False -> capture 18u8
|
||||
if x then
|
||||
capture 123u64
|
||||
else
|
||||
capture 18u8
|
||||
|
||||
fun {}
|
||||
"#
|
||||
|
|
@ -3608,12 +3609,13 @@ fn lambda_capture_niches_have_captured_function_in_closure() {
|
|||
|
||||
fun = \x ->
|
||||
h =
|
||||
when x is
|
||||
True -> after (\{} -> "") f
|
||||
False -> after (\{} -> {s1: "s1"}) g
|
||||
if x then
|
||||
after (\{} -> "") f
|
||||
else
|
||||
after (\{} -> {s1: "s1"}) g
|
||||
h {}
|
||||
|
||||
{a: fun False, b: fun True}
|
||||
{a: fun Bool.false, b: fun Bool.true}
|
||||
"#
|
||||
),
|
||||
(RocStr::from("s1"), RocStr::from("fun f")),
|
||||
|
|
@ -4007,10 +4009,10 @@ fn mutually_recursive_captures() {
|
|||
indoc!(
|
||||
r#"
|
||||
x : Bool
|
||||
x = True
|
||||
x = Bool.true
|
||||
|
||||
y : Bool
|
||||
y = False
|
||||
y = Bool.false
|
||||
|
||||
a = "foo"
|
||||
b = "bar"
|
||||
|
|
@ -4035,9 +4037,9 @@ fn monomorphization_sees_polymorphic_recursion() {
|
|||
foo : a, Bool -> Str
|
||||
foo = \in, b -> if b then "done" else bar in
|
||||
|
||||
bar = \_ -> foo {} True
|
||||
bar = \_ -> foo {} Bool.true
|
||||
|
||||
foo "" False
|
||||
foo "" Bool.false
|
||||
"#
|
||||
),
|
||||
RocStr::from("done"),
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ fn f64_record2_literal() {
|
|||
// indoc!(
|
||||
// r#"
|
||||
// record : { a : Bool, b : Bool, c : Bool, d : Bool }
|
||||
// record = { a: True, b: True, c : True, d : Bool }
|
||||
// record = { a: Bool.true, b: Bool.true, c : Bool.true, d : Bool }
|
||||
|
||||
// record
|
||||
// "#
|
||||
|
|
@ -366,7 +366,7 @@ fn bool_literal() {
|
|||
indoc!(
|
||||
r#"
|
||||
x : Bool
|
||||
x = True
|
||||
x = Bool.true
|
||||
|
||||
x
|
||||
"#
|
||||
|
|
@ -894,7 +894,9 @@ fn booleans_in_record() {
|
|||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn alignment_in_record() {
|
||||
assert_evals_to!(
|
||||
indoc!("{ c: 32, b: if True then Red else if True then Green else Blue, a: 1 == 1 }"),
|
||||
indoc!(
|
||||
"{ c: 32, b: if Bool.true then Red else if Bool.true then Green else Blue, a: 1 == 1 }"
|
||||
),
|
||||
(32i64, true, 2u8),
|
||||
(i64, bool, u8)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ fn boxed_str_dec() {
|
|||
s = Str.concat "A long enough string " "to be heap-allocated"
|
||||
b = Box.box s
|
||||
|
||||
if False then
|
||||
if Bool.false then
|
||||
ReturnTheBox b
|
||||
else
|
||||
DeallocateEverything
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ fn roc_result_err() {
|
|||
fn issue_2583_specialize_errors_behind_unified_branches() {
|
||||
assert_evals_to!(
|
||||
r#"
|
||||
if True then List.first [15] else Str.toI64 ""
|
||||
if Bool.true then List.first [15] else Str.toI64 ""
|
||||
"#,
|
||||
RocResult::ok(15i64),
|
||||
RocResult<i64, bool>
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ fn true_is_true() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
bool : [True, False]
|
||||
bool = True
|
||||
bool : Bool
|
||||
bool = Bool.true
|
||||
|
||||
bool
|
||||
"#
|
||||
|
|
@ -132,8 +132,8 @@ fn false_is_false() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
bool : [True, False]
|
||||
bool = False
|
||||
bool : Bool
|
||||
bool = Bool.false
|
||||
|
||||
bool
|
||||
"#
|
||||
|
|
@ -214,8 +214,8 @@ fn basic_enum() {
|
|||
// isEmpty : LinkedList a -> Bool
|
||||
// isEmpty = \list ->
|
||||
// when list is
|
||||
// Nil -> True
|
||||
// Cons _ _ -> False
|
||||
// Nil -> Bool.true
|
||||
// Cons _ _ -> Bool.false
|
||||
//
|
||||
// isEmpty (Cons 4 Nil)
|
||||
// "#
|
||||
|
|
@ -232,14 +232,14 @@ fn even_odd() {
|
|||
r#"
|
||||
even = \n ->
|
||||
when n is
|
||||
0 -> True
|
||||
1 -> False
|
||||
0 -> Bool.true
|
||||
1 -> Bool.false
|
||||
_ -> odd (n - 1)
|
||||
|
||||
odd = \n ->
|
||||
when n is
|
||||
0 -> False
|
||||
1 -> True
|
||||
0 -> Bool.false
|
||||
1 -> Bool.true
|
||||
_ -> even (n - 1)
|
||||
|
||||
odd 5 && even 42
|
||||
|
|
@ -256,7 +256,7 @@ fn gen_literal_true() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
if True then -1 else 1
|
||||
if Bool.true then -1 else 1
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
|
|
@ -270,7 +270,7 @@ fn gen_if_float() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
if True then -1.0 else 1.0
|
||||
if Bool.true then -1.0 else 1.0
|
||||
"#
|
||||
),
|
||||
-1.0,
|
||||
|
|
@ -424,8 +424,8 @@ fn maybe_is_just_not_nested() {
|
|||
isJust : Maybe a -> Bool
|
||||
isJust = \list ->
|
||||
when list is
|
||||
Nothing -> False
|
||||
Just _ -> True
|
||||
Nothing -> Bool.false
|
||||
Just _ -> Bool.true
|
||||
|
||||
main =
|
||||
isJust (Just 42)
|
||||
|
|
@ -447,8 +447,8 @@ fn maybe_is_just_nested() {
|
|||
isJust : Maybe a -> Bool
|
||||
isJust = \list ->
|
||||
when list is
|
||||
Nothing -> False
|
||||
Just _ -> True
|
||||
Nothing -> Bool.false
|
||||
Just _ -> Bool.true
|
||||
|
||||
isJust (Just 42)
|
||||
"#
|
||||
|
|
@ -601,7 +601,7 @@ fn if_guard_pattern_false() {
|
|||
r#"
|
||||
wrapper = \{} ->
|
||||
when 2 is
|
||||
2 if False -> 0
|
||||
2 if Bool.false -> 0
|
||||
_ -> 42
|
||||
|
||||
wrapper {}
|
||||
|
|
@ -620,7 +620,7 @@ fn if_guard_switch() {
|
|||
r#"
|
||||
wrapper = \{} ->
|
||||
when 2 is
|
||||
2 | 3 if False -> 0
|
||||
2 | 3 if Bool.false -> 0
|
||||
_ -> 42
|
||||
|
||||
wrapper {}
|
||||
|
|
@ -639,7 +639,7 @@ fn if_guard_pattern_true() {
|
|||
r#"
|
||||
wrapper = \{} ->
|
||||
when 2 is
|
||||
2 if True -> 42
|
||||
2 if Bool.true -> 42
|
||||
_ -> 0
|
||||
|
||||
wrapper {}
|
||||
|
|
@ -658,7 +658,7 @@ fn if_guard_exhaustiveness() {
|
|||
r#"
|
||||
wrapper = \{} ->
|
||||
when 2 is
|
||||
_ if False -> 0
|
||||
_ if Bool.false -> 0
|
||||
_ -> 42
|
||||
|
||||
wrapper {}
|
||||
|
|
@ -814,7 +814,7 @@ fn join_point_if() {
|
|||
indoc!(
|
||||
r#"
|
||||
x =
|
||||
if True then 1 else 2
|
||||
if Bool.true then 1 else 2
|
||||
|
||||
x
|
||||
"#
|
||||
|
|
@ -895,7 +895,7 @@ fn alignment_in_single_tag_construction() {
|
|||
assert_evals_to!(indoc!("Three (1 == 1) 32"), (32i64, true), (i64, bool));
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!("Three (1 == 1) (if True then Red else if True then Green else Blue) 32"),
|
||||
indoc!("Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32"),
|
||||
(32i64, true, 2u8),
|
||||
(i64, bool, u8)
|
||||
);
|
||||
|
|
@ -921,7 +921,7 @@ fn alignment_in_single_tag_pattern_match() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r"#
|
||||
x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32
|
||||
x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32
|
||||
|
||||
when x is
|
||||
Three bool color int ->
|
||||
|
|
@ -958,7 +958,7 @@ fn alignment_in_multi_tag_construction_three() {
|
|||
indoc!(
|
||||
r"#
|
||||
x : [Three Bool [Red, Green, Blue] I64, Empty]
|
||||
x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32
|
||||
x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32
|
||||
|
||||
x
|
||||
#"
|
||||
|
|
@ -982,7 +982,7 @@ fn alignment_in_multi_tag_pattern_match() {
|
|||
{ bool, int }
|
||||
|
||||
Empty ->
|
||||
{ bool: False, int: 0 }
|
||||
{ bool: Bool.false, int: 0 }
|
||||
#"
|
||||
),
|
||||
(32i64, true),
|
||||
|
|
@ -993,13 +993,13 @@ fn alignment_in_multi_tag_pattern_match() {
|
|||
indoc!(
|
||||
r"#
|
||||
x : [Three Bool [Red, Green, Blue] I64, Empty]
|
||||
x = Three (1 == 1) (if True then Red else if True then Green else Blue) 32
|
||||
x = Three (1 == 1) (if Bool.true then Red else if Bool.true then Green else Blue) 32
|
||||
|
||||
when x is
|
||||
Three bool color int ->
|
||||
{ bool, color, int }
|
||||
Empty ->
|
||||
{ bool: False, color: Red, int: 0 }
|
||||
{ bool: Bool.false, color: Red, int: 0 }
|
||||
#"
|
||||
),
|
||||
(32i64, true, 2u8),
|
||||
|
|
@ -1237,8 +1237,8 @@ fn monomorphized_tag() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
b = False
|
||||
f : Bool, [True, False, Idk] -> U8
|
||||
b = Bar
|
||||
f : [Foo, Bar], [Bar, Baz] -> U8
|
||||
f = \_, _ -> 18
|
||||
f b b
|
||||
"#
|
||||
|
|
@ -1853,10 +1853,10 @@ fn error_type_in_tag_union_payload() {
|
|||
r#"
|
||||
f : ([] -> Bool) -> Bool
|
||||
f = \fun ->
|
||||
if True then
|
||||
if Bool.true then
|
||||
fun 42
|
||||
else
|
||||
False
|
||||
Bool.false
|
||||
|
||||
f (\x -> x)
|
||||
"#
|
||||
|
|
|
|||
|
|
@ -299,14 +299,14 @@ fn small_str_zeroed_literal() {
|
|||
reusedSpace = createStr isForRealThisTime
|
||||
|
||||
# Unoptimised 'if' ensures that we don't just allocate in the caller's frame
|
||||
if True then
|
||||
if Bool.true then
|
||||
reusedSpace
|
||||
else
|
||||
reusedSpace
|
||||
|
||||
main =
|
||||
garbage = functionWithReusedSpace False
|
||||
functionWithReusedSpace True
|
||||
garbage = functionWithReusedSpace Bool.false
|
||||
functionWithReusedSpace Bool.true
|
||||
"#
|
||||
),
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue