Created
April 14, 2020 17:55
-
-
Save UserGalileo/a020ea5d351d2866b262d89ebbc07573 to your computer and use it in GitHub Desktop.
Functors Monoid
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
// 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