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

move Local instances into Ask companion #279

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import cats.{Applicative, Id}
import cats.data.{Kleisli, Reader}

private[mtl] trait LowPriorityAskInstancesCompat {
implicit def askForReader[E]: Ask[Reader[E, *], E] =
def askForReader[E]: Ask[Reader[E, *], E] =
new Ask[Reader[E, *], E] {
val applicative = Applicative[Reader[E, *]]
def ask[E2 >: E] = Kleisli.ask[Id, E2]
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/scala/cats/mtl/Ask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private[mtl] trait AskForMonadPartialOrder[F[_], G[_], E] extends Ask[G, E] {

private[mtl] trait LowPriorityAskInstances extends LowPriorityAskInstancesCompat {

implicit def askForMonadPartialOrder[F[_], G[_], E](
def askForMonadPartialOrder[F[_], G[_], E](
implicit lift0: MonadPartialOrder[F, G],
F0: Ask[F, E]): Ask[G, E] =
new AskForMonadPartialOrder[F, G, E] {
Expand All @@ -69,15 +69,15 @@ private[mtl] trait LowPriorityAskInstances extends LowPriorityAskInstancesCompat
}
}

private[mtl] trait AskInstances extends LowPriorityAskInstances {
private[mtl] trait AskInstances extends LocalInstances with LowPriorityAskInstances {

implicit def askForKleisli[F[_], E](implicit F: Applicative[F]): Ask[Kleisli[F, E, *], E] =
Local.baseLocalForKleisli[F, E]
def askForKleisli[F[_], E](implicit F: Applicative[F]): Ask[Kleisli[F, E, *], E] =
baseLocalForKleisli[F, E]

implicit def askForRWST[F[_], E, L, S](
def askForRWST[F[_], E, L, S](
implicit F: Monad[F],
L: Monoid[L]): Ask[RWST[F, E, L, S, *], E] =
Local.baseLocalForRWST[F, E, L, S]
baseLocalForRWST[F, E, L, S]
}

object Ask extends AskInstances {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/mtl/Local.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private[mtl] trait LocalInstances extends LowPriorityLocalInstances {
}
}

object Local extends LocalInstances {
object Local {
def apply[F[_], A](implicit local: Local[F, A]): Local[F, A] = local

def local[F[_], E, A](fa: F[A])(f: E => E)(implicit local: Local[F, E]): F[A] =
Expand Down