[Haskell-cafe] Re: what is inverse of mzero and return?

Daniel Fischer daniel.is.fischer at web.de
Sat Jan 22 16:40:31 EST 2005


Am Samstag, 22. Januar 2005 21:20 schrieb Keean Schupke:
> Ashley Yakeley wrote:
> >In article <41F211FB.3030706 at imperial.ac.uk>,
> >
> > Keean Schupke <k.schupke at imperial.ac.uk> wrote:
> >>This fits the above description, but I don't see how the following can
> >>be true:
> >>
> >>    (mplus a b) >>= c = mplus (a >>= c) (b >>= c)
> >
> >Try it (and my test code) with [], which is an instance of MonadPlus.
> >mplus is defined as (++) for [].
>
> but what if (a >>= c) causes c to fail, and (b >>= c) lets c succeed. In
> this
> case the LHS will fail, whereas the RHS will succeed I think?
>
>     Keean.

That's probably a misunderstanding due to the notation, in the [] monad, it's 
just

concat (map c (a ++ b)) = concat (map c a) ++ concat (Map c b),

which is easily seen to be true (if applying c to an element of a causes an 
error, neither side will go past that).

Daniel


More information about the Haskell-Cafe mailing list