monads and adjunctions
Monads
You should know: functors, natural transformations, adjoint functors
Overview
A monad is a triple (T, η, μ) consisting of an endofunctor T : C → C and two natural transformations — the unit η : Id ⇒ T and the multiplication μ : T² ⇒ T — satisfying associativity and unit laws. Monads unify constructions as diverse as free algebras, powerset, probability distributions, and computational effects (in Haskell). Every adjunction gives rise to a monad, and conversely every monad arises from an adjunction (via the Kleisli or Eilenberg–Moore construction).
Intuition
Think of a monad as a 'box' with two operations: one to put a value in the box (unit η), and one to flatten a nested box into a single box (multiplication μ). The Maybe monad boxes a value that might not exist; the List monad boxes multiple possible values. The monad laws ensure that boxing and flattening behave consistently — nesting doesn't matter and the unit is a neutral element for flattening.
Formal Definition
A monad on a category C is a triple (T, η, μ) where T : C → C is a functor, η : Id_C ⇒ T is the unit, and μ : T ∘ T ⇒ T is the multiplication, satisfying the following commutative diagrams (monad laws).
Flattening from the left or right gives the same result
The unit is a two-sided identity for multiplication
Notation
| Notation | Meaning |
|---|---|
| The endofunctor of the monad | |
| Unit natural transformation Id ⇒ T | |
| Multiplication natural transformation T² ⇒ T | |
| Kleisli composition of two Kleisli morphisms |
Properties
Every adjunction yields a monad
Condition: F ⊣ G an adjunction
Eilenberg–Moore algebras
Beck's monadicity theorem
Worked Examples
Define the powerset functor: for f : A → B, Pf(S) = {f(a) | a ∈ S}.
The unit η_A : A → PA sends each element to its singleton.
The multiplication μ_A : PPA → PA takes a set of subsets and unions them.
Verify associativity: μ ∘ Pμ = μ ∘ μP. Both sides take a set of sets of sets and flatten it to a set — order doesn't matter since union is associative.
A Kleisli morphism A → PB is a relation (multi-valued function). The Kleisli category of P is the category Rel of sets and relations.
Answer: The powerset monad has unit η_A(a) = {a} and multiplication μ_A = ∪. Its Kleisli category is the category of sets and relations.
Practice Problems
Let T = (−) × M for a monoid (M, e, ·) in Set. Define natural transformations η and μ making T a monad, and verify one monad law.
Describe the Kleisli category of the Maybe monad on Set. What are the objects and morphisms, and what is composition?
State Beck's monadicity theorem and use it to show that the forgetful functor U : Ab → Set (abelian groups to sets) is monadic.
Common Mistakes
A monad is just a functor
A monad is a functor equipped with two natural transformations (unit and multiplication) satisfying coherence laws. The extra structure is essential.
All endofunctors are monads
An endofunctor can fail to admit unit/multiplication natural transformations satisfying the monad laws; additional structure must be specified.
Kleisli and Eilenberg–Moore categories are the same
Both arise from a monad but are generally different: the Kleisli category is the 'free' construction while Eilenberg–Moore is the 'complete' one; there is a canonical functor Kl(T) → EM(T).
Quiz
Historical Background
Monads were introduced by Roger Godement in 1958 under the name 'standard constructions'. Eilenberg and Moore studied the algebras of a monad (now called Eilenberg–Moore algebras) in 1965. Kleisli introduced an alternative category in 1965 as well. The term 'monad' was popularized by Saunders Mac Lane. Eugenio Moggi's 1991 paper showed monads model computational effects, making them fundamental in functional programming.
- 1958
Godement introduces 'standard constructions' (monads)
Roger Godement
- 1965
Eilenberg–Moore algebras and Kleisli category defined
Samuel Eilenberg, John Moore, Heinrich Kleisli
- 1991
Moggi uses monads to model computational effects
Eugenio Moggi
- 1992
Wadler popularises monads in functional programming
Philip Wadler
Summary
- A monad (T, η, μ) on C is an endofunctor with a unit η : Id ⇒ T and multiplication μ : T² ⇒ T satisfying associativity and unit laws.
- Every adjunction F ⊣ G yields a monad T = GF; conversely every monad arises from two adjunctions — Kleisli and Eilenberg–Moore.
- The Kleisli category Kl(T) has the same objects as C; morphisms A → B are C-morphisms A → TB composed via μ.
- Eilenberg–Moore T-algebras generalise the notion of 'module over T'; e.g., free-monoid monad gives monoids, free-abelian-group monad gives abelian groups.
- Monads model computational effects in functional programming: Maybe (partiality), List (non-determinism), State, IO, etc.
References
- BookMac Lane, S. — Categories for the Working Mathematician, 2nd ed., Ch. VI
- BookRiehl, E. — Category Theory in Context, Ch. 5
- PaperMoggi, E. — Notions of Computation and Monads (1991)
Mathematics