When a type application cannot be applied to an identifier due to the absence of an explicit type signature, let the error just say so!
Consider this code:
{-# language TypeApplications #-}
module TypeApplicationsErrorMessage where
f = (+)
g = f @Integer
This is what happens when I try to compile it:
% ghc TypeApplicationsErrorMessage.hs
[1 of 1] Compiling TypeApplicationsErrorMessage ( TypeApplicationsErrorMessage.hs, TypeApplicationsErrorMessage.o )
TypeApplicationsErrorMessage.hs:6:5: error:
• Cannot apply expression of type ‘a0 -> a0 -> a0’
to a visible type argument ‘Integer’
• In the expression: f @Integer
In an equation for ‘g’: g = f @Integer
|
6 | g = f @Integer
| ^^^^^^^^^^
This error is easily fixed by supplying an explicit type signature to f. So, perhaps the error message could just say so?
I am observing this with The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180810.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |