[Haskell-cafe] Suggestions for simulating Object ID

Jan Christiansen jac at informatik.uni-kiel.de
Tue Jun 30 14:18:49 EDT 2009


On 30.06.2009, at 11:55, Hemanth Kapila wrote:

> Can some one please suggest something on simulating some sort of  
> "object-Ids" in Haskell?
> I mean, something like the following relation will hold:
> > a1 == a2  =  (objectID a1) == (objectID a2)

I am not quite sure but perhaps Stable Names are also interesting for  

They only provide the following:

  mkStableName x == mkStableName y => x == y

"Stable names are a way of performing fast (O(1)), not-quite-exact  
comparison between objects.

Stable names solve the following problem: suppose you want to build a  
hash table with Haskell objects as keys, but you want to use pointer  
equality for comparison; maybe because the keys are large and hashing  
would be slow, or perhaps because the keys are infinite in size. We  
can't build a hash table using the address of the object as the key,  
because objects get moved around by the garbage collector, meaning a  
re-hash would be necessary after every garbage collection."

Cheers, Jan

More information about the Haskell-Cafe mailing list