Skip to content

Instantly share code, notes, and snippets.

@adamw
Created December 12, 2016 11:00
Show Gist options
  • Save adamw/65eb05116de6628719f0c438c8fe6ee7 to your computer and use it in GitHub Desktop.
Save adamw/65eb05116de6628719f0c438c8fe6ee7 to your computer and use it in GitHub Desktop.
implicit def readerDistributive[I]: Distributive[({type R[X]=Reader[I, X]})#R] = new Distributive[({type R[X]=Reader[I, X]})#R] {
override def distributeImpl[G[_], A, B](fa: G[A])(f: (A) => Reader[I, B])(implicit gf: Functor[G]): Reader[I, G[B]] =
Reader { i =>
fa.map(a => f(a)(i))
}
override def map[A, B](fa: Reader[I, A])(f: (A) => B): Reader[I, B] = fa.map(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment