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

Edward Kmett ekmett at gmail.com
Wed Aug 20 15:48:26 UTC 2014


I wanted this too when I first got into Haskell, but ultimately it comes
down to not being semantically correct here.

NaN /= NaN, so referential equality of anything that might ever compare
inside two NaN's doesn't imply value equality.

e.g. Anything with a polymorphic field can't use this.

You can argue that that was a bad call, but it was the expected call under
IEEE semantics.

If you wanted to bubble up some kind of extra 'reflexive :: a -> Bool'
through the Eq instance, then the tricky part is that determining if you
can use this can be as bad as doing the full tree comparison for
pathological cases you can construct and can introduce bottoms where there
previously were none if you do it naively.

You also start getting weird cases where things turn into Heisenbugs. this
== that would terminate before you evaluate this or that, but if you
evaluate one or the other then sometimes it works.

-Edward



On Wed, Aug 20, 2014 at 11:14 AM, Iustin Pop <iusty at k1024.org> wrote:

> On Wed, Aug 20, 2014 at 03:16:03PM +0200, Johan Holmquist wrote:
> > To summarise, the points raised sofar against this optimisation are,
> > roughly, as follows.
>
> I think a different aspect of this is: what are you trying to optimise?
> What code do you have where equality tests are a significant part of the
> workload?
>
> regards,
> iustin
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140820/85c7c668/attachment.html>


More information about the Haskell-Cafe mailing list