[Haskell-cafe] Optimizing Eq instances with reallyUnsafePtrEquality#

Simon Jakobi simon.jakobi at googlemail.com
Tue Jun 8 14:25:52 UTC 2021


Hi everyone!

In https://github.com/haskell-unordered-containers/unordered-containers/issues/77
we're wondering whether certain Eq instances, for example record types
or strings, could be optimized by including a pointer equality check
that detects when an object is compared with itself.

Does anyone here have experience with such an optimization? Has this
been considered before, for example in GHC's deriving machinery?

One complication seems to be the correct handling of fields with
irreflexive instances, for example Float and Double. In such a case,
pointer equality doesn't imply "==-equality".

I'm looking forward to hearing your thoughts on this! :)

Cheers,
Simon


More information about the Haskell-Cafe mailing list