Where do monads come from?

Last time, we saw several ad-hoc examples of monads. Now we look for a more uniform way to produce them. This is our first step into a wider world, in which connections with other mathematical constructions start to arise.

For an adjunction L \dashv R, write \eta : \mathsf{Id} \Rightarrow R \circ L and \epsilon : L \circ R \Rightarrow \mathsf{Id}, for the unit and counit of the adjunction respectively. If R : \mathcal{D} \rightarrow \mathcal{C}, then there is a monad on \mathcal{C} with:

  • Endofunctor: R \circ L.
  • Unit: \eta : \mathsf{Id} \Rightarrow R \circ L.
  • Multiplication: R \epsilon_L : (R \circ L)^2 \Rightarrow R \circ L.

In fact, every monad arises in this way, although we wont see the details of the other direction until we discuss Kleisli and Eilenberg-Moore categories in later posts.

Example: The category \mathsf{Set} is Cartesian closed. We therefore have for a fixed S, an adjunction (-) \times S \vdash S \Rightarrow (-). The resulting monad S \Rightarrow (-) \times S is known as the state monad.

The construction above can be generalized. If we have an adjunction as before, and a monad \mathbb{T} : \mathcal{C} \rightarrow \mathcal{C}, then there is a monad on \mathcal{C} with:

  • Endofunctor: R \circ \mathbb{T} \circ L.
  • Unit: R \eta^{\mathbb{T}}_L \circ \eta.
  • Multiplication R \mu^{\mathbb{T}}_L \circ R \mathbb{T} \epsilon \mathbb{T} L.

Example: For a monad \mathbb{T} on \mathsf{Set}, by Cartesian closure, we get a monad S \Rightarrow \mathbb{T}(- \times S). This construction is sometimes known as the state monad transformer.

Those familiar with a bit more category theory should note that both the state monad and the corresponding transformer generalize to any Cartesian closed, and in fact any monoidal closed category.

So we have seen that finding monads can be reduced to finding adjunctions, and in a sense this is the only trick we need. It does have the disadvantage that to get a concrete description of the resulting monad, we need a good understanding of both the left and right adjoints.

So for example, to find lots of monads on the category \mathsf{Set}, we just need a source of lots of right adjoint functors \mathcal{C} \rightarrow \mathsf{Set}. Ideally, we would like a nice concrete description of both adjoints, in order to get a clear formulation the composite monad.

Next time, we will look at a conceptually important way in which we can find such functors.

4 thoughts on “Where do monads come from?”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: