Let ⟨T, η, μ⟩ be a monad over a category C. The Kleisli category of C is the category CT whose objects and morphisms are given by
That is, every morphism f: X → T Y in C (with codomain TY) can also be regarded as a morphism in CT (but with codomain Y). Composition of morphisms in CT is given by
where f: X → T Y and g: Y → T Z. The identity morphism is given by the monad unit η:
An alternative way of writing this, which clarifies the category in which each object lives, is used by Mac Lane.1 We use very slightly different notation for this presentation. Given the same monad and category C {\displaystyle C} as above, we associate with each object X {\displaystyle X} in C {\displaystyle C} a new object X T {\displaystyle X_{T}} , and for each morphism f : X → T Y {\displaystyle f\colon X\to TY} in C {\displaystyle C} a morphism f ∗ : X T → Y T {\displaystyle f^{*}\colon X_{T}\to Y_{T}} . Together, these objects and morphisms form our category C T {\displaystyle C_{T}} , where we define composition, also called Kleisli composition, by
Then the identity morphism in C T {\displaystyle C_{T}} , the Kleisli identity, is
Composition of Kleisli arrows can be expressed succinctly by means of the extension operator (–)# : Hom(X, TY) → Hom(TX, TY). Given a monad ⟨T, η, μ⟩ over a category C and a morphism f : X → TY let
Composition in the Kleisli category CT can then be written
The extension operator satisfies the identities:
where f : X → TY and g : Y → TZ. It follows trivially from these properties that Kleisli composition is associative and that ηX is the identity.
In fact, to give a monad is to give a Kleisli triple ⟨T, η, (–)#⟩, i.e.
such that the above three equations for extension operators are satisfied.
Kleisli categories were originally defined in order to show that every monad arises from an adjunction. That construction is as follows.
Let ⟨T, η, μ⟩ be a monad over a category C and let CT be the associated Kleisli category. Using Mac Lane's notation mentioned in the “Formal definition” section above, define a functor F: C → CT by
and a functor G : CT → C by
One can show that F and G are indeed functors and that F is left adjoint to G. The counit of the adjunction is given by
Finally, one can show that T = GF and μ = GεF so that ⟨T, η, μ⟩ is the monad associated to the adjunction ⟨F, G, η, ε⟩.
For any object X in category C:
For any f : X → Y {\displaystyle f:X\to Y} in category C:
Since ( G ∘ F ) ( X ) = T X {\displaystyle (G\circ F)(X)=TX} is true for any object X in C and ( G ∘ F ) ( f ) = T f {\displaystyle (G\circ F)(f)=Tf} is true for any morphism f in C, then G ∘ F = T {\displaystyle G\circ F=T} . Q.E.D.
Mac Lane (1998). Categories for the Working Mathematician. p. 147. ↩