[Haskell-cafe] How to check object's identity?

Peter Verswyvelen bugfact at gmail.com
Sun Jan 4 18:37:49 EST 2009

Maybe you could use stable names for this:


"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

2009/1/3 Xie Hanjian <jan.h.xie at gmail.com>:
> Hi,
> I tried this in ghci:
>>Prelude> 1:2:[] == 1:2:[]
> True
> Does this mean (:) return the same object on same input, or
> (==) is not for identity checking? If the later is true, how
> can I check two object is the *same* object?
> Thanks
> Jan
> --
> jan=callcc{|jan|jan};jan.call(jan)
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list