Error message: f is applied to two arguments, but its type has only two (sic)
I occasionally get type errors where the error message refers to a function’s arity in a contradictory way:
The function ‘X’ is applied to two arguments, […] but its type has only two.
Here’s a full error message of this kind:
lenstest.hs:89:12:
Couldn't match type ‘Either String Int’ with ‘Maybe b0’
Expected type: [Char] -> Either String Int
Actual type: [Char] -> Maybe b0
The function ‘preview’ is applied to two arguments,
but its type ‘Getting (Data.Monoid.First b0) (Either b0 c0) b0
-> [Char] -> Maybe b0’
has only two
In the second argument of ‘($)’, namely
| ‘(preview _Left "abc" | Either String Int)’ |
|---|---|
| In a stmt of a 'do' block: | |
| print $ (preview _Left "abc" | Either String Int) |
Failed, modules loaded: none.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler (Type checker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |