Content deleted Content added
m →Definition: Added link to kind (type theory) |
No edit summary |
||
Line 30:
== Examples ==
=== The option monad transformer ===
Given any monad <math>\mathrm{M} \, A</math>, the option monad transformer <math>\mathrm{M} \left( A^{?} \right)</math> (where <math>A^{?}</math> denotes the [[option type]]) is defined by:
*<math>\mathrm{return}: A \rarr \mathrm{M} \left( A^{?} \right) = a \mapsto \mathrm{return} (\mathrm{Just}\,a)</math>
*<math>\mathrm{bind}: \mathrm{M} \left( A^{?} \right) \rarr \left( A \rarr \mathrm{M} \left( B^{?} \right) \right) \rarr \mathrm{M} \left( B^{?} \right) = a \mapsto f \mapsto \mathrm{bind} \, a \, \left(a' \mapsto \begin{cases} \mbox{return Nothing} & \mbox{if } a' = \mathrm{Nothing}\\ f \, a'' & \mbox{if } a' = \mathrm{Just} \, a'' \end{cases} \right)</math>
*<math>\mathrm{lift}: \mathrm{M} (A) \rarr \mathrm{M} \left( A^{?} \right) = m \mapsto \mathrm{bind} \, m \, (x \mapsto \mathrm{return} (\mathrm{Just} \, x))</math>
== See also ==
|