import AST
-
:: Scheme = Forall [TVar] Type
:: Gamma :== 'Map'.Map String Scheme //map from Variables! to types
:: Typing a :== StateT (Gamma, [TVar]) (Either SemError) a
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
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