List prepend implementation with tests, and a few small code clarity changes to list_push implementation

This commit is contained in:
Chad Stearns 2020-07-25 19:22:01 -04:00
parent fc52bdc59a
commit 68b13d29fd
7 changed files with 214 additions and 10 deletions

View file

@ -510,7 +510,7 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
),
);
// push : List elem -> elem -> List elem
// push : List elem, elem -> List elem
add_type(
Symbol::LIST_PUSH,
SolvedType::Func(
@ -519,6 +519,15 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
),
);
// prepend : List elem, elem -> List elem
add_type(
Symbol::LIST_PREPEND,
SolvedType::Func(
vec![list_type(flex(TVAR1)), flex(TVAR1)],
Box::new(list_type(flex(TVAR1))),
),
);
// single : a -> List a
add_type(
Symbol::LIST_SINGLE,