X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=sem.icl;h=5cf0520adb2a8d68f50d664ae427a994e0052a0f;hb=74b900cf6db033a51e177f7f85d835dae44217e5;hp=68e08591d4b413610960752955b4f9f42da1261d;hpb=74b8c52b6f00b15208e55e0e6c1ed56ce888f0db;p=cc1516.git diff --git a/sem.icl b/sem.icl index 68e0859..5cf0520 100644 --- a/sem.icl +++ b/sem.icl @@ -225,6 +225,8 @@ instance infer Expr where infer e2 >>= \(s2, t2, e2_) -> pure (compose s2 s1, TupleType (t1,t2), TupleExpr p (e1_,e2_)) + LambdaExpr _ _ _ = liftT $ Left $ Error "PANIC: lambdas should be tasnformed" + FunExpr p f args fs = lookup f >>= \expected -> let accST = (\(s,ts,es) e->infer e >>= \(s_,et,e_)-> pure (compose s_ s,ts++[et],es++[e_])) in @@ -384,13 +386,13 @@ instance type FunDecl where (case expected of Nothing = pure zero Just (FuncType expected_) = lift (unify expected_ given) - Just expected_ = lift (unify expected_ given)) - >>= \s3 -> + Just expected_ = lift (unify expected_ given) + ) >>= \s3 -> let ftype = subst (compose s3 $ compose s2 s1) given in - (case expected of - Just (FuncType _) = pure (FuncType ftype) - _ = pure ftype) - >>= \ftype_-> + (case ftype of + _ ->> _ = pure ftype + _ = pure $ FuncType ftype + ) >>= \ftype_-> generalize ftype_ >>= \t-> putGamma outerScope >>| changeGamma (extend f t) >>|