looking for data structure advice

Derek Elkins ddarius at hotpop.com
Sun Dec 14 10:59:45 EST 2003

On Fri, 12 Dec 2003 20:55:59 +0000
Graham Klyne <GK at ninebynine.org> wrote:

> At 14:17 12/12/03 -0500, Derek Elkins wrote:
> >This will also provide a migration path if you want a more featureful
> >monad.  (or_maybe is mplus, fail or mzero can be used for Nothing
> >when you explicitly want to fail).
> Is this or_maybe (and friends) actually defined in any of the standard
> libraries?  (Google found only one hit, in an old IRC log.)

Well, I was somewhat confusing in switching the order, but or_maybe is a
specialization of mplus.  mplus is the general standard function and
or_maybe is David's specialized to Maybe version.


The idea of the operations of the MonadPlus class is mzero typically
stands for some kind of failure and mplus is a choice or a merging.  A
logic analogy is if a >> b >> c is do a and b and c then a `mplus` b
`mplus` c is do a or b or c.  mzero would be false and return x would be
true.  Examples of things that would be instances of MonadPlus are:
lists as representing non-determinism where mzero is [] meaning no
answers (failure) and mplus being non-deterministic choice represented
as (++), parsers with mzero as the always failing parser and mplus as
alternation (Parsec's <|>), concurrency with mzero as the process that
immediately halts and mplus as par (run two processes in parallel).

More information about the Haskell-Cafe mailing list