union and intersection

This commit is contained in:
Folkert 2021-02-14 19:55:01 +01:00
parent cbe91abcc2
commit 02db8f1a05
11 changed files with 579 additions and 1 deletions

View file

@ -819,6 +819,42 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
),
);
// Dict.union : Dict k v, Dict k v -> Dict k v
add_type(
Symbol::DICT_UNION,
top_level_function(
vec![
dict_type(flex(TVAR1), flex(TVAR2)),
dict_type(flex(TVAR1), flex(TVAR2)),
],
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
),
);
// Dict.intersection : Dict k v, Dict k v -> Dict k v
add_type(
Symbol::DICT_INTERSECTION,
top_level_function(
vec![
dict_type(flex(TVAR1), flex(TVAR2)),
dict_type(flex(TVAR1), flex(TVAR2)),
],
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
),
);
// Dict.difference : Dict k v, Dict k v -> Dict k v
add_type(
Symbol::DICT_DIFFERENCE,
top_level_function(
vec![
dict_type(flex(TVAR1), flex(TVAR2)),
dict_type(flex(TVAR1), flex(TVAR2)),
],
Box::new(dict_type(flex(TVAR1), flex(TVAR2))),
),
);
// Set module
// empty : Set a