[Haskell-cafe] Does GHC compare pointers when eval'ing (==)

Erik Hesselink hesselink at gmail.com
Wed Aug 20 08:23:13 UTC 2014


As I understood, the question was if GHC would first compare pointers,
and only call the Eq instance if the pointers are not equal. I guess
this would be safe, but I don't think GHC does such a thing.

Erik

On Wed, Aug 20, 2014 at 9:09 AM, Alois Cochard <alois.cochard at gmail.com> wrote:
> Hi Johan,
>
> Haskell does not support referential equality, as that would break
> referential transparency.
>
> http://stackoverflow.com/questions/1717553/pointer-equality-in-haskell
>
> Cheers
>
> On Aug 20, 2014 7:52 AM, "Johan Holmquist" <holmisen at gmail.com> wrote:
>>
>> Comparing two structures for equality (structurally) can be expensive. But
>> if their references are the same they would for sure be equal (unless (==)
>> was defined in some funny way). Does GHC perform any such optimization?
>>
>> (Likely a question for another list but I make a stab here first. )
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>
> _______________________________________________
> 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