Opened 21 months ago

Last modified 6 weeks 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:

Description (last modified by bgamari)

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 (5)

comment:1 Changed 21 months ago by cactus

  • Type changed from bug to feature request

comment:2 Changed 10 months ago by cactus

  • Cc cactus added
  • Keywords pattern synonyms added

comment:3 Changed 9 months ago by cactus

  • Keywords PatternSynonyms added; pattern synonyms removed

comment:4 Changed 6 weeks ago by bgamari

  • Description modified (diff)

comment:5 Changed 6 weeks ago by bgamari

  • Description modified (diff)
Note: See TracTickets for help on using tickets.