[GHC] #13454: Operators not allowed as fields in Record Pattern Synonyms

GHC ghc-devs at haskell.org
Sun Mar 19 12:53:12 UTC 2017


#13454: Operators not allowed as fields in Record Pattern Synonyms
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
  PatternSynonyms                    |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I want to write the following record pattern synonym

 {{{#!hs
 pattern MkOp :: Op -> Exp -> Exp -> Exp
 pattern MkOp {(·), a, b} <- (splitOp -> Just ((·), a, b))
   where MkOp (·) a b      = a · b
 }}}

 given this code

 {{{#!hs
 data Exp = Val Int | Add Exp Exp | Mul Exp Exp deriving Show

 type Op = Exp -> Exp -> Exp

 splitOp :: Exp -> Maybe (Op, Exp, Exp)
 splitOp (Add a b) = Just (Add, a, b)
 splitOp (Mul a b) = Just (Mul, a, b)
 splitOp _         = Nothing
 }}}

 It works fine if `(·)` is replaced by `operator`. Fields of regular data
 types works just fine:

 {{{#!hs
 data F a = F {
   (·) :: a -> a -> a,
   x   :: a,
   y   :: a
 }

 f F{(·), x, y} = x·y
 g F{..}        = x·y
 }}}

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


More information about the ghc-tickets mailing list