https://en.wikipedia.org/wiki/Monad_(functional_programming)#Definition
Given any well-defined, basic types T, U, a monad consists of three parts:
- A type constructor $M$ that builds up a monadic type $M T$
A type converter, often called $unit$ or $return$, that embeds an object $x$ in the monad:
$$unit(x) : T → M T$$
A combinator, typically called $bind$ (as in binding a variable) and represented with an infix operator $>>=$, that unwraps a monadic variable, then inserts it into a monadic function/expression, resulting in a new monadic value: $$(mx >>= f) : (M T, T → M U) → M > U$$
To fully qualify as a monad though, these three parts must also respect a few laws:
- $unit$ is a left-identity for $bind$: $$unit(a) >>= λx → f(x) ↔ f(a)$$
- $unit$ is also a right-identity for $bind$: $$ma >>= λx → unit(x) ↔ ma$$
- $bind$ is essentially associative: $$ma >>= λx → (f(x) >>= λy → g(y)) ↔ (ma >>= λx → f(x)) >>= λy → g(y)$$
Algebraically, this means any monad both gives rise to a category (called the Kleisli category) and a monoid in the category of functors (from values to computations), with monadic composition as a binary operator and unit as identity.
Questions:
What is the "category" given rise to by a monad? Specifically, what are the objects and morphisms in the "category"?
What is the monoid given rise to by a monad? When the quote says "a monoid in the category of functors (from values to computations)", what does it mean by "a monoid in the category of functors" and "functors (from values to computations)"?
Thanks.