[Haskell-cafe] Re: instance Eq (a -> b)
ashley at semantic.org
Thu Apr 15 15:22:15 EDT 2010
On 2010-04-15 06:18, Nick Bowler wrote:
> Your definitions seem very strange, because according to this, the
> f :: Double -> Double
> f x = 1/x
> g :: Double -> Double
> g x = 1/x
> are not equal, since (-0.0 == 0.0) yet f (-0.0) /= g (0.0).
There's an impedance mismatch between the IEEE notion of equality (under
which -0.0 == 0.0), and the Haskell notion of equality (where we'd want
x == y to imply f x == f y).
A Haskellish solution would be to implement Eq so that it compares the
bits of the representations of Float and Double, thus -0.0 /= 0.0, NaN
== NaN (if it's the same NaN). But this might surprise people expecting
IEEE equality, which is probably almost everyone using Float or Double.
More information about the Haskell-Cafe