Last active
April 14, 2020 19:07
-
-
Save UserGalileo/78467948813c635a37dfaa1f8eb27d6b to your computer and use it in GitHub Desktop.
Extracting Composition
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
// Pointfree utility for "chain" | |
const chain = fn => a => a.chain(fn); | |
// generic composition operation | |
const op = (f1, f2) => compose(chain(f2), f1) | |
// just to demonstrate, here's the non-generic way of composing our two functions | |
const op2 = compose(chain(g), f); | |
// Now we can compose our functions! | |
const f_g = op(f, g); | |
// Let's get the result! | |
const result = f_g('a'); | |
// Identity(a12) | |
inspect(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment