Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader contravariant on input type A #2922

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ final case class Kleisli[F[_], -A, B](run: A => F[B]) { self =>
def tapWithF[C, AA <: A](f: (AA, B) => F[C])(implicit F: FlatMap[F]): Kleisli[F, AA, C] =
Kleisli(a => F.flatMap(run(a))(b => f(a, b)))

def toReader[AA <: A]: Reader[AA, F[B]] = Kleisli[Id, AA, F[B]](run)
def toReader: Reader[A, F[B]] = Kleisli[Id, A, F[B]](run)

def apply(a: A): F[B] = run(a)
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ package object data {
type NonEmptyChain[+A] = NonEmptyChainImpl.Type[A]
val NonEmptyChain = NonEmptyChainImpl

type ReaderT[F[_], A, B] = Kleisli[F, A, B]
type ReaderT[F[_], -A, B] = Kleisli[F, A, B]
val ReaderT = Kleisli

type Reader[A, B] = ReaderT[Id, A, B]
type Reader[-A, B] = ReaderT[Id, A, B]

object Reader {
def apply[A, B](f: A => B): Reader[A, B] = ReaderT[Id, A, B](f)
Expand Down