Skip to content

Instantly share code, notes, and snippets.

@serhiiminin
Last active January 30, 2019 15:05
Show Gist options
  • Save serhiiminin/9ed74b63b9d733dc3cfcd39851c05dfc to your computer and use it in GitHub Desktop.
Save serhiiminin/9ed74b63b9d733dc3cfcd39851c05dfc to your computer and use it in GitHub Desktop.
class Wrapper {
constructor(value) {
this._value=value;
}
map(f) {
return f(this._value);
}
fmap(f) {
return new Wrapper(f(this._value));
}
}
const wrap = v => new Wrapper(v);
const plus = a => b => a+b;
const plus3 = plus(3);
const two = wrap(2);
console.log(two.fmap(plus3).map(v => v));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment