expose recursive definitions

This commit is contained in:
Folkert 2020-02-12 17:51:20 +01:00
parent cd7e760293
commit 4d762c0574
2 changed files with 19 additions and 3 deletions

View File

@ -153,9 +153,25 @@ pub fn canonicalize_module_defs<'a>(
}
}
}
DeclareRec(_defs) => {
panic!("TODO support exposing recursive defs");
DeclareRec(defs) => {
for def in defs {
for (symbol, variable) in def.pattern_vars.iter() {
if exposed_symbols.contains(symbol) {
// This is one of our exposed symbols;
// record the corresponding variable!
exposed_vars_by_symbol.push((*symbol, *variable));
// Remove this from exposed_symbols,
// so that at the end of the process,
// we can see if there were any
// exposed symbols which did not have
// corresponding defs.
exposed_symbols.remove(symbol);
}
}
}
}
InvalidCycle(identifiers, _) => {
panic!("TODO gracefully handle potentially attempting to expose invalid cyclic defs {:?}" , identifiers);
}

View File

@ -11,7 +11,7 @@ listMap : ConsList a, (a -> b) -> ConsList b
listMap = \list, f ->
when list is
Nil -> Nil
Cons x xs -> Cons (f x) (listMap f xs)
Cons x xs -> Cons (f x) (listMap xs f)
map : Result e a, (a -> b) -> Result e b
map = \result, f ->