2009/1/26 Alberto G. Corona <[email protected]>

> Sometimes the StableName library gives different values for the samr
> function:
>

First, unsafePerformIO is not subject to referential transparency.  You have
to ensure it yourself.  That's why it's unsafe.

Now, did you read the StableName documentation?  From the docs:

Stable names have the following property:  if sn1 :: StableName and sn2 ::
> StableName and sn1 == sn2 then sn1 and sn2 were created by calls to
> makeStableName on the same object.  The reverse is not necessarily true: if
> two stable names are not equal, then the objects they name may still be
> equal.


So the behavior you cite is perfectly reasonable: does not break referential
transparency (unsafePerformIO is the culprit here), and is consistent with
the documentation.

Luke

Sometines gives two alternate values. I checked it in ghc-6.10.1 under
> windows and in ghc-6.8.2 under Linux:
>
> This is an example
>
> Prelude>
> System.Mem.StableName.hashStableName.System.IO.Unsafe.unsafePerformIO $
>  System.Mem.StableName.makeStableName (*)
> 15
> Prelude>
> System.Mem.StableName.hashStableName.System.IO.Unsafe.unsafePerformIO $
>  System.Mem.StableName.makeStableName (*)
> 14
> Prelude>
> System.Mem.StableName.hashStableName.System.IO.Unsafe.unsafePerformIO $
>  System.Mem.StableName.makeStableName (*)
> 15
> Prelude>
> System.Mem.StableName.hashStableName.System.IO.Unsafe.unsafePerformIO $
>  System.Mem.StableName.makeStableName (*)
> 14
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to