5 ms·
"Monads don't compose" is a common sentence (google it!), for example here: https://stackoverflow.com/questions/7040844/applicatives-compose-monads-dont https:/
by the-alt-one 5y ago
"Monads don't compose" is a common sentence (google it!), for example here: https://stackoverflow.com/questions/7040844/applicatives-compose-monads-dont https://stackoverflow.com/questions/7040844/applicatives-com...
Maybe you already knew about this and is still asking, though?
- contravariant 5y agoI 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 5y agoIt'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_laws.html 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.
- contravariant 5y agoThat's a very interesting article, thanks. That said while FG = GF is indeed restrictive, requiring there to be a natural isomorphism between them is slightly less restrictive and just requiring the existence of a distributive law seems a bit too broad. What's preventing the existence of multiple distributive laws? Is there even anything preventing monads from always having a distributive law?
- kmill 5y agoThere is nothing at all preventing the existence of multiple distributive laws, and I can think of some (non-programmy) examples that have multiple possibilities. I wouldn't be surprised if some cohomology group classifies them, at least in certain settings. I don't know about whether distributive laws always exist, but what is probably true is that there's no universal distributive law -- that's in the sense that you have a function from pairs of monads to distributive laws that is natural with respect to homomorphisms of monads, whatever those are (I know there's a bicategory of monads, but that's about it).