GHC suggests that infix operators might have the wrong number of arguments
Summary
GHC sometimes suggests that you have passed the wrong number of arguments to an infix operator.
Steps to reproduce
Compile this code with GHC 8.6.5:
answer = map (foo ++ bar) "hello, world"
foo = toUpper
bar = take 10
The first error message says:
Test.hs:1:15: error:
• Couldn't match expected type ‘Char -> b’ with actual type ‘[a1]’
• Possible cause: ‘(++)’ is applied to too many arguments
In the first argument of ‘map’, namely ‘(foo ++ bar)’
In the expression: map (foo ++ bar) "hello, world"
In an equation for ‘answer’:
answer = map (foo ++ bar) "hello, world"
• Relevant bindings include answer :: [b] (bound at Test.hs:1:1)
The suggestion that I have applied (++) to too many arguments is not a very likely one, since infix operators must take two arguments just by their syntax alone. I suppose it's possible that I intended to write an operator section, but it seems like a stretch.
Expected behavior
I would expect this error message without the suggest that (++) is applied to too many arguments.
Environment
- GHC version used: 8.6.5