Created
February 7, 2021 09:40
-
-
Save humanhighway/6398398a99edfc9dd111dea03e490c1f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Box = (x) => ({ | |
| map: f => Box(f(x)), // always return Box type. | |
| fold: (f) => f(x), // unwarp value | |
| }) | |
| const result= Box(10) | |
| .map((x) => x * 2) | |
| .map((x) => x + 10) | |
| .fold(x => x); | |
| console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment