[GHC] #5144: Pattern synonyms

GHC ghc-devs at haskell.org
Sun Sep 22 11:00:12 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):

 Based on discussions with SPJ, I've updated the PatternSynonyms proposal
 and redesigned the implementation to postpone the instantiation of pattern
 synonyms until the desugarer. See the updated implementation at
 https://github.com/gergoerdi/ghc/tree/pattern-synonyms

 Basically, the old implementation was pretty much unsalvageable for
 patterns mentioning non-Haskell98 data constructors. The new one works
 nicely with unconstrained and constrained existential types.

 On the features front, I've added explicit syntax for unidirectional vs.
 bidirectional patterns. The tentative syntax is:

 {{{
 pattern Head x -> (x:_) -- pattern-only synonym
 pattern Single x = [x] -- bidirectional synonym
 }}}

 So now you can rewrite the second one as

 {{{
 pattern Single x -> [x]
 }}}

 and it will not introduce a new virtual constructor to be used in
 expressions.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5144#comment:33>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list