[Haskell-cafe] Mystery of an Eq instance

Mike Meyer mwm at mired.org
Sat Sep 21 23:08:41 CEST 2013


On Sep 21, 2013 9:17 AM, "Bob Hutchison" <hutch-lists at recursive.ca> wrote:
> On 2013-09-21, at 4:46 AM, Stijn van Drongelen <rhymoid at gmail.com> wrote:
>> I do have to agree with Damodar Kulkarni that different laws imply
different classes. However, this will break **a lot** of existing software.
> You could argue that the existing software is already broken.

I'd argue that it's not all broken, and you're breaking it all.

>> If we would do this, only Eq and Ord need to be duplicated, as they
cause most of the problems. Qualified imports should suffice to
differentiate between the two.
>>     import qualified Data.Eq.Approximate as A
>>     import qualified Data.Ord.Approximate as A
>>
>>     main = print $ 3.16227766016837956 A.== 3.16227766016837955
> As soon as you start doing computations with fp numbers things get much
worse.

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 pairs
of non-zero numbers that when added result in one of the two numbers is
broken. That addition isn't associative is broken. That expressions don't
obey the substitution principle is broken. But you can't tell these things
are broken until you start comparing values. Eq and Ord are just the
messengers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130921/66a52f74/attachment.htm>


More information about the Haskell-Cafe mailing list