Re: [Haskell-cafe] Control.Alternative --- some and many?

2010-06-23 Thread Neil Brown

On 23/06/10 06:54, Christopher Done wrote:

I'm not sure how Alternative differs from MonadPlus, other than being
defined for Applicative rather than Monad.  They have the same laws
(identity and associativity).
   


Importantly, MonadPlus must satisfy some laws for (>>=) and (>>), 
whereas Alternative must only satisfy laws for the new (<|>) operator.  
There are plenty of monads that do not satisfy the laws for MonadPlus 
(particularly the difficult mzero-being-right-zero law), but do satisfy 
the laws when defining their (<|>) implementation.  So they are 
different because MonadPlus overlaps with Monad, whereas Alternative 
does not (and thus, in my view, is much cleaner and more useful).



"Some" and "many" are probably motivated by their usefulness in
parsers.  Hence "optional", etc.  I'm sure there are plenty of other
uses for it.
   


I wrote a little about some and many in Alternative in this blog post: 
http://chplib.wordpress.com/2010/05/05/choose-anything-adding-an-alternative-instance/ 
(scroll down to the "Alternative" heading).  I think they are mainly 
useful with a left-biased choice operator.



On 23 June 2010 05:22, Gregory Crosswhite  wrote:
   

Hey everyone,

Could someone explain to me (or point me to a reference explaining) the
purpose of the "some" and "many" methods of the Alternative class?

Also, there is a link posted in the documentation for Control.Applicative to
a paper which describes the motivation behind the Applicative class;  is
there similarly a paper explaining the motivation behind the Alternative
class?  (The problem with Googling for "Alternative" is that this word is
used a whole lot of the time, and very rarely does it refer to the
Alernative class.  :-) )

Cheers,
Greg

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

 

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


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


Re: [Haskell-cafe] Control.Alternative --- some and many?

2010-06-22 Thread Christopher Done
I'm not sure how Alternative differs from MonadPlus, other than being
defined for Applicative rather than Monad.  They have the same laws
(identity and associativity).

"Some" and "many" are probably motivated by their usefulness in
parsers.  Hence "optional", etc.  I'm sure there are plenty of other
uses for it.

On 23 June 2010 05:22, Gregory Crosswhite  wrote:
> Hey everyone,
>
> Could someone explain to me (or point me to a reference explaining) the
> purpose of the "some" and "many" methods of the Alternative class?
>
> Also, there is a link posted in the documentation for Control.Applicative to
> a paper which describes the motivation behind the Applicative class;  is
> there similarly a paper explaining the motivation behind the Alternative
> class?  (The problem with Googling for "Alternative" is that this word is
> used a whole lot of the time, and very rarely does it refer to the
> Alernative class.  :-) )
>
> Cheers,
> Greg
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe