[GHC] #12001: RFC: Add pattern synonyms to base

GHC ghc-devs at haskell.org
Mon May 2 23:28:57 UTC 2016


#12001: RFC: Add pattern synonyms to base
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  libraries/base    |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 Since `Polar` was the pick of the litter, it's worth mentioning that with
 record syntax:

 {{{#!hs
 pattern Polar :: RealFloat a => a -> a -> Complex a
 pattern Polar {m, theta} <- (polar -> (m, theta))
   where Polar m theta = mkPolar m theta
 }}}

 we can write

 {{{
 ghci> (3 :+ 1) { m = 2 }
 1.8973665961010275 :+ 0.6324555320336759
 ghci>
 ghci> set (_polar._1) 2 (3 :+ 1)
 1.8973665961010275 :+ 0.6324555320336759
 }}}

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


More information about the ghc-tickets mailing list