Skip to content

Non-exhaustive pattern match warning with DataKinds and TypeFamilies

The code is:

data K = Foo
       | Bar

data D1 :: K -> * where
    F1 :: D1 Foo
    B1 :: D1 Bar

class C (a :: K -> *) where
    data D2 a :: K -> *
    foo :: a k -> D2 a k -> Bool

instance C D1 where
    data D2 D1 k where
              F2 :: D2 D1 Foo
              B2 :: D2 D1 Bar
    foo F1 F2 = True
    foo B1 B2 = True

With -Wall it gives the warning:

Test.hs:23:5: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for `foo':
        Patterns not matched:
            F1 B2
            B1 F2
Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information