Algebras for a Monad
An algebra for a monad is an object with a structure map that interacts correctly with the unit and multiplication. The algebras form the Eilenberg–Moore category, whose free–forgetful adjunction induces the monad back; a comparison functor relates any other inducing adjunction to it, and for the list monad the algebras are exactly monoids.
╌╌╌╌
A monad on was built to be the trace of an adjunction, but the definition never mentions one. Every monad does arise from an adjunction, and the construction that proves it also identifies the structure a monad describes: its algebras, objects equipped with a map that evaluates -structure. The category they form, due to Eilenberg and Moore, carries a free–forgetful adjunction inducing exactly .1
For the list monad an algebra is a set with a way of multiplying out any finite list of its elements, subject to consistency laws that make it a monoid. Monads in this sense present universal algebra through arrows.
Algebras and their axioms
The two axioms mirror the two monad laws, one level down.
- Unit axiom. An element inserted into as a trivial structure by must evaluate to itself. For the list monad: evaluating the singleton list returns .
- Associativity axiom. Given a doubly-nested structure in , the two ways of evaluating it — flatten first with , or evaluate the inner layer first with — must agree.
Barr & Wells distinguish an algebra for the endofunctor (any pair with , no axioms) from an algebra for the monad, which is an endofunctor algebra satisfying the two laws above.2 The unconstrained version has its own theory, taken up in algebras for an endofunctor; here the laws tie evaluation to the monad's unit and multiplication.
Composition and identities are inherited from , so the -algebras and their morphisms form a category.
Algebras of the list monad are monoids
Let be the list monad on : , unit , multiplication = concatenation. An algebra is a set with a map evaluating every finite list to an element. Define a binary operation and a constant by
The algebra axioms force to be a monoid, and conversely every monoid gives an algebra by -fold multiplication.3
- Unit axiom gives : singleton lists evaluate trivially.
- Associativity axiom applied to the nested list gives , and applied to gives . Both products equal the flat evaluation, hence each other.
- Unit element. The same axiom on gives , and symmetrically .
Algebra morphisms are exactly monoid homomorphisms: commuting with on two-element lists is preserving the product, and on the empty list is preserving the unit. So .
The pattern generalizes far beyond lists. A theorem of Linton states that every equationally defined category of one-sorted algebraic structures — groups, rings, modules over a fixed ring, lattices — is equivalent to the Eilenberg–Moore category of some monad on ; the converse holds too if infinitary operations are permitted.4 Monads on and algebraic theories are two presentations of the same subject.
| Monad on | Its algebras | |
|---|---|---|
| list | monoids | |
| maybe | pointed sets | |
| writer over a monoid | -sets (sets with an -action) | |
| free group | reduced words over | groups |
| free -module | finite formal -combinations of | -modules |
The maybe row is worth checking by hand: a structure map satisfying the unit law is the identity on plus a choice of basepoint (the image of the extra point), and the associativity law is automatic. An algebra is a set with a distinguished element, and morphisms preserve it.
The writer row is the same computation for the representation monad of a monoid . A structure map is a binary operation . The unit axiom demands , since . For the associativity axiom, chase an element around the square: the route through gives , and the route through gives . The two axioms reproduce the two laws of a monoid action, so the algebras are -sets and their morphisms are the equivariant maps — recovering by pure diagram chasing the category that originally induced the monad.
The free–forgetful adjunction
The Eilenberg–Moore category resolves the monad into an adjunction.
- Forgetful functor sends and an algebra morphism to itself as an arrow of .
- Free functor sends and .
The pair is the free algebra on : its carrier is and its structure map is the monad multiplication. The algebra axioms for it restate the associativity and unit laws of the monad itself, so no new verification is needed: the monad laws are the statement that free algebras are algebras.
The unit of the adjunction is itself. The counit at an algebra is the structure map , viewed as an algebra morphism — the associativity axiom is what makes such a morphism. Composing, and , so the induced monad is the one we started with. Every monad therefore arises from at least one adjunction.
The comparison functor
The Eilenberg–Moore adjunction is not the only one inducing ; the Kleisli construction gives another, and concrete free–forgetful adjunctions (say, itself) give more. The Eilenberg–Moore category is universal among them from above: every inducing adjunction maps into it.
The structure map evaluates by the counit; its algebra axioms follow from the triangle identities and naturality. The comparison functor measures how close is to being the category of algebras.
Monadicity is the precise sense in which a category is algebraic over
a base.
The forgetful functors from , , and
to are monadic — that is the content of Linton's theorem read
through the comparison functor. The forgetful functor
has a left adjoint (the discrete-space functor)
but is not monadic: its induced monad is the identity, whose algebras are just
sets, and . A topology is structure but
not algebraic structure, and monadicity detects the difference.
Splitting an adjunction through its algebras
The factorization theorems recast the relationship between a monad and its sources. Given any adjunction inducing :
- the monad lives on and encodes the round trip;
- the Eilenberg–Moore category reconstructs from alone a canonical codomain, the largest one in a precise sense;
- the comparison functor places the original inside it.
Barr & Wells note a cultural split over this construction: in mathematics the Eilenberg–Moore category has been the more important of the two factorizations, while in computer science the Kleisli category dominates.6 The mathematical uses run through monadicity: proving a category is algebraic transfers limits, colimits, and exactness properties wholesale from the base. The computing uses run through free algebras and substitution, and the Kleisli category is the category of those free algebras.
Footnotes
- Barr & Wells, Category Theory for Computing Science, §14.4.2 — Eilenberg–Moore algebras: the definition of a -algebra by the two commuting diagrams, and the category . ↩
- Barr & Wells, §14.1.3 vs §14.4.2 — an algebra for an endofunctor is any ; a triple algebra is one satisfying the unit and associativity diagrams. ↩
- Barr & Wells, §14.4.5 Exercise 3 — algebras for the Kleene-closure (list) triple are precisely monoids, and algebra homomorphisms are monoid homomorphisms. ↩
- Barr & Wells, §14.4.3 (remark) — Linton's theorem: every equationally defined category of one-sorted algebraic structures is the category of Eilenberg–Moore algebras for a triple on . ↩
- Barr & Wells, §14.4.3 (Proposition) — is left adjoint to the underlying functor , and the associated triple is . ↩
- Barr & Wells, §14.4.2 —
In mathematics, this construction has been much more interesting than the Kleisli construction, but in computer science it has been quite the opposite.
↩
╌╌ END ╌╌