From c29c970c0653c0f74a617413471e28a4e4d08c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Mej=C3=ADa=20Su=C3=A1rez?= Date: Mon, 11 Apr 2022 20:44:22 -0500 Subject: [PATCH] Deprecate Future instances --- .../src/main/scala/alleycats/std/future.scala | 2 +- core/src/main/scala/cats/Invariant.scala | 24 ++++++++++++++++++ core/src/main/scala/cats/Semigroupal.scala | 25 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/alleycats-core/src/main/scala/alleycats/std/future.scala b/alleycats-core/src/main/scala/alleycats/std/future.scala index bee323ce33..49bc6f2549 100644 --- a/alleycats-core/src/main/scala/alleycats/std/future.scala +++ b/alleycats-core/src/main/scala/alleycats/std/future.scala @@ -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] { diff --git a/core/src/main/scala/cats/Invariant.scala b/core/src/main/scala/cats/Invariant.scala index 626046cc9d..7af63823ed 100644 --- a/core/src/main/scala/cats/Invariant.scala +++ b/core/src/main/scala/cats/Invariant.scala @@ -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] = diff --git a/core/src/main/scala/cats/Semigroupal.scala b/core/src/main/scala/cats/Semigroupal.scala index 0255a5f06b..10d1f77fb3 100644 --- a/core/src/main/scala/cats/Semigroupal.scala +++ b/core/src/main/scala/cats/Semigroupal.scala @@ -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