[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts
Karthick Gururaj
karthick.gururaj at gmail.com
Fri Mar 4 10:47:10 CET 2011
On Fri, Mar 4, 2011 at 10:42 AM, Richard O'Keefe <ok at cs.otago.ac.nz> wrote:
>
> On 4/03/2011, at 5:49 PM, Karthick Gururaj wrote:
>> I meant: there is no reasonable way of ordering tuples, let alone enum
>> them.
>
> 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.
Hmm.. not true. Can you explain what do you mean by "compatibility"?
One of the following, and exactly one, must always hold, on a ordered
set (is this what you mean by "compatibility"?), for any arbitrary
legal selection of a, b, c and d.
a. (a, b) EQ (c, d)
b. (a, b) LT (c, d)
c. (a, b) GT (c, d)
All the definitions above are compatible in this sense.
> Lexicographic ordering is in wide use and fully compatible
> with Eq.
>> 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.
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.
>>
>>
>> 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.)
:) Ok. The original point was whether there is a reasonable way to
enumerate a tuple, I guess there is none.
More information about the Haskell-Cafe
mailing list