Skip to content

Instantly share code, notes, and snippets.

@victorvoid
Last active July 19, 2018 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorvoid/b7ff71364d0f6b591b26af53ba622ddd to your computer and use it in GitHub Desktop.
Save victorvoid/b7ff71364d0f6b591b26af53ba622ddd to your computer and use it in GitHub Desktop.
const Functor = x => ({
map: f => Functor(f(x)),
fold: f => f(x)
})
const app = (n) =>
Functor(n)
.map(n => n * 2)
.map(n => n + 1)
app(10)
.fold(console.log) //21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment