Error message points to wrong location
This rightly fails, but I have an issue with the error message. I think points to the visible type application eagerly.. rather than the type annotation (f_xx :: ())
.
{-# Language RankNTypes, PolyKinds, GADTs, TypeApplications, ScopedTypeVariables #-}
import Data.Kind
newtype Limit :: (k -> Type) -> Type where
Limit :: (forall xx. f xx) -> Limit f
foo :: forall f a. Limit f -> f a
foo (Limit (f_xx :: ())) = f_xx @a
gives
$ ghci -ignore-dot-ghci /tmp/Test.hs
GHCi, version 8.5.20180105: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( /tmp/Test.hs, interpreted )
/tmp/Test.hs:9:28: error:
• Cannot apply expression of type ‘()’
to a visible type argument ‘a’
• In the expression: f_xx @a
In an equation for ‘foo’: foo (Limit (f_xx :: ())) = f_xx @a
|
9 | foo (Limit (f_xx :: ())) = f_xx @a
| ^^^^^^^
Failed, no modules loaded.
Prelude>
I would have expected:
/tmp/Test.hs:9:13: error:
• Couldn't match expected type ‘()’ with actual type ‘f xx0’
• When checking that the pattern signature: ()
fits the type of its context: forall (xx :: k1). f xx
In the pattern: f_xx :: ()
In the pattern: Limit (f_xx :: ())
• Relevant bindings include
foo :: Limit f -> f a (bound at /tmp/Test.hs:9:1)
Thoughts
Trac metadata
Trac field | Value |
---|---|
Version | 8.5 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |