At 20:12 +0000 1999/04/27, Kevin Atkinson wrote:
>> So one defines a global total order on the elements of all classes and
>> instances, which then can be used to create maps and sets which are
>> balanced trees, just as in C++ STL. This total order is normally different
>> from any derivation of Ord, and is just used for sorting purposes.
>
>How is this different. Do you mean that some times the ordering is just
>an ordering and as no meanings to humans like an alphabet order does?
The total order is needed in order to make the balanced trees used for the
sets/maps. So what I have in my mind is that somehow Haskell produces a
default total order on elements. This could be the declaration order or an
alphabetical order, or whatever (and it is nice to humans that the elements
always come out in a specific, known order). For elements that have a
natural order, one can use that of course. And as an option, one can think
of that it can be overridden.
The main point though is that the total order exists, and is a sorting
order separate from the Ord derivation.
Then Haskell uses this to implement sets and maps by using C++ STL style
balanced trees. As Haskell already has generic variables, just as in the
case of lists, it needs only be implemented once.
Hans Aberg
* Email: Hans Aberg <mailto:[EMAIL PROTECTED]>
* Home Page: <http://www.matematik.su.se/~haberg/>
* AMS member listing: <http://www.ams.org/cml/>