mapM (checkStmt tres) stmts >>= \newstmts->
case mt of
Nothing = inferReturnType stmts
- >>= \returntype->reconstructType args returntype
- >>= \ftype->restoreGamma gamma
+ >>= \returntype->reconstructType args tres
+ >>= \ftype->pure Void//restoreGamma gamma
>>| putIdent f ftype >>| pure (
- FunDecl p f args (Just ftype) newvds newstmts)
+ FunDecl p f args (Just ftype) newvds newstmts)
Just t = restoreGamma gamma
>>| pure (FunDecl p f args mt newvds newstmts)
unify (ListType t1) (ListType t2) = unify t1 t2 >>| (pure $ ListType t1)
unify (ta1 ->> ta2) (tb1 ->> tb2) = unify ta1 tb1 >>= \ta-> unify ta2 tb2
>>= \tb-> pure (ta ->> tb)
+ unify VoidType VoidType = pure VoidType
unify t1 t2 = liftT $ Left $ UnifyError zero t1 t2
instance zero Pos where