[GHC] #12862: Operator (!) causes weird pretty printing and parsing

GHC ghc-devs at haskell.org
Mon Nov 21 11:51:19 UTC 2016


#12862: Operator (!) causes weird pretty printing and parsing
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Parser)                           |
           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:
-------------------------------------+-------------------------------------
 {{{#!hs
 class Key key where
   data TotalMap key :: Type -> Type
   (!) :: TotalMap key val -> (key -> val)

 instance Key Bool where
   data TotalMap Bool val = BoolMap val val
   (!) :: TotalMap Bool val -> (Bool -> val)
   (BoolMap f _) ! False = f
 }}}

 puts unnecessary parentheses around the wildcard pattern:

 {{{
 tf6t.hs:14:3-23: error: …
     Parse error in pattern: (BoolMap f (_))
 Compilation failed.
 }}}

 and with no parentheses

 {{{#!hs
   BoolMap f _ ! False = f
 }}}

 it talks about missing method, pattern bindings and doesn't list a space
 between `!` and `False`:

 {{{
 tf6t.hs:13:3-5: error: …
     The class method signature for ‘!’ lacks an accompanying binding
       (The class method signature must be given where ‘!’ is declared)
 tf6t.hs:14:3-25: error: …
     Pattern bindings (except simple variables) not allowed in instance
 declaration:
       BoolMap f _ !False = f
 Compilation failed.
 }}}

 All of these issues go away if the operator is called something other than
 `!`, it works if written prefix

 {{{#!hs
   (!) (BoolMap f _) False = f
 }}}

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


More information about the ghc-tickets mailing list