Uniquable RdrName instance
Simon Peyton Jones
simonpj at microsoft.com
Tue Jun 17 16:00:17 UTC 2014
We just haven't needed one so far.
Can a RdrName and a Name have the same Unique? Well, of course that just depends on what you are using the RdrName Uniques for. It's not a question that has a yes or no answer.
Does it matter if (Orig m x) and (Orig n x) have the same Unique? Same answer, except that I bet the answer is "yes it matters".
FWIW the "OrigNameCache" is a finite map keyed by (ModuleName,Orig) pairs.
Simon
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Jan
| Stolarek
| Sent: 16 June 2014 12:45
| To: ghc-devs at haskell.org
| Subject: Uniquable RdrName instance
|
| Hi all,
|
| I just found myself in the need of Uniquable instance for RdrName. I'm
| surprised that such instance does not exist already because other
| datatypes like Name or OccName already have Uniquable instances. So, is
| there a reason why Uniquable instance for RdrName does not exist already
| (other than "it wasn't needed")? How should such an instance look like?
| I made an
| attempt:
|
| rdrNameUnique :: RdrName -> Unique
| rdrNameUnique (Unqual occName) = getUnique occName rdrNameUnique (Qual _
| occName) = getUnique occName rdrNameUnique (Orig _ occName) = getUnique
| occName
| rdrNameUnique (Exact name ) = getUnique name
|
| But I suspect this might be wrong:
| - cases 1 and 4 simply return a Unique for the OccName/Name stored
| inside RdrName. I think this will assign the same Unique to RdrName and
| corresponding OccName/Name. Is this allowed?
| - cases 2 and 3 ignore the Module stored inside RdrName. Again, this
| assigns the RdrName with a Unique identical to OccNames stored inside
| it.
|
| Help appreciated.
|
| Janek
| _______________________________________________
| ghc-devs mailing list
| ghc-devs at haskell.org
| http://www.haskell.org/mailman/listinfo/ghc-devs
More information about the ghc-devs
mailing list