[GHC] #15627: Absent unlifted bindings

GHC ghc-devs at haskell.org
Wed Sep 12 14:27:29 UTC 2018


#15627: Absent unlifted bindings
-------------------------------------+-------------------------------------
        Reporter:  sgraf             |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:  ⊥
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #9279 #4328       |  Differential Rev(s):
  #11126                             |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by sgraf):

 We need the `Eq` instance of `Literal` when deriving `Eq AltCon`. That's
 OK, we have `eqType` for that. However, there's also an instance `Ord
 AltCon` that is a little shady (sic):

 {{{
 -- This instance is a bit shady. It can only be used to compare AltCons
 for
 -- a single type constructor. Fortunately, it seems quite unlikely that
 we'll
 -- ever need to compare AltCons for different type constructors.
 -- The instance adheres to the order described in [CoreSyn case
 invariants]
 instance Ord AltCon where
   compare (DataAlt con1) (DataAlt con2) =
     ASSERT( dataConTyCon con1 == dataConTyCon con2 )
     compare (dataConTag con1) (dataConTag con2)
   compare (DataAlt _) _ = GT
   compare _ (DataAlt _) = LT
   compare (LitAlt l1) (LitAlt l2) = compare l1 l2
   compare (LitAlt _) DEFAULT = GT
   compare DEFAULT DEFAULT = EQ
   compare DEFAULT _ = LT
 }}}

 I will not try and remove that instance, I think it's probably needed
 somewhere. Questions:

 1. How would I implement `cmpType`, which I'd need for a faithful `cmpLit`
 function?
 2. In the likely case the answer to 1) is "don't", then does sound
 ignoring the `MachNull` type in comparisons OK? E.g. `cmpType (MachNull _)
 (MachNull_) = EQ`. Makes `Ord AltCon` a little more shady than it already
 is, but still seems in line with the invariant "only use on AltCons of
 same type constructor". Also, `cmpType` and `eqType` might then disagree.

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


More information about the ghc-tickets mailing list