- fresh >>= \tv->
- let given = foldr (->>) tv argTs in
- lift (unify expected given) >>= \s2->
- let fReturnType = subst s2 tv in
- foldM foldFieldSelectors fReturnType fs >>= \returnType ->
- (case f of
- "print" = case head argTs of
- IntType = pure "1printint"
- CharType = pure "1printchar"
- BoolType = pure "1printbool"
- ListType (CharType) = pure "1printstr"
- t = liftT $ Left $ SanityError p ("can not print " +++ toString t)
- _ = pure f) >>= \newF->
- pure (compose s2 s1, returnType, FunExpr p newF args_ fs)
+ fresh >>= \tv->case expected of
+ FuncType t = pure (s1, t, e)
+ _ = (let given = foldr (->>) tv argTs in
+ lift (unify expected given) >>= \s2->
+ let fReturnType = subst s2 tv in
+ foldM foldFieldSelectors fReturnType fs >>= \returnType ->
+ (case f of
+ "print" = case head argTs of
+ IntType = pure "1printint"
+ CharType = pure "1printchar"
+ BoolType = pure "1printbool"
+ ListType (CharType) = pure "1printstr"
+ t = liftT $ Left $ SanityError p ("can not print " +++ toString t)
+ _ = pure f) >>= \newF->
+ pure (compose s2 s1, returnType, FunExpr p newF args_ fs))