According to John Baez, a monad can be considered at least in two ways: [1] Monads are used in the theory of pairs of adjoint functors, and they generalize closure operators on partially ordered sets to arbitrary categories.
[2] We had some time to talk, and during the course of it I realized I’d become less scared of certain topics involving monads.
The monad theory matters as part of the effort to capture what it is that adjunctions 'preserve'.
, or see below the commutative diagrams not using these notions: The first axiom is akin to the associativity in monoids if we think of
as the monoid's binary operation, and the second axiom is akin to the existence of an identity element (which we think of as given by
and whose morphisms are the natural transformations between them, with the monoidal structure induced by the composition of endofunctors.
be the function between the power sets induced by taking direct images under
to itself, with a set of axioms for counit and comultiplication that come from reversing the arrows everywhere in the definition just given.
The notion of monad was invented by Roger Godement in 1958 under the name "standard construction".
Monad has been called "dual standard construction", "triple", "monoid" and "triad".
Any adjunction gives rise to a monad on C. This very widespread construction works as follows: the endofunctor is the composite This endofunctor is quickly seen to be a monad, where the unit map stems from the unit map
The associated monad sends a vector space V to its double dual
), then the formalism becomes much simpler: adjoint pairs are Galois connections and monads are closure operators.
Further, the multiplication of this monad is the map made out of a natural concatenation or 'flattening' of 'strings of strings'.
Thus, every such type of algebra gives rise to a monad on the category of sets.
The endofunctor of the maybe or partiality monad adds a disjoint point:[8] The unit is given by the inclusion of a set
, the endofunctor of the reader or environment monad maps each set
In functional programming and denotational semantics, the environment monad models computations with access to some read-only data.
In functional programming, the list monad is used to model nondeterministic computations.
subject to axioms resembling the behavior of convex linear combinations
However, there are usually several distinct adjunctions giving rise to a monad: let
An initial object is the Kleisli category, which is by definition the full subcategory of
For example, the forgetful functor from the category of compact Hausdorff spaces to sets is monadic.
[12] The dual version of Beck's theorem, characterizing comonadic adjunctions, is relevant in different fields such as topos theory and topics in algebraic geometry related to descent.
This adjunction is comonadic, by Beck's theorem, if and only if B is faithfully flat as an A-module.
It thus allows to descend B-modules, equipped with a descent datum (i.e., an action of the comonad given by the adjunction) to A-modules.
The resulting theory of faithfully flat descent is widely applied in algebraic geometry.
Monads are used in functional programming to express types of sequential computation (sometimes with side-effects).
See monads in functional programming, and the more mathematically oriented Wikibook module b:Haskell/Category theory.
Monads are used in the denotational semantics of impure functional and imperative programming languages.