[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts
ok at cs.otago.ac.nz
Fri Mar 4 06:12:21 CET 2011
On 4/03/2011, at 5:49 PM, Karthick Gururaj wrote:
> I meant: there is no reasonable way of ordering tuples, let alone enum
There are several reasonable ways to order tuples.
> That does not mean we can't define them:
> 1. (a,b) > (c,d) if a>c
Not really reasonable because it isn't compatible with equality.
> 2. (a,b) > (c,d) if b>d
> 3. (a,b) > (c,d) if a^2 + b^2 > c^2 + d^2
> 4. (a,b) > (c,d) if a*b > c*d
Ord has to be compatible with Eq, and none of these are.
Lexicographic ordering is in wide use and fully compatible
> Which of
> these is a reasonable definition?
> The set of complex numbers do not
> have a "default" ordering, due to this very issue.
No, that's for another reason. The complex numbers don't have
a standard ordering because when you have a ring or field and
you add an ordering, you want the two to be compatible, and
there is no total order for the complex numbers that fits in
the way required.
> When we do not have a "reasonable" way of ordering, I'd argue to not
> have anything at all
There is nothing unreasonable about lexicographic order.
It makes an excellent default.
> As a side note, the cardinality of rational numbers is the same as
> those of integers - so both are "equally" infinite.
Ah, here we come across the distinction between cardinals and
ordinals. Two sets can have the same cardinality but not be
the same order type. (Add 1 to the first infinite cardinal
and you get the same cardinal back; add 1 to the first infinite
ordinal and you don't get the same ordinal back.)
More information about the Haskell-Cafe