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

Deprecate Future instances #4182

Closed
Closed
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 alleycats-core/src/main/scala/alleycats/std/future.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import scala.concurrent.Future

object future extends FutureInstances

trait FutureInstances {
trait FutureInstances extends cats.instances.FutureInstances {

implicit val alleycatsStdFuturePure: Pure[Future] =
new Pure[Future] {
Expand Down
24 changes: 24 additions & 0 deletions core/src/main/scala/cats/Invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn

implicit def catsInstancesForTry: MonadThrow[Try] with CoflatMap[Try] =
cats.instances.try_.catsStdInstancesForTry

@deprecated(
// format: off
message =
"""
Instances for scala.concurrent.Future have been deprecated,
and will be moved into alleycats-core in cats 3.

The rationale for the change is that given the nature of Future
cats can't guarantee the appropriate behaviour of its instance.

If you want to silence this warning you can add this to your scalacOptions:
"-Wconf:cat=deprecation&origin=cats\\..*\\..*ForFuture:s"

You may also prepare for this change and use alleycats right now.
Import the library: "org.typelevel" %% "alleycats-core" % "..."
And import alleycats.std.future._ in this file;
if you require the future instances in multiple files
you can add the following scalacOptions to automatically add the import in all files:
"-Yimports", "java.lang", "scala", "scala.Predef", "alleycats.std.future"
""",
// format: on
since = "2.8.0"
)
implicit def catsInstancesForFuture(implicit
ec: ExecutionContext
): MonadThrow[Future] with CoflatMap[Future] =
Expand Down
25 changes: 25 additions & 0 deletions core/src/main/scala/cats/Semigroupal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,33 @@ object Semigroupal extends ScalaVersionSpecificSemigroupalInstances with Semigro
implicit def catsSemigroupalForId: Semigroupal[Id] = catsInstancesForId
implicit def catsSemigroupalForOption: Semigroupal[Option] = cats.instances.option.catsStdInstancesForOption
implicit def catsSemigroupalForTry: Semigroupal[Try] = cats.instances.try_.catsStdInstancesForTry

@deprecated(
// format: off
message =
"""
Instances for scala.concurrent.Future have been deprecated,
and will be moved into alleycats-core in cats 3.

The rationale for the change is that given the nature of Future
cats can't guarantee the appropriate behaviour of its instance.

If you want to silence this warning you can add this to your scalacOptions:
"-Wconf:cat=deprecation&origin=cats\\..*\\..*ForFuture:s"

You may also prepare for this change and use alleycats right now.
Import the library: "org.typelevel" %% "alleycats-core" % "..."
And import alleycats.std.future._ in this file;
if you require the future instances in multiple files
you can add the following scalacOptions to automatically add the import in all files:
"-Yimports", "java.lang", "scala", "scala.Predef", "alleycats.std.future"
""",
// format: on
since = "2.8.0"
)
implicit def catsSemigroupalForFuture(implicit ec: ExecutionContext): Semigroupal[Future] =
cats.instances.future.catsStdInstancesForFuture(ec)

implicit def catsSemigroupalForList: Semigroupal[List] = cats.instances.list.catsStdInstancesForList
implicit def catsSemigroupalForSeq: Semigroupal[Seq] = cats.instances.seq.catsStdInstancesForSeq
implicit def catsSemigroupalForVector: Semigroupal[Vector] = cats.instances.vector.catsStdInstancesForVector
Expand Down