From 121f4d3604d61c52c45c31c303e86410ceea8684 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Tue, 10 Dec 2019 14:03:23 -0600 Subject: [PATCH 1/3] Fix more bincompat breakage --- core/src/main/scala/cats/instances/sortedSet.scala | 9 ++++++++- laws/src/main/scala/cats/laws/MonadErrorLaws.scala | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/instances/sortedSet.scala b/core/src/main/scala/cats/instances/sortedSet.scala index 99c642d110..345a610ff7 100644 --- a/core/src/main/scala/cats/instances/sortedSet.scala +++ b/core/src/main/scala/cats/instances/sortedSet.scala @@ -92,12 +92,19 @@ private[instances] trait SortedSetInstancesBinCompat0 { } private[instances] trait SortedSetInstancesBinCompat1 extends LowPrioritySortedSetInstancesBinCompat1 { + implicit def catsKernelStdHashForSortedSet1[A: Hash]: Hash[SortedSet[A]] = + cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) + // TODO: Remove when this is no longer necessary for binary compatibility. // Note that the overrides here and below are only necessary because the // definitions in `SortedSetInstances1` conflict with the ones in // `cats.kernel.instances.SortedSetInstances`. Both are inherited here, so // we have to "bubble" the "correct" ones up to the appropriate place. - implicit override def catsKernelStdHashForSortedSet[A: Hash]: Hash[SortedSet[A]] = + override def catsKernelStdHashForSortedSet[A: Hash]: Hash[SortedSet[A]] = + cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) + + @deprecated("Use cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet", "2.0.0-RC3") + override def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] = cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) } diff --git a/laws/src/main/scala/cats/laws/MonadErrorLaws.scala b/laws/src/main/scala/cats/laws/MonadErrorLaws.scala index e9b19354bf..082326f196 100644 --- a/laws/src/main/scala/cats/laws/MonadErrorLaws.scala +++ b/laws/src/main/scala/cats/laws/MonadErrorLaws.scala @@ -19,6 +19,12 @@ trait MonadErrorLaws[F[_], E] extends ApplicativeErrorLaws[F, E] with MonadLaws[ def redeemWithDerivedFromAttemptFlatMap[A, B](fa: F[A], fe: E => F[B], fs: A => F[B]): IsEq[F[B]] = F.redeemWith(fa)(fe, fs) <-> F.flatMap(F.attempt(fa))(_.fold(fe, fs)) + + override def adaptErrorPure[A](a: A, f: E => E): IsEq[F[A]] = + F.adaptError(F.pure(a)) { case x => f(x) } <-> F.pure(a) + + override def adaptErrorRaise[A](e: E, f: E => E): IsEq[F[A]] = + F.adaptError(F.raiseError[A](e)) { case x => f(x) } <-> F.raiseError(f(e)) } object MonadErrorLaws { From 716644a706d7bd9276601407049c37390a30c444 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Tue, 10 Dec 2019 14:07:44 -0600 Subject: [PATCH 2/3] Simplification --- core/src/main/scala/cats/instances/sortedSet.scala | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/src/main/scala/cats/instances/sortedSet.scala b/core/src/main/scala/cats/instances/sortedSet.scala index 345a610ff7..36a9652f61 100644 --- a/core/src/main/scala/cats/instances/sortedSet.scala +++ b/core/src/main/scala/cats/instances/sortedSet.scala @@ -95,14 +95,6 @@ private[instances] trait SortedSetInstancesBinCompat1 extends LowPrioritySortedS implicit def catsKernelStdHashForSortedSet1[A: Hash]: Hash[SortedSet[A]] = cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) - // TODO: Remove when this is no longer necessary for binary compatibility. - // Note that the overrides here and below are only necessary because the - // definitions in `SortedSetInstances1` conflict with the ones in - // `cats.kernel.instances.SortedSetInstances`. Both are inherited here, so - // we have to "bubble" the "correct" ones up to the appropriate place. - override def catsKernelStdHashForSortedSet[A: Hash]: Hash[SortedSet[A]] = - cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) - @deprecated("Use cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet", "2.0.0-RC3") override def catsKernelStdHashForSortedSet[A: Order: Hash]: Hash[SortedSet[A]] = cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A](Hash[A]) From 057fb8ecc05326105817c0974d7658c8cf278939 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Tue, 10 Dec 2019 15:17:06 -0600 Subject: [PATCH 3/3] Add note about overrides and bincompat --- laws/src/main/scala/cats/laws/MonadErrorLaws.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laws/src/main/scala/cats/laws/MonadErrorLaws.scala b/laws/src/main/scala/cats/laws/MonadErrorLaws.scala index 082326f196..c05f029994 100644 --- a/laws/src/main/scala/cats/laws/MonadErrorLaws.scala +++ b/laws/src/main/scala/cats/laws/MonadErrorLaws.scala @@ -20,6 +20,8 @@ trait MonadErrorLaws[F[_], E] extends ApplicativeErrorLaws[F, E] with MonadLaws[ def redeemWithDerivedFromAttemptFlatMap[A, B](fa: F[A], fe: E => F[B], fs: A => F[B]): IsEq[F[B]] = F.redeemWith(fa)(fe, fs) <-> F.flatMap(F.attempt(fa))(_.fold(fe, fs)) + // See https://github.com/typelevel/cats/pull/3203 for an explanation of why these two overrides + // are needed in 2.x for binary compatibility. override def adaptErrorPure[A](a: A, f: E => E): IsEq[F[A]] = F.adaptError(F.pure(a)) { case x => f(x) } <-> F.pure(a)