Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#522 Incomplete pattern warnings with GADTs

open
nobody
None
5
2005-09-23
2005-09-23
Bjorn Bringert
No

{-
With GADTs, -fwarn-incomplete-patterns complains
about missing
impossible cases.
-}

{-# OPTIONS_GHC -fglasgow-exts
-fwarn-incomplete-patterns #-}

data Var = Var
data Typ = Typ

data Tree a where
V :: String -> Tree Var
T_int :: Tree Typ

getId :: Tree Var -> String
getId (V x) = x
--getId T_int = "T_int"

{-

With the last line commented out:

gadt-pattern-warning.hs:11:0:
Warning: Pattern match(es) are non-exhaustive
In the definition of `getId': Patterns not
matched: T_int
Ok, modules loaded: Main.

With the last line not commented out:
gadt-pattern-warning.hs:12:6:
Inaccessible case alternative: Can't match types
`Typ' and `Var'
When checking the pattern: T_int
In the definition of `getId': getId T_int = "T_int"
Failed, modules loaded: none.

-}

Discussion