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 , write
and
, for the unit and counit of the adjunction respectively. If
, then there is a monad on
with:
- Endofunctor:
.
- Unit:
.
- Multiplication:
.
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 is Cartesian closed. We therefore have for a fixed
, an adjunction
. The resulting monad
is known as the state monad.
The construction above can be generalized. If we have an adjunction as before, and a monad , then there is a monad on
with:
- Endofunctor:
.
- Unit:
.
- Multiplication
.
Example: For a monad on
, by Cartesian closure, we get a monad
. 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 , we just need a source of lots of right adjoint functors
. 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?”