Skip to content

Instantly share code, notes, and snippets.

@dewey92
Created April 23, 2018 13:27
Show Gist options
  • Select an option

  • Save dewey92/21f1766f2a45ade408d274ff3b3c4404 to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/21f1766f2a45ade408d274ff3b3c4404 to your computer and use it in GitHub Desktop.
Bind Reader
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