> 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. It also means one can simply write
>
> instance Monad [] where
> ...return, >>=, >> as before...
> mfail s = []
Good idea! So your suggestion is:
class Monad m where
...return, >>=, >> as before...
mfail :: String -> m a
class MonadPlus m where
mplus :: m a -> m a -> m a
mzero :: m a
I certainly don't object to that, and it has the merit you mention,
namely that people who don't want zero or plus don't need to fuss with
it. Should it still be called MonadPlus? (yes, say I... it's a
Monad plus some extra stuff :)
A third alternative (which is more or less what Mark suggested)
is to retain MonadZero also, just as now.
Monad( return, >>=, >>, mfail )
MonadZero( mzero )
MonadPlus( mplus )
That is a smaller change from the present situation, but it's
not clear that the extra monads are worth the candle.
OK, so
Option 1: Monad( .., mfail, mzero ), MonadPlus( mplus )
Option 2: Monad( .., mfail), MonadPlus( mzero, mplus )
Option 3: Monad( .., mfail), MonadPlus( mplus ), MonadZero( mzero )
I think I like (2) best, but I could live with any of them.
Votes to me (don't copy the list unless you have something else
to say than a vote)
> 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'. -- P
I don't like grabbing too many very generic names like zero, plus, fail
from the user (this is all in the Prelude, remember). I don't want
to grab 'raise' because we're going to want it for exceptions in Haskell
2. I havn't been able to think of anything better than these monsters.
Simon