Hi Haskell experts,
while waiting for the release of Haskell 1.3 (for my machine), I passed the time
reading the almost finished report. The most interesting part was the new monad
system. Could someone please comment on a few questions relating to the class
MonadZero?
1) I was surprised that MonadZero does not contain an operation null to test for
the zero monad. The standard monads (lists and the Maybe type) and usual
data structures (queues, ordered sets, ...) could easily implement this
operation. Which other applications were intended?
2) The library proposal does not contain any advanced data structures (yet). How
would one declare, for example, ordered sets as an instance of Monad[Plus]?
An efficient implementation of the operation m >>= f would require that f is
restricted to monotonous functions. (That is, x<=y implies that,
for all x' in f(x), for all y' in f(y), x'<=y'.) As I see it, this is the
only way to avoid unnecessary comparisons in filter, using the fact that
return is monotonous in this sense.
The constraint for f looks as if it could be explained by a category
theorist. But the books and articles I have seen on the subject only deal
with the special case join = (>>= id) instead of (>>=).
3) It would be nice if operations like elem, foldl, foldr and others could be
overloaded in a similar manner. Can we expect that PreludeList will be
replaced with something different as soon as the library proposal is
extended? Will there be subclasses of MonadPlus?
Best regards,
Klaus
Klaus Barthelmann, Institut f"ur Informatik, Universit"at Mainz, Germany,
[EMAIL PROTECTED]