>       * Eliminate MonadZero
>       * Add 'mfail :: m a' to Monad, with a suitable default decl
>       * Every do expression has a type in Monad
> 
> I must be dense this morning, as I'm still in the dark.  What is the
> intended meaning of `mfail'?  If `mfail' is `mzero', why change the
> name?  What is the suitable default declaration?  What, if anything,
> does `mfail' have to do with `do' expressions?  -- P

Sorry, I was too terse.

mfail is the same as mzero.  Perhaps it should be called mzero.
The 'fail' was meant to suggest that it might not be a zero of
the monad.  (Indeed, most monad's claimed zeros do not obey the laws
for zero, because of bottom.)  I'll use mzero in what follows.

On reflection there probably shouldn't be a default declaration for mzero.
Any compiler for Haskell must do *something* if a method is
called for which there is neither an explicit declaration in 
the instance, nor a default method.   (If there is a default method
then it's the one that should be called, which is usually uninformative.)
Leaving out the default method would let a compiler halt execution
reporting

        "Pattern match failure in `do' expression at line 39 of Foo.hs"

which is what we want.

> What, if anything, does `mfail' have to do with `do' expressions? 

On the other hand, if mzero *is* defined by the programmer, then it is
invoked when pattern match failure in a do-expression. Just as is 
the case with 'zero' now.


As Mark says, the whole situation is very like ordinary pattern
matching. If we have

        data T = T1 Int

        f :: T -> Int
        f (T1 a) = a

then adding a constructor to T doesn't change the type of f,
but it might make it fail at runtime.  The interesting thing
about 'do' is that you get the chance to continue after a 
pattern match failure if you provide a binding for mzero in the
instance declaration for the monad.


The more I think about this the more I like option 2: nuke
MonadZero.

Simon


Reply via email to