Produce type errors after looking at whole applications
Currently, the type error messages we produce in case of function applications are rather dumb, in particular if arguments were ommited, added, swapped or not parenthized correctly. (Examples in the first comment below.)
In many cases a procedure like the following would be better: For a given application f a1 a2 a3
, present the user with the (inferred) type of f
, as well as the (expected) type f
needs to have to be used with arguments a1 a2 a3
. This way, only one type error will be reported per function application, instead of many, and comparing these two reported types will allow the user to spot the problem more easily.
(With „one application“ I mean e1 e2 e3 … en
where e1
is not of that form.)
Furthermore, once we have these two types in our hands, we can look for common patterns, and give even more helpful error messages, such as suggesting to swap two arguments.
Clearly, there are many tricky corner cases (e.g. polymorphic functions, types with constraints or type classes, type applications etc.). But that should not stop us from trying better in obvious, monomorphic cases.