start support for recursive let
[minfp.git] / check.icl
index 8a4ea5c..b0e078d 100644 (file)
--- a/check.icl
+++ b/check.icl
@@ -21,7 +21,7 @@ check fs
        = case partition (\a->a=:(Function ['start'] _ _)) fs of
                ([], _) = Left ["No start function defined"]
                ([Function _ [] e], fs)
-                       # e = foldr (\(Function i a e)->Let i (foldr ((o) o Lambda) id a e)) e fs
+                       # e = foldr (\(Function i a e)->Let [(i, (foldr ((o) o Lambda) id a e))]) e fs
                        = (\x->(e, x)) <$> runInfer (infer preamble e)
                ([Function _ _ _], _) = Left ["Start cannot have arguments"]
 
@@ -129,7 +129,7 @@ infer env (Lambda x b)
 //     =              infer env e1
 //     >>= \(s1, t1)->infer ('Data.Map'.put x (generalize (apply s1 env) t1) env) e2
 //     >>= \(s2, t2)->pure (s1 oo s2, t2)
-infer env (Let x e1 e2)
+infer env (Let [(x, e1)] e2)
        =              fresh
        >>= \tv->      infer ('Data.Map'.put x (Forall [] tv) env) e1
        >>= \(s1, t1)->infer ('Data.Map'.put x (generalize (apply s1 env) t1) env) e2