Last active
January 30, 2019 15:05
-
-
Save serhiiminin/9ed74b63b9d733dc3cfcd39851c05dfc 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
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