Skip to content

Instantly share code, notes, and snippets.

@dewey92
Last active April 25, 2018 07:26
Show Gist options
  • Select an option

  • Save dewey92/9c554bf881ae12de121729386e9d7c5e to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/9c554bf881ae12de121729386e9d7c5e to your computer and use it in GitHub Desktop.
Bind Reader
bind<A, B>(f: (v: A) => Functor<B>, functorA: Functor<A>): Functor<B>
// for Reader, it should be
bind<D, A, B>(f: (v: A) => Reader<D, B>, readerA: Reader<D, A>): Reader<D, B>
// Hindley-Milner style
// bind :: (a -> f b) -> f a -> f b
// bind :: (a -> Reader d b) -> Reader d a -> Reader d b
// karena (Reader d b) adalah (d -> b), maka
// bind :: (a -> d -> b) -> (d -> a) -> (d -> b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment