Lennart wrote:

>Sorry, I'm not happy with this proposal.  Monads are a well
>defined mathematical concept and I think the Monad class should
>reflect this.  Having a mzero (and mfail) method seems weird to
>me.  I would suggest a MonadZero class having these methods,
>and that do notation on works for the MonadZero class (regardless
>of if you use patern matching or not).

This is even worse, especially when you appeal to mathematical elegance.
Moreover, with the current proposal, it is still possible to pretend that
your monads have structure. If you have a monad with a non-trivial zero, you
define an empty MonadZero class and replace contstraints Monad m to
MonadZero m. Usually when you write a definition for a monadic value you get
an unresolved toplevel overloading error anyway, so you must already put in
a type signature yourself.

Phil wrote:

>There is no need to have both `mzero' and `mfail' in every monad.
>Just have `mfail'.  Leave `zero' and `plus' to MonadPlus.  This should
>make Eric partially happy.

That is more or less what Mark proposed, except that in that case we should
keep MonadZero and MonadPlus. On the other hand, you can define anything on
top of Monad yourself now. The do-notation is only depending on Monad and
not on MonadZero anymore. Append is unoverloaded so there is no need anymore
for a MonadPlus class. In this light I'd rather goo for brevity than for
partial happiness.

>The names `mzero' and `mfail' are horrible.  I like Ralph's suggestion
>to change `fail' to `raise' in the IO monad, and use `fail' for
>`mfail'.  If that doesn't work, try something else, but please
>pick names that have a simple meaning in English (as with `return')
>not monsters like `mzero' and `mfail'.

Yes!, names should be pronouncable. Too much exposure to Squiggol ((| |),
( )], |>,...), Unix (cat, lpr, mv, ...) and Microsoft Hungarian (LPUNKNOWN
FAR *lppUnk, LPCTSTR lpszClassName, ...) makes people become blunted about
this issue I guess. I unsuccesfully tried this argument in the case of fmap
an its other now unoverloaded friends and proposed to use the module system
to disambiguate the names (Alastairs suggestion).

The suggestion to replace fail by raise in the IO monad and mzero and mfail
by zero and fail is a good one. On the other hand you can easily achieve the
effect yourself using some hiding and adding a handfull of definitions,
which is what I will probably end up doing. An extra level of indirection
can do wonders. The important thing is the translation of the do-notation,
which you cannot influence as a user.

Erik



Reply via email to