From: pimjager Date: Tue, 21 Jun 2016 08:50:52 +0000 (+0200) Subject: improving type checking X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=1f77588b4d69fdb9f8880864240458efd5b51561;p=cc1516.git improving type checking --- diff --git a/sem.icl b/sem.icl index 9eac35b..a65bef6 100644 --- a/sem.icl +++ b/sem.icl @@ -262,7 +262,9 @@ instance infer Expr where Op2Expr p e1 op e2 = infer e1 >>= \(s1, t1, e1_) -> + applySubst s1 >>| infer e2 >>= \(s2, t2, e2_) -> + applySubst s2 >>| fresh >>= \tv -> let given = t1 ->> t2 ->> tv in op2Type op >>= \expected -> @@ -301,6 +303,7 @@ instance infer Expr where ) >>= \newF-> fresh >>= \tv->case expected of FuncType t = pure (s1, t, (FunExpr p newF args fs)) + //TODO: Fieldselectors! _ = (let given = foldr (->>) tv argTs in lift (unify expected given) >>= \s2-> let fReturnType = subst s2 tv in @@ -390,6 +393,7 @@ instance infer Stmt where pure (compose s2 s1, VoidType, FunStmt newF args_ fs) ReturnStmt Nothing = pure (zero, VoidType, s) + //hier ook sub applyen ReturnStmt (Just e) = infer e >>= \(sub, t, e_)-> pure (sub, t, ReturnStmt (Just e_)) reverseFs :: Type FieldSelector -> Typing Type