Last active
July 4, 2017 09:22
-
-
Save dewey92/eeebd2a88359cc88fe3c644a84a826a1 to your computer and use it in GitHub Desktop.
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
| // composeK :: Monad m => ((y → m z), (x → m y), …, (a → m b)) → (a → m z) | |
| const composeK = (...fns) => init => { | |
| if (!fns.length) throw new Error('Need at least 1 argument') | |
| const lastArg = fns.pop(); | |
| return fns.reduceRight((acc, x) => acc.bind(x), lastArg(init)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment