-
-
Save victorvoid/b7ff71364d0f6b591b26af53ba622ddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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