[Haskell-cafe] Spurious pattern match warnings with GADTs
Tom Hawkins
tomahawkins at gmail.com
Thu Jan 12 21:40:25 CET 2012
Let's say I have:
data T0
data T1
data T a where
A :: T T0
B :: T T1
Then I can write the following without getting any non-exhaustive
pattern match warnings:
t :: T T0 -> String
t a = case a of
A -> "A"
However, if I use type classes to constrain the constructors, instead
of using the phantom types directly:
class C0 a
instance C0 T0
class C1 a
instance C1 T1
data T a where
A :: C0 a => T a
B :: C1 a => T a
Then I get a non-exhaustive pattern match warning on 't'. How come?
(I'm using GHC 7.0.4)
It appears that the intelligent pattern analysis of the first example
is a relatively recent addition [1].
-Tom
[1] http://hackage.haskell.org/trac/ghc/ticket/3476
More information about the Haskell-Cafe
mailing list