X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=sem.icl;h=af49fdfa35aca8668a97f3da6992e7a8d45e11e9;hb=5133b2b81d244d3f05930481366082a00fc95c3b;hp=68b804d42939c49739bb662f0688ccd527740913;hpb=0a75e19cdae3c9fa329cc8c18f8284419a62432b;p=cc1516.git diff --git a/sem.icl b/sem.icl index 68b804d..af49fdf 100644 --- a/sem.icl +++ b/sem.icl @@ -26,7 +26,6 @@ from Text import class Text(concat), instance Text String import AST - :: Scheme = Forall [TVar] Type :: Gamma :== 'Map'.Map String Scheme //map from Variables! to types :: Typing a :== StateT (Gamma, [TVar]) (Either SemError) a @@ -173,6 +172,7 @@ generalize :: Type -> Typing Scheme generalize t = gamma >>= \g-> pure $ Forall (difference (ftv t) (ftv g)) t lookup :: String -> Typing Type +lookup "isEmpty" = ListType <$> fresh lookup k = gamma >>= \g-> case 'Map'.member k g of False = liftT (Left $ UndeclaredVariableError zero k) True = instantiate $ 'Map'.find k g @@ -278,7 +278,7 @@ instance infer Stmt where changeGamma (extend k (Forall [] given)) >>| //todo: fieldselectors pure (s, VoidType) - FunStmt f es = undef //what is this? + FunStmt f es = pure (zero, VoidType) ReturnStmt Nothing = pure (zero, VoidType) ReturnStmt (Just e) = infer e