
30 Oct
2009
30 Oct
'09
1:39 p.m.
On Fri, Oct 30, 2009 at 1:33 PM, Yusaku Hashimoto
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