[Haskell-cafe] Stacking monads

Andrew Coppin andrewcoppin at btinternet.com
Fri Oct 3 15:10:27 EDT 2008

Jake McArthur wrote:
> Andrew Coppin wrote:
>> But on the other hand, that would seem to imply that every monad is 
>> trivially applicative, yet studying the libraries this is not the case.
> Actually, it is the case. It is technically possible to write:
>    instance Monad m => Applicative m where
>      pure = return
>      (<*>) = ap
> We don't include the above definition because it elimimates all 
> possibility of specialization.

I don't follow.

> The reason for the separation of the two for many functions is so that 
> types which are instances of only one of the two can still take 
> advantage of the functionality.

Well, that makes sense once you assume two seperate, unconnected 
classes. I'm still fuzzy on that first point though.

>> Foldable seems simplish, except that it refers to some odd "monoid" 
>> class that looks suspiciously like "MonadPlus" but isn't... wuh?
> A Monoid is simply anything that has an identity element (mempty) and 
> an associative binary operation (mappend). It is not necessary for a 
> complete instance of Foldable.

Again, it looks like MonadPlus == Monad + Monoid, except all the method 
names are different. Why do we have this confusing duplication?

More information about the Haskell-Cafe mailing list