
18 Oct
2013
18 Oct
'13
9:15 p.m.
Violates the Monad laws, specifically join . join = join . fmap join:
let join x = bind x id join (join [[[1]],[[],[2,3]]]) [1,3] join (fmap join [[[1]],[[],[2,3]]]) [1]
That's right. Thanks. I found yet another pedagogical case: f x = case x of 1 -> MyZipList [1,0,0] 2 -> MyZipList [0,2,0] 3 -> MyZipList [0,0,3] otherwise -> MyZipList []
MyZipList [1,2,3] >>= f >>= f MyZipList [1,2,3]
MyZipList [1,2,3] >>= \x -> (f x >>= f) MyZipList [1]
So the conclusion is ZipList can never be a Monad in a strict sense, right? - Etsuji