Algebras for a Monad — Eilenberg–Moore and Kleisli

Summary

Every monad on arises from an adjunction — in two canonical, universal ways. A -algebra is a pair whose action satisfies a unit law and an associativity law ; these form the Eilenberg–Moore category (the category of -algebras), with a free forgetful adjunction recovering . The Kleisli category has the same objects as but morphisms , and gives another adjunction recovering ; it is (equivalent to) the full subcategory of free -algebras. Among all adjunctions inducing , Kleisli is initial and Eilenberg–Moore is terminal, and the comparison functor is full and faithful with image the free algebras.

Overview

Lemma 5.1.3 shows every adjunction induces a monad. Conversely, every monad arises from an adjunction: “perhaps surprisingly, the answer is yes — and from two (typically distinct) adjunctions that are moreover universal with this property.” A monad is a syntactic presentation of algebraic structure; its algebras are the actual structured objects (e.g. for the free-monoid monad, the algebras are monoids). This note gives both constructions and the comparison between them; whether the comparison to is an equivalence is the subject of Beck’s Monadicity Theorem.

Main Content

-algebra and the Eilenberg–Moore category (Definition 5.2.4)

Let be a monad on . The Eilenberg–Moore category , or category of -algebras, has:

  • objects = pairs ( is the algebra structure map) such that the diagrams (5.2.5) commute:
    • unit: ( equals the identity);
    • associativity: ;
  • morphisms = -algebra homomorphisms: maps in such that the square commutes, .

Composition and identities are as in .

Free -algebra and the free functor (Definition 5.2.8)

For each the free -algebra is ; the algebra axioms (5.2.5) hold by the monad’s own unit and associativity laws. This is functorial: the free functor sends and to the homomorphism (a homomorphism by naturality of ).

Eilenberg–Moore adjunction (Lemma 5.2.9)

For any monad on there is an adjunction

whose underlying monad is . Here is the forgetful functor and is the free functor; note . The unit is , and the counit has components given by the algebra structure map itself:

In particular , so the monad underlying is exactly .

Kleisli category (Definition 5.2.10)

The Kleisli category is defined by:

  • objects = the objects of ;
  • morphisms = morphisms in .

The identity on is . The composite of with is the Kleisli composite

(Associativity and unitality of this composition are the monad laws.)

Kleisli adjunction (Lemma 5.2.12)

For any monad on there is an adjunction whose underlying monad is . The left adjoint is the identity on objects and sends to ; the right adjoint sends and a Kleisli map (i.e. ) to . The hom-set isomorphism is , both .

Universal property: Kleisli initial, Eilenberg–Moore terminal (Proposition 5.2.13)

Let be the category of adjunctions that induce the monad on (morphisms = functors commuting with both adjoints). Then the Kleisli adjunction is initial and the Eilenberg–Moore adjunction is terminal: for any inducing there exist unique functors

commuting with the left and right adjoints.

The comparison functor (Lemma 5.2.14)

The canonical comparison functor (from Prop 5.2.13, ) is full and faithful, and its image consists exactly of the free -algebras: . Thus the Kleisli category embeds as the full subcategory of free -algebras and all maps between them. Consequently iff every algebra is free — e.g. for the free vector space monad (every vector space is free on a basis), or the maybe monad ().

Examples

Algebras = the expected structured objects

  • Free-monoid (list) monad (Example 5.2.6(iii) / p. 188): a -algebra is a set with an -ary operation for each (a map ); the unit law forces the unary operation to be the identity and the associativity square forces the operations to come from a single associative binary operation with unit. The category of algebras is isomorphic to .
  • Maybe monad (Example 5.2.6(i)): a -algebra is a set with a chosen basepoint (the image of ); .
  • monad on (Example 5.2.6(ii)): an algebra is an -module.
  • Affine-combination monad (Definition 5.2.3): an algebra is precisely an affine space.
  • Closure operator (Example 5.2.6(iv)): an algebra for the closure operator on subsets of a space is exactly a closed subset; dually a coalgebra for the interior operator is an open subset.

Kleisli categories in computation

  • Maybe monad (Example 5.2.11(i)): Kleisli maps are partially-defined functions ; .
  • Free-monoid monad (5.2.11(ii)): a Kleisli map is a function (each input yields a list of outputs).
  • State monad (5.2.11(iii)): a Kleisli map is a function — input + current state ↦ output + updated state; this models stateful computation (“side effects”) in functional languages.
  • Giry monad (5.2.11(iv)): Kleisli maps are Markov kernels; an endomorphism is a discrete-time Markov chain.

Connections

  • Definitions reuse the monad laws: the algebra axioms of Definition 5.2.4 are the monad’s own unit & associativity laws, now for an action rather than .
  • Closes the loop with Adjunctions Induce Monads: both and have underlying monad , proving every monad comes from an adjunction.
  • Sets up monadicity: an adjunction is monadic exactly when its comparison is an equivalence — see Beck’s Monadicity Theorem. For an idempotent monad, is a reflective subcategory and (Proposition 5.3.3, Exercise 5.3.i).
  • Canonical presentations (§5.4): every algebra is a coequalizer of free algebras (Proposition 5.4.2) — the categorical “generators and relations.” See Beck’s Monadicity Theorem.

See Also