Strange interaction between TypeData and pattern-match coverage warnings
Given this program:
{-# LANGUAGE TypeData #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
module X where
type data T a where
A :: T Int
B :: T a
f :: T a -> ()
f x = case x of {}
GHC 9.6.1-alpha2 will produce the following warning when compiling it:
$ ghc-9.6 Bug.hs
[1 of 1] Compiling X ( Bug.hs, Bug.o )
Bug.hs:10:7: warning: [GHC-62161] [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative:
Patterns of type ‘T a’ not matched:
A
B
|
10 | f x = case x of {}
| ^^^^^^^^^^^^
But this really ought to be marked as exhaustive instead. After all, type data
data constructors don't exist at the value level, so there is no way to actually match on them. For the purposes of pattern-match coverage checking, a type data
declaration should be treated like an empty data type.