Examples
Given any monad
, the option monad transformer
(where
denotes the option type) is defined by:

Given any monad
, the exception monad transformer
(where E is the type of exceptions) is defined by:

Given any monad
, the reader monad transformer
(where E is the environment type) is defined by:

Given any monad
, the state monad transformer
(where S is the state type) is defined by:

Given any monad
, the writer monad transformer
(where W is endowed with a monoid operation ∗ with identity element
) is defined by:

Given any monad
, the continuation monad transformer maps an arbitrary type R into functions of type
, where R is the result type of the continuation. It is defined by:

Note that monad transformations are usually not commutative: for instance, applying the state transformer to the option monad yields a type
(a computation which may fail and yield no final state), whereas the converse transformation has type
(a computation which yields a final state and an optional return value).
This page is based on this
Wikipedia article Text is available under the
CC BY-SA 4.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.