Until I edited it, the Haskell Wiki claimed to be Maybea commutative monad (in fact, I think it still claims to be somewhere). This is clearly wrong because
do {a <- Nothing; b <- undefined; return (a,b)} === Nothing
and
do {b <- undefined; a <- Nothing; return (a,b)} === undefined
This failure of commutativity is actually quite important in real code: programmers rely on the computation to stop as soon as it reaches Nothing.
This leaves (among the monads described as commutative on the Haskell Wiki) only the monad Reader, which does not seem to do anything terrible. This raised my question about whether there are any commutative monads in Haskell that are significantly different from Reader, with the exception of limitations Reader.
Edit
I just realized that it is also possible to make a limited monad Writercommutative - it should accumulate values in some commutative monoid. Still not interesting.
source
share