[GHC] #14100: Nested NPlusKPatterns

GHC ghc-devs at haskell.org
Tue Aug 8 07:56:20 UTC 2017


#14100: Nested NPlusKPatterns
-------------------------------------+-------------------------------------
           Reporter:  ralf           |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Nested patterns involving NPlusKPatterns cause a "parse error in pattern".
 Example appended below.

 > {-# 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>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list