[GHC] #10056: Inconsistent precedence of ~

GHC ghc-devs at haskell.org
Mon Jul 30 10:50:24 UTC 2018


#10056: Inconsistent precedence of ~
-------------------------------------+-------------------------------------
        Reporter:  crockeea          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.8.4
  (Parser)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10059, #10431,   |  Differential Rev(s):  Phab:D4876
  #14316                             |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 When talking about `(~)`, it's important to distinguish between two
 different uses of it:

 1. As the equality type operator.
 2. As a laziness annotation in `-XStrict` (e.g., `data Foo a = MkFoo ~a`).

 If it weren't for usage (2), `(~)` would not need any special treatment at
 all in the parser. But alas, because of (2), we initially parse all uses
 of `(~)` as laziness annotations, and perform an additional pass right
 after parsing to determine which uses of `(~)` are for actually for (1),
 and which are for actually for (2).

 (Note that the problems I describe about `(->)` in comment:38 would still
 be relevant even if `(~)` had no special treatment in the parser. In other
 words, if we decided in the future to have some other type operator with a
 precedence of -2 or lower, than we'd have to figure out how to answer The
 `(->)` Question.)

 Once that's taken care of, the fixity of `(~)` is handled like any other
 type operator. I only opted to wire in the fixity of `(~)` in comment:38
 since it's negative, and you can't assign a negative fixity through an
 `infix -2 ~` declaration.

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


More information about the ghc-tickets mailing list