GHC is too hesitant to say a function is applied to too few arguments.
Given a function f :: T1 -> T2 -> T3 -> T4
and an expression f y z
with types y :: T2
z :: T3
it's very obvious that the function has been underapplied.
Currently this results in a vaguely useful onslaught of errors. E.g. for this code:
foo :: Int -> Char -> Bool -> String
foo x y z = "bla"
bar :: String
bar = foo 'c' True
We get:
Test.hs:18:7: error: [GHC-83865]
• Couldn't match type: Bool -> String
with: [Char]
Expected: String
Actual: Bool -> String
• Probable cause: ‘foo’ is applied to too few arguments
In the expression: foo 'c' True
In an equation for ‘bar’: bar = foo 'c' True
|
18 | bar = foo 'c' True
| ^^^^^^^^^^^^
Test.hs:18:11: error: [GHC-83865]
• Couldn't match expected type ‘Int’ with actual type ‘Char’
• In the first argument of ‘foo’, namely ‘'c'’
In the expression: foo 'c' True
In an equation for ‘bar’: bar = foo 'c' True
|
18 | bar = foo 'c' True
| ^^^
Test.hs:18:15: error: [GHC-83865]
• Couldn't match expected type ‘Char’ with actual type ‘Bool’
• In the second argument of ‘foo’, namely ‘True’
In the expression: foo 'c' True
In an equation for ‘bar’: bar = foo 'c' True
|
18 | bar = foo 'c' True
| ^^^^
But ideally we would want GHC to be smarter than that and say something like:
Test.hs:18:7: error: [GHC-83865]
• Function `bar` is applied to too few arguments.
Expected: Int -> Char -> Bool
Actual: Char -> Bool
* Probably cause: Missing argument of type `Int`
In the expression: foo 'c' True
In an equation for ‘bar’: bar = foo 'c' True
|
18 | bar = foo 'c' True
| ^^^^^^^^^^^^
No idea how feasible this is in the type checker. But for the common case of "I forgot one argument" that sounds doable.
"Simply" check if the types line up of we were to insert the expected type at the first missmatched argument position. But then I have not worked on the code that makes this happen so I might be wrong and it's harder than expected.