Improving containers library

Axel Simon Axel.Simon at
Wed Mar 3 12:58:35 EST 2010

On 03.03.2010, at 17:30, Milan Straka wrote:

> Any easy way of comparing pointers? I mean, if I have something like
> Tree a = N | B (Tree a) a (Tree a)
> and have (l::Tree a) and (r::Tree a), can I ask about the "physical
> equality"?

You can! Despite the names appearing in the following code, the  
following is safe:

-- | Equality on pointers.
ptrEqual :: a -> a -> Bool
ptrEqual x y = unsafePerformIO $ do
   nx <- makeStableName x
   ny <- makeStableName y
   return (nx==ny)


More information about the Libraries mailing list