Skip to content

Commit

Permalink
Fix more bincompat breakage (#3203)
Browse files Browse the repository at this point in the history
* Fix more bincompat breakage

* Simplification

* Add note about overrides and bincompat
  • Loading branch information
travisbrown authored Dec 11, 2019
1 parent f0b813d commit e0e8f35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/src/main/scala/cats/instances/sortedSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ private[instances] trait SortedSetInstancesBinCompat0 {
}

private[instances] trait SortedSetInstancesBinCompat1 extends LowPrioritySortedSetInstancesBinCompat1 {
// 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]] =
implicit def catsKernelStdHashForSortedSet1[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])
}

Expand Down
8 changes: 8 additions & 0 deletions laws/src/main/scala/cats/laws/MonadErrorLaws.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ 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)

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 {
Expand Down

0 comments on commit e0e8f35

Please sign in to comment.