[GHC] #913: instance Ord (StableName a)

GHC ghc-devs at haskell.org
Tue May 15 23:33:31 UTC 2018


#913: instance Ord (StableName a)
-------------------------------------+-------------------------------------
        Reporter:  ekarttun          |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  6.10 branch
       Component:  libraries/base    |              Version:  6.4.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by andrewthad):

 I agree with your concern that an Ord instance limits future possibilities
 to modify the implementation.  I disagree with the concern about
 soundness.  As you point out, using  hashStableName to implement an Ord
 instance is unsound.  We do not use it in the Eq instance,  and it would
 be every bit as unsound in an Ord instance.  The path forward to
 implementing an Ord instance would be to introduce a new primop  for
 comparing StableName#.  It would basically be the same thing as
 eqStableName#.  After all, eqStableName#  is basically ( in the current
 implementation)  two calls to stableNameToInt#  with the guarantee that
 garbage collection cannot happen between them.  And this guarantee that
 garbage collection  doesn’t happen between the two calls  is exactly what
 you make the implementation you discuss above sound.

  But yes, it does constrain the possible available implementations. I
 certainly agree with that.

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


More information about the ghc-tickets mailing list