Last active
June 22, 2017 04:38
-
-
Save abiodun0/9fa6d70b8fd2f1dfc727e33355d1829d to your computer and use it in GitHub Desktop.
withingFuncton
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 run = Symbol('run'); | |
| const map = Symbol('map'); | |
| const ask = Symbol('ask'); | |
| const of = Symbol('of'); | |
| const flatmap = Symbol('flatmap'); | |
| Function[of] = function(x) { return _ => x; }; | |
| Function.prototype[flatmap] = function(f) { | |
| return s => f(this(s))(s); | |
| }; | |
| Function.prototype[run] = function (env) { | |
| return this(env); | |
| }; | |
| Function.prototype[map] = function (f) { | |
| return x => f(this(x)); | |
| }; | |
| Function[ask] = () => x => x; | |
| const append: any = (str: string) => | |
| Reader(R.identity) | |
| .map((env: any) => R.concat(str, env)); | |
| Reader.ask().map((env: string) => R.concat(str, env)); | |
| Reader((env: string) => R.concat(str, env)); | |
| Reader(R.identity) | |
| .map((env: any) => R.concat(str, env)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment