top | item 30361090

(no title)

the-alt-one | 4 years ago

"Monads don't compose" is a common sentence (google it!), for example here: https://stackoverflow.com/questions/7040844/applicatives-com...

Maybe you already knew about this and is still asking, though?

discuss

order

contravariant|4 years ago

I wasn't aware. The examples given here are all cases where the monad doesn't commute, hence my question.

If two monads commute you can show that the composition of the two is (trivially) a new monad, but I'm not sure if the converse also holds.

kmill|4 years ago

It's not very precise talking about whether a monad commutes -- it's not clear what "commutes" should really mean (certainly not F . G = G . F since that's way too restrictive).

I started working it out by hand, but then figured nLab had it somewhere, and indeed: https://golem.ph.utexas.edu/category/2017/02/distributive_la...

F, G, and F.G are monads if and only if there is a "distributive law," which is a natural transformation G.F -> F.G satisfying some properties. It's like something that satisfies half the braiding properties, where braidings are already a weaker version of commutativity.