Op2Expr p e1 op e2 =
infer e1 >>= \(s1, t1, e1_) ->
+ applySubst s1 >>|
infer e2 >>= \(s2, t2, e2_) ->
+ applySubst s2 >>|
fresh >>= \tv ->
let given = t1 ->> t2 ->> tv in
op2Type op >>= \expected ->
) >>= \newF->
fresh >>= \tv->case expected of
FuncType t = pure (s1, t, (FunExpr p newF args fs))
+ //TODO: Fieldselectors!
_ = (let given = foldr (->>) tv argTs in
lift (unify expected given) >>= \s2->
let fReturnType = subst s2 tv in
pure (compose s2 s1, VoidType, FunStmt newF args_ fs)
ReturnStmt Nothing = pure (zero, VoidType, s)
+ //hier ook sub applyen
ReturnStmt (Just e) = infer e >>= \(sub, t, e_)-> pure (sub, t, ReturnStmt (Just e_))
reverseFs :: Type FieldSelector -> Typing Type