We have now seen both Kleisli and Eilenberg-Moore laws, and their associated notions of lifted functor. Despite introducing the appropriate definitions, and sketching their key theoretical properties, we haven’t really seen any examples yet. That is the issue we now address.
A standard source of both Kleisli and Eilenberg-Moore laws are the monad morphisms . This can be seen as both
- A Kleisli law of type
.
- An Eilenberg-Moore law of type
.
Therefore, each monad morphism induces both:
- A functor
such that
.
- A functor
such that
.
(Notice the difference in direction between the two).
Example: For every monad, the unit is a monad morphism. For the identity monad there are obvious isomorphisms:
Up to composition with these isomorphisms, the functor is the usual Kleisli free functor, and the functor
is the usual Eilenberg-Moore forgetful functor.
As is a recurring theme, we should always consider what a new feature of monad theory means in terms of algebra.
Example: Consider two equational presentations over the same signature such that
, with respective induced monads
. Then for a set
, every equivalence class of terms in
is contained in an equivalence class of terms in
, as the latter theory satisfies more equations. This induces a monad morphism:
The induced functor picks out the subcategory of
-algebras (which satisfy more equations), within the larger category of
-algebras. For example, every commutative monoid is a monoid.
As usual, we can consider the morphisms of and
as families of equivalence classes of terms in the respective theories. From this point of view, every equivalence class in the weaker theory can be promoted to the enclosing one in the stronger theory. This is the behaviour of the induced functor
. For example, the term
in the theory of monoids will be mapped to an equivalence class including
in the theory of commutative monoids.
We can also find examples beyond monad morphisms to show the greater generality is useful.
Example: For every monad, the multiplication is both:
- A Kleisli law of type
.
- An Eilenberg-Moore law of type
.
Up to the isomorphisms discussed in the earlier example:
- The induced functor
is the usual Kleisli forgetful functor.
- The induced functor
is the usual Eilenberg-Moore free functor.
Finally, we sketch a key source of examples that needs proper account at a later date.
Example: For a pair of monads on the same base category, a natural transformation:
which is simultaneously an Eilenberg-Moore and a Kleisli is known as a distributive law. This is an important notion, introduced by Beck, which allows us to build up monads in a principled way, by composing other monads together. Given such a , the endofunctor
carries the structure of a monad in a particularly well-behaved way. (In general, composing the underlying functors of two monads can result in a functor that carries no monad structure at all).
The existence of suitable distributive laws allows us to work with monads in a modular fashion. This topic is too important to skim over, so we shall postpone further discussions until more detailed future posts.