What is a Monad?
In this post, we provide the minimal category theory background that is required to define a monad.
Definition of a Category
A category contains the following:
- Objects: A sequence of objects, denoted by :
- Arrows: A sequence of arrows denoted by
The above satisfy the following properties:
- For each arrow , there exist objects and called the domain and codomain of , respectively. We write to indicate and .
- For any two arrows and , there is an arrow called the composite of and .
- For each object , there exist the identity arrow
- Associativity:
- Unit: for every arrow
Functor
A homomorphism of categories is called a functor. More precisely, we call between two categories and , a functor iff:
- Arrow preservation:
- Identity preservation: for every
- Composition preservation:
That is, preserves domains and codomains, identity arrows, and composition.
Natural transformations
Let functors .
A natural transformation from to is an assignment to every object of a morphism in such that for every morphism in we have:
in
Monad
If is a category, a monad on is defined as an endfunctor equipped with two natural transformations:
The above natural transformations must satisfy: (a) and (b)
References
Written on March 20, 2016