Skip to content

Instantly share code, notes, and snippets.

@ulfryk
Last active February 23, 2016 13:52
Show Gist options
  • Save ulfryk/b026f807dae799dbc328 to your computer and use it in GitHub Desktop.
Save ulfryk/b026f807dae799dbc328 to your computer and use it in GitHub Desktop.
JS Promisees vs. Monads
// Axioms
unit(value).bind(f) <=> f(value);
monad.bind(unit) == monad;
monad.bind(f).bind(g) == monad.bind(value => f(value).bind(g))
// Promise
Promise.resolve(value).then(f) <=> f(value)
promise.then(Promise.resolve) == promise
promise.then(f).then(g) != promise.then(value => f(value).then(g)) // f for promises can return value or promise - fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment