[Haskell-cafe] I love purity, but it's killing me.
Bertram Felgenhauer
bertram.felgenhauer at googlemail.com
Sat Feb 9 09:34:34 EST 2008
Matthew Naylor wrote:
[snip]
> Finally, when I say "observable sharing", I don't necessarily mean it
> as defined by Koen Claessen and David Sands. I simply mean the use of
> unsafePerformIO to detect sharing, whether or not this is done by an
> "eq" predicate on Refs. (I say this because I think there are simpler
> ways to detect sharing, though these will probably not have the nice
> semantic properties of observable sharing.)
ghc actually provides a primop for this:
reallyUnsafePtrEquality# :: a -> a -> Int#
Use at your own risk.
Note that you can only check for equality uing that primop. To detect
cycles in data structures efficiently, a total order would be better,
but in the presence of copying garbage collection that's asking too
much.
Bertram
More information about the Haskell-Cafe
mailing list