Opened 8 years ago

Closed 6 years ago

Last modified 4 years ago

#913 closed feature request (wontfix)

instance Ord (StableName a)

Reported by: ekarttun Owned by:
Priority: normal Milestone: 6.10 branch
Component: libraries/base Version: 6.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Being able to have an Ord instance for StableNames? would make sense. This would be very useful for code passing around a Set of StableNames?. As the Eq instance already exists this would probably not involve any new issues.

Change History (7)

comment:1 Changed 8 years ago by simonmar

  • Milestone set to 6.8

I think this is possible. hashStableName says that it doesn't guarantee to be unique, but I think that's only because StableName? identifiers can be reused. There is a danger that one of the SNs might get GC'd just after we call stableNameToInt# on it and the identity could be reused by newStableName in another thread, but the original comparison would still be valid. Conclusion: just call stableNameToInt# on the two stable names and compare the Int#s.

comment:2 Changed 8 years ago by simonmar

From Jan-Willem Maessen:

I feel like I may have already run into this problem with the Eq
instance of stableNames. But I was never able to verify for sure
that this was going on, and it's rather hard to guarantee that the
object referred to by the stable name actually outlives the Int# (if
we stick to Haskell code alone).

If I ever get a reproducible bug whose symptoms I understand, I'll
let you know. :-) But just to make sure you are aware that this
could actually be causing trouble in practice.

comment:3 Changed 6 years ago by simonmar

  • Milestone changed from 6.8 branch to 6.10 branch

comment:4 Changed 6 years ago by igloo

  • Resolution set to wontfix
  • Status changed from new to closed

Please follow the library submissions process for this:
http://www.haskell.org/haskellwiki/Library_submissions

comment:5 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:7 Changed 4 years ago by simonmar

  • Difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.