[Haskell-cafe] Re: instance Eq (a -> b)
Ashley Yakeley
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
> functions
>
> f :: Double -> Double
> f x = 1/x
>
> and
>
> 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.
--
Ashley Yakeley
More information about the Haskell-Cafe
mailing list