[GHC] #14100: Nested NPlusKPatterns

GHC ghc-devs at haskell.org
Tue Aug 8 09:10:23 UTC 2017


#14100: Nested NPlusKPatterns
-------------------------------------+-------------------------------------
        Reporter:  ralf              |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      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):

 You format Haskell code using

 {{{
 {{{#!hs
 ... code
 }}}
 }}}

 ----

 {{{#!hs
 {-# LANGUAGE NPlusKPatterns #-}
 {-# LANGUAGE ViewPatterns, PatternSynonyms #-}

 infix 1 ::

 data Bush elem = Nil | Bud elem | Bush elem :: Bush elem

 test ((n + 1) + 1) = n

 pattern DivMod2 ∷ (Integral nat) ⇒ nat → nat → nat
 pattern DivMod2 n k ← ((divMod 2) → (n, k)) where DivMod2 n k = 2 * n + k

 braun ∷ Integer → Bush ()
 braun (0)               = Nil
 braun (1)               = Bud ()
 braun (DivMod2 n k + 2) = braun (n + k + 1) :: braun (n + 1)
 }}}

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


More information about the ghc-tickets mailing list