Idea
In category theory, a Kleisli category is a category associated with a monad that captures the notion of “computation with effects.” It provides a way to treat morphisms that return an object wrapped in a monad as regular arrows between objects.
Definition
Let be a monad on a category . The Kleisli category of , denoted , is defined as follows:
- Objects: The objects of are exactly the objects of . For every object , there is a corresponding object .
- Morphisms: A morphism in is defined as a morphism in the base category .
- Identity: For any object , the identity morphism in is the unit of the monad at in the base category: .
- Composition: Given morphisms and in (which are and in ), their Kleisli composition is defined using the monad multiplication :
The following diagram illustrates this composition in the base category :
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
X \arrow[r, "f"] \arrow[rr, "g \circ_T f", bend right=40] & TY \arrow[r, "Tg"] & T^2Z \arrow[r, "\mu_Z"] & TZ
\end{tikzcd}
\end{document}The Kleisli Adjunction
The Kleisli category is the “smallest” (initial) resolution of a monad into an adjunction. There exists a canonical adjunction between and :
- Free Functor :
- On objects: .
- On morphisms: (where ).
- Forgetful Functor :
- On objects: .
- On morphisms: (where in ).
This adjunction induces the original monad .
Significance
The Kleisli category is extensively used in computer science (particularly in functional programming) to model various computational effects such as state, exceptions, and non-determinism. Morphisms in the Kleisli category represent “effectful programs,” while the composition represents the sequential execution of these programs.