Skip to content

Instantly share code, notes, and snippets.

@abiodun0
Last active June 22, 2017 04:38
Show Gist options
  • Select an option

  • Save abiodun0/9fa6d70b8fd2f1dfc727e33355d1829d to your computer and use it in GitHub Desktop.

Select an option

Save abiodun0/9fa6d70b8fd2f1dfc727e33355d1829d to your computer and use it in GitHub Desktop.
withingFuncton
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