preparation for recursive tag unions

This commit is contained in:
Folkert 2020-03-19 12:20:12 +01:00
parent 9d1e2a0ef1
commit c31116af87
2 changed files with 79 additions and 1 deletions

View file

@ -1311,6 +1311,84 @@ mod test_gen {
); );
} }
#[test]
fn maybe_is_just() {
assert_evals_to!(
indoc!(
r#"
Maybe a : [ Just a, Nothing ]
isJust : Maybe a -> Bool
isJust = \list ->
when list is
Nothing -> False
Just _ -> True
isJust (Just 42)
"#
),
true,
bool
);
}
// #[test]
// fn linked_list_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// empty : LinkedList Int
// empty = Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_singleton() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// singleton : LinkedList Int
// singleton = Cons 0x1 Nil
//
// 1
// "#
// ),
// 1,
// i64
// );
// }
//
// #[test]
// fn linked_list_is_empty() {
// assert_evals_to!(
// indoc!(
// r#"
// LinkedList a : [ Cons a (LinkedList a), Nil ]
//
// isEmpty : LinkedList a -> Bool
// isEmpty = \list ->
// when list is
// Nil -> True
// Cons _ _ -> False
//
// isEmpty (Cons 4 Nil)
// "#
// ),
// false,
// bool
// );
// }
#[test] #[test]
fn empty_record() { fn empty_record() {
assert_evals_to!( assert_evals_to!(

View file

@ -715,7 +715,7 @@ fn from_can<'a>(
variant_var, variant_var,
&mut tags, &mut tags,
) { ) {
Ok(()) => { Ok(()) | Err((_, Content::FlexVar(_))) => {
tags.sort(); tags.sort();
} }
other => panic!("invalid value in ext_var {:?}", other), other => panic!("invalid value in ext_var {:?}", other),