Can't scope type variables when pattern matching on GADTs
I was very surprised that the following doesn't compile:
{-# LANGUAGE GADTs, ScopedTypeVariables #-}
data Foo x where
A :: Foo Bool
B :: Foo Int
foo :: Foo x -> ()
foo (A :: Foo Bool) = ()
GHC says that it couldn't match the type y
with Bool
. See [this question](http://stackoverflow.com/questions/42824949/type-inference-with-gadts) for a simple motivating example. As someone there pointed out, the situation would be improved with type application (#11350 (closed)), but this ticket is about bringing the output type in scope with ScopedTypeVariables
.
This most closely reminds me of #1823 (closed) (!), but that was resolved many moons ago. This behavior also exists in 7.10.3.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |