[Haskell-cafe] Re: Why purely in haskell?
Wolfgang Jeltsch
g9ks157k at acme.softbase.org
Fri Jan 11 04:27:44 EST 2008
Am Freitag, 11. Januar 2008 08:11 schrieb Lennart Augustsson:
> Some people seem to think that == is an equality predicate.
> This is a big source of confusion for them; until they realize that == is
> just another function returning Bool they will make claims like
> [1..]==[1..] having an unnatural result.
>
> The == function is only vaguely related to the equality predicate in that
> it is meant to be a computable approximation of semantic equality (but
> since it's overloaded it can be anything, of course).
>
> -- Lennart
But class methods are expected to fulfill some axioms. I’d suppose that (==)
should be an equivalence relation. Of course, this is not implementable
because of infininte data structures. But one could relax the axioms such
that it’s allowed for (==) to return _|_ instead of the expected value.
Differentiating between data and codata would of course be the better
solution.
However, the fact that (0 / 0) == (0 / 0) yields False is quite shocking. It
doesn’t adhere to any meaningful axiom set for Eq. So I think that this
behavior should be changed. Think of a set implementation which uses (==) to
compare set elements for equality. The NaN behavior would break this
implementation since it would allow for sets which contain NaN multiple
times.
Best wishes,
Wolfgang
More information about the Haskell-Cafe
mailing list