[Haskell-cafe] Mystery of an Eq instance
Albert Y. C. Lai
trebla at vex.net
Fri Sep 20 18:31:59 CEST 2013
On 13-09-20 07:47 AM, damodar kulkarni wrote:
> *Main> sqrt (10.0) ==3.1622776601683795
> True
[...]
> *Main> sqrt (10.0) ==3.16227766016837956435443343
> True
This is not even specific to Haskell. Every language that provides
floating point and floating point equality does this.
(To date, P(provides floating point equality | provides floating point)
seems to be still 1.)
In the case of Haskell, where you may have a choice:
Do you want floating point > < ?
If you say yes, then you have two problems.
1. At present, Haskell puts > < under Ord, and Ord under Eq. You must
accept Eq to get Ord. If you reject this, you're asking the whole
community to re-arrange that class hierarchy just for a few types.
2. With or without your approval, one can still defy you and define:
eq x y = not_corner_case x && not_corner_case y &&
not (x<y) && not (x>y)
See, == can be derived from > < .
More information about the Haskell-Cafe
mailing list