[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] MonadPlus versus Alternative
From:       wren ng thornton <wren () freegeek ! org>
Date:       2011-10-31 0:39:04
Message-ID: 4EADEE28.2080801 () freegeek ! org
[Download RAW message or body]

On 10/29/11 11:02 PM, Gregory Crosswhite wrote:
> Hey everyone,
> 
> What is the difference between MonadPlus and Alternative?  In my mind, it would \
> make sense for the difference to be that the former provides "and" semantics (i.e., \
> x `mplus` y means do both x and y) whereas the latter provides "or" semantics \
> (i.e., x<|>  y means do x or y but not both).  However, when I look at the \
> instances defined for List I see that it is exactly the same as MonadPlus.

As other's've mentioned, they both have "or" semantics and it's just an 
artifact of the Monad/Applicative split. However, an additional note.

For lists or sets, the mplus/(<|>) functions could be interpreted as 
both "and" and "or" semantics, depending on what you think lists are. If 
you think of them as a collection of multiple answers, then 
concatenating/unioning is colloquially regarded as saying I have xs and 
ys. However, if you think of them as giving a non-deterministic answer, 
then the concatenation/union should be regarded as saying you can chose 
the xs or the ys, which is closer to the logical interpretation of union 
as disjunction.

I guess my point is that the notion of "and" isn't especially 
well-defined. At the very least there are three different notions of 
"and". We have the andThen notion which corresponds to monadic bind, 
probabilistic conjunction, and Sigma types. We have the andAlso notion 
which corresponds to unions conceived of as nondeterminisms, also covers 
the linear conjunction which only lets you take one of the projections, 
and is the one involved with the idea of "and"ing two functions with 
(+++). And we have the bothAnd notion which corresponds to Cartesian 
products, logical conjunction, the linear conjunction which lets you 
take both projections, and the notion of "and"ing two functions with (***).

-- 
Live well,
~wren

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic