Associated pattern synonyms
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