Previously, we have encountered various structures involving monads, such as Eilenberg-Moore algebras, Kleisli and Eilenberg-Moore laws, and distributive laws. In this post, we encounter another such structure, monad actions. These are less frequently discussed, but useful and relatively simple constructions. Conceptually, they sit somewhere between Eilenberg-Moore algebras and distributive laws.

## Introducing actions

For a monad , a left action of on a functor is a natural transformation:

such that the following two axioms hold:

- The
**unit axiom**: - The
**multiplication axiom**:

Actions are also sometimes called modules in the literature, although there is some inconsistency in the use of this term, so we shall avoid it.

**Remark**: For those who have encountered them before, there is a close analogy between a left action of a monad on a functor, and the action of a monoid (or perhaps more commonly a group) on a set. In fact, at an appropriate level of abstraction, they are both instances of the same construction.

We begin with what is probably the motivating example.

**Example**: For any Eilenberg-Moore algebra

we can consider the functor from the terminal category, which picks out the object . We use the same name for both the object and the corresponding functor, as both provide essentially the same data. From this perspective, is a natural transformation . The axioms for an Eilenberg-Moore algebra exactly correspond to this natural transformation being a left monad action.

So Eilenberg-Moore algebras are a special case of left monad actions. There are of course more general examples:

**Example**: Let be the non-empty multiset monad, and for let denote the functor forming collections of multisets of at least elements. Taking unions of multisets induces a monad action:

.

Every set induces an Eilenberg-Moore algebra:

**Example**: Let be the list monad, and be the functor mapping a set to the collection of even length lists of its elements. There is a left monad action:

given by list concatenation. Again, every set induces an Eilenberg-Moore algebra:

The previous two examples show that more general left actions can be seen as encoding a uniform family of Eilenberg-Moore algebras.

The notion of left monad action can be dualised. For an endofunctor

a right monad action is a natural transformation:

such that the following two axioms hold:

- The
**unit axiom**: - The
**multiplication axiom**:

We could go further and consider natural transformations where monads act on both the left and right, commonly referred to as bimodules. We could also dualise and consider both left and right (co)actions of comonads, although we shall resist the temptation to explore these related topics for now. For the rest of this post, we shall primarily focus on left actions of monads.

## Building Monad Actions

So far, we have seen some reasonably ad-hoc looking examples of left monad actions. The only procedure we have for constructing monad actions is to view any Eilenberg-Moore algebra as a left action.

For a monad as before, there are several more methods for systematically construction monad actions. For example:

- The monad multiplication is a left (and right) monad action.
- For , and , if is a left monad action, then so is .
- If is a monad action, a a monad morphism, then is a left action of .

There are other methods, involving adjunctions and Kan extensions, but the constructions above are enough for our remaining discussions.

## Monad Actions and Morphisms

Given any monad morphism

using two of the constructions in the previous section, we can build a monad action

In fact, the resulting actions are special. They satisfy an extra **compatibility axiom**:

For any action

satisfying the compatibility axiom, the composite

is a monad morphism. Furthermore, these two mapping exhibit a bijection between monad morphisms and monad actions satisfying the compatibility axiom. This handy relationship often allows us to move back and forth between the monad morphism and action perspectives as suites our needs.

## Monad Actions and Laws

Given a left monad action , and any other monad , we can form the composite:

It is not hard to verify that this is in fact an Eilenberg-Moore law. Forming the dual composite for a right action will yield a Kleisli law.

The point of these two simple constructions is that monad actions can be built and combined in various ways, and this now gives us a new route to building Eilenberg-Moore and Kleisli laws, which have many uses.

## Conclusion

Although monad actions are perhaps a slightly more obscure aspect of monad theory than some of the topics we have covered, they are nonetheless useful. Verifying many of the claims above is straightforward, particularly if done using string diagrams, and monad actions interact well with string diagrammatic techniques. Monad actions will also prove handy tools in some future posts. From the point of view of computer science, they seem to be an under-investigated topic, ripe for further exploration.

**Further reading**: “Modules over Monads and their Algebras” by Piróg, Wu and Gibbons is an excellent computer science oriented source for background, and helped greatly with the examples in this post. The article prefers the term module rather than action, but hopefully this wont be too distracting in relating the ideas to our discussions. They also give nice examples of right actions, which we have paid less attention, interpreting them as computations in context.

## 2 thoughts on “Monad Actions”