Re: [Haskell-cafe] Commutative monads vs Applicative functors

Anders Kock has a nice paper on commutative monads [1]. He relates commutativity to the Fubini theorem, because that is what commutativity is for the monad of meaures: You can change the order in integration by parts. He works in a symmetric monoidal closed category, so Hask works, too. It is the sort of category theory paper where you can go along the paper and implement most of it in Haskell. In particular, he mentions that MonadPlus has an alternative set of laws: A monad m is a MonadPlus when there are isomorphisms iso0 :: () -> m Void iso2 :: (m a,m b) -> m (Either a b) Indeed, let mzero = liftM absurd (iso0 ()) mplus x y = liftM codiagonal (iso2 (x,y)) where codiagonal (Left x) = x codiagonal (Right y) = y Conversely, let iso0 () = mzero iso2 (x,y) = (liftM Left x) `mplus` (liftM Right y) Then Kock shows that the MonadPlus operations are automatically Eilenberg-Moore algebra homomorphisms, which is the abstract way of saying that addition distributes over multiplication. On a related note, I wonder whether the following is true: Let m be a monad and let r be an object which is an m-algebra. Think of m as the free semigroup monad. Now consider the continuation monad type T x = (x -> r) -> r Observe that (x -> r) inherits the m-algebra structure of r. Let T' x be the subset of maps in T x which are m-linear. Is T' a monad, too? Can this me made concrete in a Haskell function? Regards, Olaf [1] @article{kock12, author="Kock, Anders", title="Commutative monads as a theory of distributions", journal="Theory and Applications of Categories", volume=26, number=4, pages="97-131", year=2012, url="http://www.tac.mta.ca/tac/volumes/26/4/26-04.pdf" }
participants (1)
-
Olaf Klinke