Wrong argument count in error message with TypeApplications
When I write:
{-# language TypeApplications #-}
module Bug where
wrong = id @Bool True False
I get the error:
• Couldn't match expected type ‘Bool -> t’ with actual type ‘Bool’
• The function ‘id’ is applied to three arguments,
but its type ‘Bool -> Bool’ has only one
In the expression: id @Bool True False
In an equation for ‘bad’: bad = id @Bool True False
• Relevant bindings include bad :: t (bound at Bug.hs:8:1)
This seems to tell me that I ought to get rid of //two// of the arguments given to id
, when in fact I only ought to remove //one//. In particular, the issue seems to be that GHC includes visibly applied type parameters in the count of "how many arguments is it applied to?" but does not include them in the count of "how many arguments does it have?"
Suggested fix: in cases of this error with visible type application, report something akin to, "The function ‘id’ is applied to two type arguments and two value arguments, but its type has only one value argument."
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | goldfire |
Operating system | |
Architecture |