pure (compose s1 s2, TupleType (t1,t2))
FunExpr _ f args fs = //todo: fieldselectors
- lookup f >>= \expected ->
- mapM infer args >>= \argTypes
+ lookup f >>= instantiate >>= \expected ->
+ let accTypSub = (\(s,ts) e->infer e >>= \(s_,et)->pure (compose s_ s,ts++[et])) in
+ foldM accTypSub (zero,[]) args >>= \(s1, argTs)->
+ fresh >>= \tv->
+ let given = foldr (->>) tv argTs in
+ lift (unify expected given) >>= \s2->
+ pure (compose s1 s2, subst s2 tv)
IntExpr _ _ = pure $ (zero, IntType)
BoolExpr _ _ = pure $ (zero, BoolType)