X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=sem.icl;h=2341eefdef0c6c5da997b89d1f151230976e999e;hb=e01254ee33ddd811fe95ea98cba19909f3e4f740;hp=68b804d42939c49739bb662f0688ccd527740913;hpb=0a75e19cdae3c9fa329cc8c18f8284419a62432b;p=cc1516.git diff --git a/sem.icl b/sem.icl index 68b804d..2341eef 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