[GHC] #5144: Pattern synonyms
GHC
ghc-devs at haskell.org
Tue Aug 13 17:38:17 CEST 2013
#5144: Pattern synonyms
-------------------------------------+------------------------------------
Reporter: simonpj | Owner: cactus
Type: feature request | Status: new
Priority: normal | Milestone: _|_
Component: Compiler | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by cactus):
I've implemented infix notation as well, so now you can write this:
{{{
{-# LANGUAGE ViewPatterns, PatternSynonyms #-}
import qualified Data.Sequence as Seq
pattern Empty = (Seq.viewl -> Seq.EmptyL)
pattern x :< xs = (Seq.viewl -> x Seq.:< xs)
pattern xs :> x = (Seq.viewr -> xs Seq.:> x)
zipZag :: Seq.Seq a -> Seq.Seq b -> Seq.Seq (a, b)
zipZag (x :< xs) (ys :> y) = (x, y) Seq.<| zipZag xs ys
zipZag _ _ = Seq.empty
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5144#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list