[Haskell-cafe] Mystery of an Eq instance

Mike Meyer mwm at mired.org
Sun Sep 22 04:11:12 CEST 2013

On Sat, Sep 21, 2013 at 5:28 PM, Bardur Arantsson <spam at scientician.net>
> On 2013-09-21 23:08, Mike Meyer wrote:
> > Exactly. The Eq and Ord instances aren't what's broken, at least when
> > you're dealing with numbers (NaNs are another story). That there are
> According to Haskell NaN *is* a number.

Trying to make something whose name is "Not A Number" act like a
number sounds broken from the start.

> > Eq and Ord are just the messengers.
> No. When we declare something an instance of Monad or Applicative (for
> example), we expect(*) that thing to obey certain laws. Eq and Ord
> instances for Float/Double do *not* obey the expected laws.

I just went back through the thread, and the only examples I could
find where that happened (as opposed to where floating point
calculations or literals resulted in unexpected values) was with
NaNs. Just out of curiosity, do you know of any that don't involve

Float violates the expected behavior of instances of - well, pretty
much everything it's an instance of. Even if you restrict yourself to
working with integer values that can be represented as floats.  If
we're going to start removing it as an instance for violating instance
expectations, we might as well take it out of the numeric stack (or
the language) completely.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130921/e7b618ed/attachment.htm>

More information about the Haskell-Cafe mailing list