(x >>= f) >>= g == x >>= (\v -> f v >>= g)
However, this seems to me a kind of mathematical identity. If it is
mathematical identity, a programmer need not care about this law to
implement a monad. Can anyone give me an example implementation of
monad that violate this law ?
It's well known that "ListT m" monad violates this law in general
(though it satisfies it for some particular monads m). For example,
Prelude Control.Monad.List> runListT ((ListT [[(),()]] >> ListT [[()],
[()]]) >> ListT [[1],[2]])
[[1,1],[1,2],[2,1],[2,2],[1,1],[1,2],[2,1],[2,2],[1,1],[1,2],[2,1],
[2,2],[1,1],[1,2],[2,1],[2,2]]
Prelude Control.Monad.List> runListT (ListT [[(),()]] >> (ListT [[()],
[()]] >> ListT [[1],[2]]))
[[1,1],[1,2],[1,1],[1,2],[2,1],[2,2],[2,1],[2,2],[1,1],[1,2],[1,1],
[1,2],[2,1],[2,2],[2,1],[2,2]]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe