Skip to content

Instantly share code, notes, and snippets.

@UserGalileo
Created April 14, 2020 17:55
Show Gist options
  • Save UserGalileo/a020ea5d351d2866b262d89ebbc07573 to your computer and use it in GitHub Desktop.
Save UserGalileo/a020ea5d351d2866b262d89ebbc07573 to your computer and use it in GitHub Desktop.
Functors Monoid
// a -> a (could return whatever)
const f = n => n + 1;
// a -> M a
const g = x => Identity(x);
// Composition gives us Identity(2)
g(1).map(f)
// We could extract the composition here too:
const op = (f1, f2) => compose(map(f2), f1);
// Composition gives us Identity(2)
op(g, f)(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment