Skip to content

Commit ee796a8

Browse files
authored
Merge pull request #4230 from armanbilge/fix/soft-deprecate-future
Recommend Cats Effect `IO` as a replacement for every use case of `Future`
2 parents 77fbe02 + 5975a3f commit ee796a8

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

core/src/main/scala-2.12/cats/instances/package.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@ package object instances {
3939
object deadline extends DeadlineInstances
4040
object function extends FunctionInstances with FunctionInstancesBinCompat0
4141
object partialFunction extends PartialFunctionInstances
42+
43+
/**
44+
* @deprecated
45+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
46+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
47+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
48+
* However, at this time there are no plans to remove these instances from Cats.
49+
*
50+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
51+
*/
4252
object future extends FutureInstances
53+
4354
object int extends IntInstances
4455
object invariant extends InvariantMonoidalInstances with InvariantInstances with InvariantInstancesBinCompat0
4556
object list extends ListInstances with ListInstancesBinCompat0

core/src/main/scala-2.13+/cats/instances/package.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ package object instances {
4040
object deadline extends DeadlineInstances
4141
object function extends FunctionInstances with FunctionInstancesBinCompat0
4242
object partialFunction extends PartialFunctionInstances
43+
44+
/**
45+
* @deprecated
46+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
47+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
48+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
49+
* However, at this time there are no plans to remove these instances from Cats.
50+
*
51+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
52+
*/
4353
object future extends FutureInstances
54+
4455
object int extends IntInstances
4556
object invariant extends InvariantMonoidalInstances with InvariantInstances with InvariantInstancesBinCompat0
4657
object list extends ListInstances with ListInstancesBinCompat0

core/src/main/scala/cats/Invariant.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn
153153

154154
implicit def catsInstancesForTry: MonadThrow[Try] with CoflatMap[Try] =
155155
cats.instances.try_.catsStdInstancesForTry
156+
157+
/**
158+
* @deprecated
159+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
160+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
161+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
162+
* However, at this time there are no plans to remove these instances from Cats.
163+
*
164+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
165+
*/
156166
implicit def catsInstancesForFuture(implicit
157167
ec: ExecutionContext
158168
): MonadThrow[Future] with CoflatMap[Future] =

core/src/main/scala/cats/Semigroupal.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,19 @@ object Semigroupal extends ScalaVersionSpecificSemigroupalInstances with Semigro
7070
implicit def catsSemigroupalForId: Semigroupal[Id] = catsInstancesForId
7171
implicit def catsSemigroupalForOption: Semigroupal[Option] = cats.instances.option.catsStdInstancesForOption
7272
implicit def catsSemigroupalForTry: Semigroupal[Try] = cats.instances.try_.catsStdInstancesForTry
73+
74+
/**
75+
* @deprecated
76+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
77+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
78+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
79+
* However, at this time there are no plans to remove these instances from Cats.
80+
*
81+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
82+
*/
7383
implicit def catsSemigroupalForFuture(implicit ec: ExecutionContext): Semigroupal[Future] =
7484
cats.instances.future.catsStdInstancesForFuture(ec)
85+
7586
implicit def catsSemigroupalForList: Semigroupal[List] = cats.instances.list.catsStdInstancesForList
7687
implicit def catsSemigroupalForSeq: Semigroupal[Seq] = cats.instances.seq.catsStdInstancesForSeq
7788
implicit def catsSemigroupalForVector: Semigroupal[Vector] = cats.instances.vector.catsStdInstancesForVector

core/src/main/scala/cats/instances/future.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ package instances
2525
import scala.concurrent.{ExecutionContext, Future}
2626
import scala.util.{Failure, Success}
2727

28+
/**
29+
* @deprecated
30+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
31+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
32+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
33+
* However, at this time there are no plans to remove these instances from Cats.
34+
*
35+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
36+
*/
2837
trait FutureInstances extends FutureInstances1 {
2938

3039
implicit def catsStdInstancesForFuture(implicit

kernel/src/main/scala/cats/kernel/Semigroup.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,19 @@ private[kernel] trait MonoidInstances extends BandInstances {
288288
cats.kernel.instances.either.catsDataMonoidForEither[A, B]
289289
implicit def catsKernelMonoidForTry[A: Monoid]: Monoid[Try[A]] =
290290
new TryMonoid[A](Monoid[A])
291+
292+
/**
293+
* @deprecated
294+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
295+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
296+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
297+
* However, at this time there are no plans to remove these instances from Cats.
298+
*
299+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
300+
*/
291301
implicit def catsKernelMonoidForFuture[A](implicit A: Monoid[A], ec: ExecutionContext): Monoid[Future[A]] =
292302
new FutureMonoid[A](A, ec)
303+
293304
implicit def catsKernelMonoidForOption[A: Semigroup]: Monoid[Option[A]] =
294305
cats.kernel.instances.option.catsKernelStdMonoidForOption[A]
295306
implicit def catsKernelMonoidForSeq[A]: Monoid[Seq[A]] =
@@ -319,6 +330,15 @@ private[kernel] trait SemigroupInstances {
319330
cats.kernel.instances.either.catsDataSemigroupForEither[A, B]
320331
implicit def catsKernelSemigroupForTry[A: Semigroup]: Semigroup[Try[A]] =
321332
new TrySemigroup[A](Semigroup[A])
333+
334+
/**
335+
* @deprecated
336+
* Any non-pure use of [[scala.concurrent.Future Future]] with Cats is error prone
337+
* (particularly the semantics of [[cats.Traverse#traverse traverse]] with regard to execution order are unspecified).
338+
* We recommend using [[https://typelevel.org/cats-effect/ Cats Effect `IO`]] as a replacement for ''every'' use case of [[scala.concurrent.Future Future]].
339+
*
340+
* @see [[https://github.com/typelevel/cats/issues/4176 Changes in Future traverse behavior between 2.6 and 2.7]]
341+
*/
322342
implicit def catsKernelSemigroupForFuture[A](implicit A: Semigroup[A], ec: ExecutionContext): Semigroup[Future[A]] =
323343
new FutureSemigroup[A](A, ec)
324344
}

0 commit comments

Comments
 (0)