Tue, 2 May 2000 19:21:22 +0400 (MSD), S.D.Mechveliani <[EMAIL PROTECTED]> pisze:
> basAlgPropos says
> "class (Show a, Eq a) => Set a where ...
> is introduced as a superclass for all algebra. It also provides
> compare_m for the partial ordering (which, for example, can be
> defined trivially).
> "
> Now, compare_m can be separated to
> class Set a => PartialOrd a where
> compare_m :: a -> a -> Maybe CompValue,
>
> PartialOrd being a superclass for Ord
Currently, to be able to use a type as a key of FiniteMap, I must
make Eq and Ord instances. These classes are very simple, have only
operations relevant for ordering, and with default methods it's enough
to define only (==) and (<=), or only (==) and compare. It's easy
to see why Eq and Ord are separate, fewer types have (<) than (==),
but otherwise it's very simple, the whole picture easily fits in mind.
With your proposal I would have to define instances of
Show
Eq
Set
PartialOrd
Ord
to be able to define and use (<). They include strange "belongs"
which IMHO does not make sense at all, they include baseSet which
maps a sample argument to a record of five fields which uses five
Maybe-Maybes, two enumeration types, Integer, list, and tuples. I
must think about Show instance, and define partial ordering first,
then make it total ordering.
This is why I say it's too complex. Instead of two simple methods,
I would have to define that much, even if most of them are completely
not needed, and many don't even have a sensible implementation for
some types. Why should Show be required for Ord? Why should I be
forced to compute the cardinality, which is not trivial for more
complex compound polymorphic abstract types?
Of course I could define these methods trivially: the cardinality is
unknown, I don't know when the type will be finite, I don't know the
bounds, I don't know what does it mean that the order is Noether,
everything will show as "<foo>", and everything "belongs", whatever
it means. But this defeats the purpose of classes.
Please, NO!
Haskell is hard enough for newbies to learn, compilers are slow enough,
compiled programs are big enough.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-