I\'ve seen mentioned that IO
doesn\'t satisfy the monad laws, but I didn\'t find a simple example showing that. Anybody knows an example? Thanks.
m >>= return ≡ m
is broken:
sequence_ $ take 100000 $ iterate (>>=return) (return ()) :: IO ()
clutters memory and increases computation time, while
sequence_ $ take 100000 $ iterate (>>=return) (return ()) :: Maybe ()
does not.
AFAIR there is a Monad Transformer which solves this problem; if I guess right, it is the Codensity Monad Transformer.