On Fri, Oct 30, 2009 at 1:33 PM, Yusaku Hashimoto <nonow...@gmail.com> wrote:
> Thanks for fast replies! Examples you gave explain why all
> Applicatives are not Monads to me.
>
> And I tried to rewrite Bob's Monad instance for ZipList with (>>=).
>
> import Control.Applicative
>
> instance Monad ZipList where
>  return = ZipList . return
>  (ZipList []) >>= _ = ZipList []
>  (ZipList (a:as)) >>= f = zlHead (f a) `zlCons` (ZipList as >>= f)

This is taking the first element of each list, but you need to take
the nth element. Try

  (ZipList (a:as)) >>= f = zlHead (f a) `zlCons` (ZipList as >>= zlTail . f)


-- 
Dave Menendez <d...@zednenem.com>
<http://www.eyrie.org/~zednenem/>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to