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

explicit disabling of automatic coloring #99

Merged
merged 2 commits into from
Nov 19, 2022
Merged
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
8 changes: 8 additions & 0 deletions core/shared/src/main/scala-3/cats/effect/cps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import _root_.cps.{async, await, CpsAsyncMonad, CpsAwaitable, CpsConcurrentEffec
import cats.effect.kernel.{Async, Concurrent, Fiber, Sync}
import cats.effect.kernel.syntax.all._

import scala.annotation.implicitNotFound
import scala.util.Try

object cps {
Expand All @@ -31,11 +32,18 @@ object cps {
transparent inline def await: A = _root_.cps.await[F, A, F](self)
}

@implicitNotFound("automatic coloring is disabled")
implicit def automaticColoringTag1[F[_]:Concurrent]: _root_.cps.automaticColoring.AutomaticColoringTag[F] = ???
implicit def automaticColoringTag2[F[_]:Concurrent]: _root_.cps.automaticColoring.AutomaticColoringTag[F] = ???

// actually not used by dotty-cps-async but need for binary compability with cats-effect-cps 0.4.x.
// TODO: remove in 0.5.0
implicit def catsEffectCpsMonadPureMemoization[F[_]](implicit F: Concurrent[F]): CpsMonadMemoization.Pure[F] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does memoization has to do with automatic colouring in the context of dotty-cps? If not, any reason not to keep it ?

MiMa is complaining about bincompat, so it's either a case of keeping it, or prepping the version so that the next release is 0.5.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the early days, memoization was needed in some internal interfaces for async but actually called only during automatic coloring.
Now - dotty-cps-async requires a memoization interface only if automatic coloring is enabled.
From another side, we can restore memoization for compatibility, overhead is small.

new CpsMonadMemoization.Pure[F] {
def apply[A](fa: F[A]): F[F[A]] = F.memoize(fa)
}


// TODO we can actually provide some more gradient instances here
implicit def catsEffectCpsConcurrentMonad[F[_]](implicit F: Async[F]): CpsConcurrentEffectMonad[F] with CpsMonadInstanceContext[F] =
new CpsConcurrentEffectMonad[F] with CpsMonadInstanceContext[F] {
Expand Down