[Haskell-cafe] Re: what is inverse of mzero and return?
Jorge Adriano Aires
jadrian at mat.uc.pt
Tue Jan 25 12:01:07 EST 2005
> Jules Bean wrote:
> > It's in Control.Monad.Error. Not documented though.
> > Jules
> Ahh, so it is:
> instance MonadPlus IO where
> mzero = ioError (userError "mzero")
> m `mplus` n = m `catch` \_ -> n
> So, the author of this obviously subscribed to the view that
> side-effects are not counted when considering function identity...
(elements of type (IO a) are not functions)
I said it in a previous post, I think there is quite some confusion between
mplus and what I called skipError = m `catch` \_ -> n. There it is again,
they were defined to be the same. Doesn't surprise me. Maybe the author just
didn't take into account the MonadPlus laws (whatever they are).
Also the MonadPlus instance of Maybe doesn't take into account,
(mplus a b) >>= c = mplus (a >>= c) (b >>= c)
So what does that mean? IMO there are no paradoxes here, just lack of
specifications. And clearing that up should begin with:
What are the MonadPlus laws?
More information about the Haskell-Cafe