Skip to content

Instantly share code, notes, and snippets.

@fudini
Last active August 29, 2015 14:07
Show Gist options
  • Save fudini/15b8835e7fb51b4c7312 to your computer and use it in GitHub Desktop.
Save fudini/15b8835e7fb51b4c7312 to your computer and use it in GitHub Desktop.
// is it a monad?
var x = 1,
fn = x => x + 1,
gn = x => x * 2
var law1 = new Maybe(x).bind(fn).return() == new Maybe(fn(x)).return()
console.log(law1)
var law2 = new Maybe(x).bind(x => x).return() == new Maybe(x).return()
console.log(law2)
var law3 = new Maybe(x).bind(fn).bind(gn).return() ===
new Maybe(x).bind(x => gn(fn(x))).return()
console.log(law3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment