Opened 19 months ago

Last modified 7 months ago

#8583 new feature request

Associated pattern synonyms

Reported by: cactus Owned by:
Priority: normal Milestone:
Component: Compiler Version:
Keywords: PatternSynonyms Cc: cactus
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: #5144 Blocking:
Related Tickets: Differential Revisions:


The PatternSynonyms wiki page has a section on (typeclass-)associated pattern synonyms:

class ListLike l where
      pattern Nil :: l a
      pattern Cons :: a -> l a -> a
      isNil :: l a -> Bool
      isNil Nil = True
      isNil (Cons _ _) = False
      append :: l a -> l a -> l a

   instance ListLike [] where
      pattern Nil = []
      pattern Cons x xs = x:xs
      append = (++)

   headOf :: (ListLike l) => l a -> Maybe a
   headOf Nil = Nothing
   headOf (Cons x _) = Just x

Change History (3)

comment:1 Changed 19 months ago by cactus

  • Type changed from bug to feature request

comment:2 Changed 8 months ago by cactus

  • Cc cactus added
  • Keywords pattern synonyms added

comment:3 Changed 7 months ago by cactus

  • Keywords PatternSynonyms added; pattern synonyms removed
Note: See TracTickets for help on using tickets.