Open mepcotterell opened 3 years ago
https://en.wikipedia.org/wiki/Monad_(functional_programming)
Monad
Minimum required functionality:
M(x).bind(f).value == f(x).value
M(x).bind(M).value == M(x).value
M(x).bind(f).bind(g).value == M(x).bind(x => f(x).bind(g)).value
const gaius = require('gaius'); const M = gaius.Monad;
const nums = M([0, 1, 2, 3]).map(n => n+1).bind(Array.from);
const id = x => x; const num = M(41).map(n => n+1).bind(id);
https://en.wikipedia.org/wiki/Monad_(functional_programming)
Monad
class.Monad
class.Monad
class.Minimum required functionality:
M(x).bind(f).value == f(x).value
M(x).bind(M).value == M(x).value
M(x).bind(f).bind(g).value == M(x).bind(x => f(x).bind(g)).value