To return to the theoretical considerations. The free monad gets a lot of attention. Monoid objects in monoidal categories However, those are specifically the formulation of monads and applicatives as monoid objects (in a monoidal category). That is the source of the “a monad is just a monoid in the [monoidal] category of endofunctors [under composition]” meme, while an applicative functor is “just” a monoid in the [monoidal] category of endofunctors under Day convolution. I argue that it is important to include “under composition” in the description of the monad, because there are many monoidal products available on functors, and functor composition is a surprising choice, since it is not symmetric at all! In fact, you can think of the Day convolution as a symmetrization of the composition tensor: there is a natural map Day f g ~> Compose f g, and since Day is symmetric, it also has a map Day f g ~> Compose g f via Day g f ~> Day f g. The monoid operation is an arrow merge:M⊗M→M\operatorname{merge} : M \otimes M \to Mmerge:M⊗M→M in the functor category: that is, a natural transformation. So for monads it is join :: Compose f f ~> f, which is just forall r. f (f r) -> f r, and for applicatives it is liftA2 :: Day f f ~> f, which expands to forall r x y. (x -> y -> r) -> f x -> f y -> f r, at which point we can either take x = (y -> r) and apply id to get back (<*>), or we can take r = (x, y) and apply (,) to get a tupling function below. Applicative functors can also be thought of as lax monoidal functors (between two monoidal categories), which come with an operation tupling:f(x)⊗f(y)→f(x⊗y)\operatorname{tupling} : f(x) \otimes f(y) \to f (x \otimes y)tupling:f(x)⊗f(y)→f(x⊗y). (In the case of applicative functors, both ⊗{\otimes}⊗ are the product ×{\times}×.) As we just said, it comes from the fact that a universal choice for the (x -> y -> r) function is the tuple constructor: because that preserves information, any other choice factors through it. Arrows We can...
First seen: 2026-01-05 21:26
Last seen: 2026-01-05 23:27