Skip to content

Pattern Synonyms in Typeclasses

data A t where
   AX :: A X
   AY :: A Y
   AZ :: A Z

class HasX a where
     data pattern X :: a X

instance HasX A where
    data pattern X = AX

d :: A t -> String
d = \case
    X  -> ""
    AY -> ""
    AZ -> "" 

The above example should compile and emit no warnings with -fwarn-incomplete-patterns. Would require #8779 (closed)

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
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