[Haskell-cafe] Re: what is inverse of mzero and return?
Jorge Adriano Aires
jadrian at mat.uc.pt
Sat Jan 22 23:58:57 EST 2005
> Only the monoid Maybe a is not very nice (nor is the monoid IO a),since the
> second argument of the composition is in general ignored.
> So I think, rather than separating mplus, one should think about whether it
> is sensible to make Maybe and IO instances of MonadPlus in the first place.
> I don't know nearly enough of the innards of Haskell to form a valuable
> opinion of that, but perhaps somebody could enlighten me?
My humble opinion follows.
It's still a Monoid, being boring should be no reason not to include it [*].
By taking advantage of typeclasses, we can easily alternate between more
elaborate approaches and dull ones (if we have the dull ones available too).
One common example is using MonadPlus for some backtracking algorithm, then
instantiatiating it to Maybe or List instance depending on wether you just
want one solution or all of them.
[*] For instance, I've missed Maybe being an instance of MonadError.
More information about the Haskell-Cafe