feat(List): add walk function and fix walkBackwards

This commit is contained in:
rvcas 2020-11-24 09:01:03 -05:00
parent d9e906b8fb
commit 8feab843ea
9 changed files with 210 additions and 26 deletions

View file

@ -777,7 +777,34 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
)
});
// walkRight : Attr (* | u) (List (Attr u a))
// walk : Attr (* | u) (List (Attr u a))
// , Attr Shared (Attr u a -> b -> b)
// , b
// -> b
add_type(Symbol::LIST_WALK, {
let_tvars! { u, a, b, star1, closure };
unique_function(
vec![
SolvedType::Apply(
Symbol::ATTR_ATTR,
vec![
container(star1, vec![u]),
SolvedType::Apply(Symbol::LIST_LIST, vec![attr_type(u, a)]),
],
),
shared(SolvedType::Func(
vec![attr_type(u, a), flex(b)],
Box::new(flex(closure)),
Box::new(flex(b)),
)),
flex(b),
],
flex(b),
)
});
// walkBackwards : Attr (* | u) (List (Attr u a))
// , Attr Shared (Attr u a -> b -> b)
// , b
// -> b