[Haskell-cafe] Applicative but not Monad

Tom Davie tom.davie at gmail.com
Fri Oct 30 13:06:55 EDT 2009

On Fri, Oct 30, 2009 at 5:59 PM, Luke Palmer <lrpalmer at gmail.com> wrote:

> On Fri, Oct 30, 2009 at 10:39 AM, Tom Davie <tom.davie at gmail.com> wrote:
> > Of note, there is a sensible monad instance for zip lists which I *think*
> > agrees with the Applicative one, I don't know why they're not monads:
> > instance Monad (ZipList a) where
> >   return = Ziplist . return
> >   join (ZipList []) = ZipList []
> >   join (ZipList (a:as)) = zlHead a `zlCons` join (map zlTail as)
> IIRC, that doesn't satisfy the associativity law, particularly when
> you are joining a list of lists of different lengths.  2 minutes of
> experimenting failed to find me the counterexample though.

Cool, thanks Luke, that explains why this is available in Stream, but not in
ZipList too.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091030/c2fe514e/attachment.html

More information about the Haskell-Cafe mailing list