Skip to content

Document how to write a pattern synonym that uses a view pattern

It took me a bit to figure out how to apply a function to the expression that I want to pattern match on – turns out you can use ViewPatterns, as for example containers' Seq does:

pattern (:<|) :: a -> Seq a -> Seq a
pattern x :<| xs <- (viewl -> x :< xs)
  where
    x :<| xs = x <| xs

I think this should be documented in the user's guide.

Edited by Simon Jakobi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information