Skip to content

Instantly share code, notes, and snippets.

@humanhighway
Created February 7, 2021 09:40
Show Gist options
  • Save humanhighway/6398398a99edfc9dd111dea03e490c1f to your computer and use it in GitHub Desktop.
Save humanhighway/6398398a99edfc9dd111dea03e490c1f to your computer and use it in GitHub Desktop.
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