# [Haskell-cafe] Re: (flawed?) benchmark : sort

Dan Weston westondan at imageworks.com
Mon Mar 10 17:01:53 EDT 2008

```If x <= y && y <= x does not imply that x == y, then Ord has no business
being a subclass of Eq. By your logic, there is absolutely no
constructive subclassing going on here, only an existence proof of (==)
given (<=). What is the rational basis of such an existence claim,
unless == has the obvious meaning?

Or should I take it that you are suggesting we should move Ord up to be
a peer of Eq?

Dan

Neil Mitchell wrote:
> Hi
>
>>  But antisymmetry means that (x <= y) && (y <= x) ==> x = y, where '=' means
>>  identity. Now what does (should) 'identity' mean?
>
> I think you are using the word identity when the right would would be
> equality. Hence, the answer is, without a doubt, (==). If you define
> equality, then you are defining equality.
>
>>  In short, I would consider code where for some x, y and a function f we have
>>  (x <= y) && (y <= x) [or, equivalently, compare x y == EQ] but f x /= f y
>>  broken indeed.
>
> I would consider it slightly bad code too. But not broken code. I
> think Ord functions can assume that Ord is a total ordering, nothing
> more. Nothing to do with the existence (or otherwise) of entirely
> unrelated code.
>
> Consider the following implementation of Data.Set, which *does* meet
> all the invariants in Data.Set:
>
> data Set a = Set [a]
> insert x (Set xs) = Set \$ x : filter (/= x) xs
> elems (Set xs) = xs
>
> i.e. there is real code in the base libraries which breaks this notion
> of respecting classes etc. Is the interface to Data.Set broken? I
> would say it isn't.
>
> Thanks
>
> Neil
>
>

```

More information about the Haskell-Cafe mailing list