checkStmt VoidType r=:(ReturnStmt Nothing) = pure r
checkStmt t r=:(ReturnStmt (Just e)) = unify t e >>| pure r
checkStmt VoidType r=:(ReturnStmt Nothing) = pure r
checkStmt t r=:(ReturnStmt (Just e)) = unify t e >>| pure r
typeExpr :: Expr -> Env Type
typeExpr (IntExpr _ _) = pure IntType
typeExpr (CharExpr _ _) = pure CharType
typeExpr :: Expr -> Env Type
typeExpr (IntExpr _ _) = pure IntType
typeExpr (CharExpr _ _) = pure CharType
buildFunctionType frsh [e:es] = (->>) <$> typeExpr e <*> buildFunctionType frsh es
unifyApp :: Type [Expr] -> Env Type
buildFunctionType frsh [e:es] = (->>) <$> typeExpr e <*> buildFunctionType frsh es
unifyApp :: Type [Expr] -> Env Type
unifyApp (tf1 ->> tf2) [t1:ts] = unify tf1 t1 >>| unifyApp tf2 ts
unifyApp t1 t2 = liftT $ Left $ UnifyError zero t1 (IdType "[expressions, FIXME]")
unifyApp (tf1 ->> tf2) [t1:ts] = unify tf1 t1 >>| unifyApp tf2 ts
unifyApp t1 t2 = liftT $ Left $ UnifyError zero t1 (IdType "[expressions, FIXME]")