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

Remove custom Order code already released in Cats #2076

Merged
merged 3 commits into from
Jun 25, 2021
Merged
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
5 changes: 2 additions & 3 deletions tests/shared/src/test/scala/cats/effect/EitherTIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package cats.effect

import cats.data.EitherT
import cats.Order
import cats.laws.discipline.arbitrary._
import cats.data.EitherT
import cats.effect.laws.AsyncTests
import cats.implicits._
import cats.laws.discipline.arbitrary._

import org.scalacheck.Prop

Expand Down
29 changes: 2 additions & 27 deletions tests/shared/src/test/scala/cats/effect/IorTIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package cats.effect

import cats.data.{Ior, IorT}
import cats.Order
import cats.laws.discipline.arbitrary._
import cats.data.IorT
import cats.effect.laws.AsyncTests
import cats.implicits._
import cats.laws.discipline.arbitrary._

import org.scalacheck.Prop

Expand All @@ -39,30 +38,6 @@ class IorTIOSpec extends IOPlatformSpecification with Discipline with ScalaCheck
implicit def ordIorTIOFD(implicit ticker: Ticker): Order[IorT[IO, Int, FiniteDuration]] =
Order by { ioaO => unsafeRun(ioaO.value).fold(None, _ => None, fa => fa) }

//TODO remove once https://github.com/typelevel/cats/pull/3555 is released
implicit def orderIor[A, B](
implicit A: Order[A],
B: Order[B],
AB: Order[(A, B)]): Order[Ior[A, B]] =
new Order[Ior[A, B]] {

override def compare(x: Ior[A, B], y: Ior[A, B]): Int =
(x, y) match {
case (Ior.Left(a1), Ior.Left(a2)) => A.compare(a1, a2)
case (Ior.Left(_), _) => -1
case (Ior.Both(a1, b1), Ior.Both(a2, b2)) => AB.compare((a1, b1), (a2, b2))
case (Ior.Both(_, _), Ior.Left(_)) => 1
case (Ior.Both(_, _), Ior.Right(_)) => -1
case (Ior.Right(b1), Ior.Right(b2)) => B.compare(b1, b2)
case (Ior.Right(_), _) => 1
}

}

//TODO remove once https://github.com/typelevel/cats/pull/3555 is released
implicit def orderIorT[F[_], A, B](implicit Ord: Order[F[Ior[A, B]]]): Order[IorT[F, A, B]] =
Order.by(_.value)

implicit def execIorT(sbool: IorT[IO, Int, Boolean])(implicit ticker: Ticker): Prop =
Prop(
unsafeRun(sbool.value).fold(
Expand Down
5 changes: 2 additions & 3 deletions tests/shared/src/test/scala/cats/effect/KleisliIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

package cats.effect

import cats.data.Kleisli
import cats.{Eq, Order}
import cats.data.Kleisli
import cats.effect.laws.AsyncTests
import cats.laws.discipline.MiniInt
import cats.laws.discipline.arbitrary._
import cats.laws.discipline.eq._
import cats.effect.laws.AsyncTests
import cats.implicits._

import org.scalacheck.Prop

Expand Down
5 changes: 2 additions & 3 deletions tests/shared/src/test/scala/cats/effect/OptionTIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package cats.effect

import cats.data.OptionT
import cats.Order
import cats.laws.discipline.arbitrary._
import cats.data.OptionT
import cats.effect.laws.AsyncTests
import cats.implicits._
import cats.laws.discipline.arbitrary._

import org.scalacheck.Prop
// import org.scalacheck.rng.Seed
Expand Down
10 changes: 2 additions & 8 deletions tests/shared/src/test/scala/cats/effect/WriterTIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

package cats.effect

import cats.data.WriterT
import cats.Order
import cats.laws.discipline.arbitrary._
import cats.data.WriterT
import cats.effect.laws.AsyncTests
import cats.implicits._
import cats.laws.discipline.arbitrary._

import org.scalacheck.Prop

Expand All @@ -44,11 +43,6 @@ class WriterTIOSpec
implicit ticker: Ticker): Order[WriterT[IO, Int, FiniteDuration]] =
Order by { ioaO => unsafeRun(ioaO.run).fold(None, _ => None, fa => fa) }

//TODO remove once https://github.com/typelevel/cats/pull/3556 is released
implicit def orderWriterT[F[_], S, A](
implicit Ord: Order[F[(S, A)]]): Order[WriterT[F, S, A]] = Order.by(_.run)

//TODO remove once https://github.com/typelevel/cats/pull/3556 is released
implicit def execWriterT[S](sbool: WriterT[IO, S, Boolean])(implicit ticker: Ticker): Prop =
Prop(
unsafeRun(sbool.run).fold(
Expand Down