Early on we claimed, with no explanation, that distributive laws are monads. As the title of this post suggests, we are now in a place to explain the details of what this rather intriguing statement means. This will require our previous experience of monads in a 2-category, and distributive laws. In particular, the ability to define monads within arbitrary 2-categories gives us an awful lot of additional expressive freedom. Our first step will be to introduce a 2-category suitable for formalising relationships between monads.
A 2-category of Monads
The 2-category that we will be interested in has monads as 0-cells, Eilenberg-Moore laws as 1-cells, and compatible natural transformations as 2-cells. We now spell out the details.
For an arbitrary 2-category , there is a 2-category
with:
- 0-cells: Tuples
consisting of a 0-cell
, such that
is a monad on
in
.
- 1-cells: A 2-cell
is a pair
consisting of a 1-cell
, and a 2-cell
, such that
is an Eilenberg-Moore law.
- 2-cells: A 2-cell
is a 2-cell
such that
.
Horizontal composition is given by
with
The vertical composition and identities for 2-cells in are inherited from
.
Monads in the 2-category of Monads
We now consider what a monad in boils down to. As we will be working a 2-category constructed from another 2-category, and with 3 different monads, we will be fussy in spelling out the details carefully.
A monad in consists of four pieces of data:
- A 0-cell in
. That is, some monad
in
.
- A 1-cell in
of type
. That is, a 1-cell
in
, and an Eilenberg-Moore law
.
- A unit 2-cell of type
in
. That is, a 2-cell
in
such that
.
- A multiplication 2-cell of type
in
. That is, a 2-cell
in
such that
.
The unit and associativity axioms for a monad in are equivalent to requiring that
satisfies those axioms for a monad on
in
. Finally, the two equations satisfied by the unit and multiplication as 2-cells in
are equivalent to requiring that
is a Kleisli-law. As we noted previously, being a distributive law is equivalent to simultaneously being an Eilenberg-Moore law and a Kleisli law. Therefore, a monad in
is equivalent to the following data:
- A 0-cell
in
.
- A pair of monads
and
on
in
.
- A distributive law
in
.
Roughly speaking, up to being more careful to specify all the required data, a distributive law in is the same thing as a monad in
.
Example: For the “ordinary” monads discussed in the previous post, a distributive law is a monad in .
If we iterate the monad 2-category construction, a distributive law in is the same thing as a 0-cell in
.
Conclusion
This relatively short post has unravelled an observation of Street, to show how a distributive law can be seen as a monad in a suitable 2-category. This both served as an illustration of the power of the notion of monad in a 2-category, and provided an excuse to introduce the 2-category . This 2-category is important more broadly in the theory of monads and distributive laws. In particular, by using the different dualities that apply in a 2-category, which we encountered when discussing comonads, we can incorporate comonads and Kleisli laws in the same setting. By iterating these constructions, we can consider different flavours of distributive laws such as monad-comonad or comonad-monad distributive laws. Hopefully we will get the chance to return to these topics later.
Further reading: The constructions outlined in this post were introduced in Street’s “Formal Theory of Monads”, along with vastly more important ideas than we have had chance to discuss. The 2-category is also discussed in a very readable way, with more motivation for computer scientists, in Power and Watanabe’s “Combining a Monad and a Comonad”, along with many other interesting developments.