[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts
cdsmith at gmail.com
Fri Mar 4 16:37:10 CET 2011
On Mar 4, 2011 2:49 AM, "Karthick Gururaj" <karthick.gururaj at gmail.com>
> > Ord has to be compatible with Eq, and none of these are.
> Hmm.. not true. Can you explain what do you mean by "compatibility"?
Compatibility would mean that x == y if and only if compare x y == EQ. This
is not a restricrion enforced by the type system, but it is something that I
would think ought to be true (though it is not,for example, for the IEEE
floating point types; I personally consider that a bug and believe the IEEE
notions of comparison ought to be exposed in a different set of operations
rather than instances of Ord and Eq). In this sense it is much like the
monad laws. So whether it has to be true depends on what you mean by "has
> Ok - at this stage, I'll just take your word for it. I'm not able to
> still appreciate the choice of the default ordering order, but I need
> to wait until I get to see/develop some real code.
The most common use of Ord in real code, to be honest, is to use the value
in some data structure like Data.Set.Set or Data.Map.Map, which requires Ord
instances. For this purpose, any Ord instance that is compatible with Eq
will do fine.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe