Introduction
Category
Examples of Categories
More Examples
Extra Material
Functor
Examples of Functors
More Examples
Natural Transformation
Examples
More Examples
Monad
Monad Examples
More Examples Exception Monad
State Machine Monad
State Machine (cont'd)
Monads in Programming References
Haskell IO |
- For any category C an identity monad can be defined. It consists of an identity functor and identity morphisms.
- Suppose we have a group G. Let's define a monad MG in Set. The monad functor will be like this:
X ↦ X × G.
u(X) : X → X × G maps an element x to a pair (x,e), where e is the group's unit.
MG(MG(X)) = (idX,mG), where mG is the group multiplication.
- Lists in Set. For a set X the result of applying the functor, let's call it List, is the set of all lists, (x1,x2,x3...), including the empty one, of elements of X. This functor becomes a popular monad if we add u and m. Let uX : X → List(X) create a single-element list for each x∊X. And mX: List(List(X)) → List(X) maps lists of lists to plain lists by flattening them
|
|