Improving containers library

Bertram Felgenhauer bertram.felgenhauer at
Mon Mar 8 05:35:36 EST 2010

Axel Simon wrote:
> On 06.03.2010, at 18:19, Bertram Felgenhauer wrote:
> >ptrEqual' :: a -> a -> Bool
> >ptrEqual' x y = case reallyUnsafePtrEquality# x y of
> >   0# -> False
> >   1# -> True
> >
> >This is actually a pointer comparison. I believe it can produce false
> >negatives though, because indirections are not followed. If that's
> >correct, a false negative may be turned into a positive by garbage
> >collection. So use with care.
> Interesting. But if reallyUnsafePtrEquality# is a primitive, it is
> evaluated either before or after GC, so it can't compare a pointer
> from one generation with the next.

That is true. But besides GC, there is another source of indirections:
updating a thunk with its final value if it's too large, or with a
different thunk, which happens when an asynchronous exception is raised.



More information about the Libraries mailing list