Created
April 23, 2018 13:27
-
-
Save dewey92/21f1766f2a45ade408d274ff3b3c4404 to your computer and use it in GitHub Desktop.
Bind Reader
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
| interface Reader<D, A> { | |
| (deps: D): A | |
| } | |
| // Hindley-Milner style: | |
| // Reader d a = d -> a | |
| const bind = <D, A, B>(f: (v: A) => Reader<D, B>, readerA: Reader<D, A>): Reader<D, B> => | |
| deps => f(readerA(deps))(deps) | |
| // ES6: | |
| // const bind = (f, reader) => deps => f(reader(deps))(deps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment