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

Update cats-effect-laws to 3.2.0 #274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inThisBuild(List(

val monixVersion = "3.4.0"
val minitestVersion = "2.9.6"
val catsEffectVersion = "2.5.1"
val catsEffectVersion = "3.2.0"

// The Monix version with which we must keep binary compatibility.
// https://github.com/typesafehub/migration-manager/wiki/Sbt-plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package monix.bio

import cats.effect.{ContextShift, IO => CIO}
import cats.effect.{IO => CIO}
import cats.effect.laws.discipline._
import cats.laws.discipline.{ApplicativeTests, BifunctorTests, CoflatMapTests, ParallelTests}
import cats.kernel.laws.discipline.MonoidTests
Expand Down
5 changes: 3 additions & 2 deletions core/shared/src/main/scala/monix/bio/BIOApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

package monix.bio

import cats.effect.{ConcurrentEffect, ContextShift, ExitCode, IOApp, Timer}
import cats.effect.{ConcurrentEffect, ExitCode, IOApp}
import monix.catnap.SchedulerEffect
import monix.bio.instances.CatsConcurrentEffectForTask
import monix.execution.Scheduler
import cats.effect.Temporal

/** Safe `App` type that executes a [[IO]]. Shutdown occurs after
* the `IO` completes, as follows:
Expand Down Expand Up @@ -88,7 +89,7 @@ trait BIOApp {
val app = new IOApp {
override implicit lazy val contextShift: ContextShift[cats.effect.IO] =
SchedulerEffect.contextShift[cats.effect.IO](scheduler)(cats.effect.IO.ioEffect)
override implicit lazy val timer: Timer[cats.effect.IO] =
override implicit lazy val timer: Temporal[cats.effect.IO] =
SchedulerEffect.timerLiftIO[cats.effect.IO](scheduler)(cats.effect.IO.ioEffect)
def run(args: List[String]): cats.effect.IO[ExitCode] =
self.run(args).to[cats.effect.IO]
Expand Down
15 changes: 7 additions & 8 deletions core/shared/src/main/scala/monix/bio/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import cats.effect.{
Clock,
Concurrent,
ConcurrentEffect,
ContextShift,
Effect,
ExitCase,
IO => CIO,
Timer,
Fiber => _
}
import cats.{~>, CommutativeApplicative, Monoid, Parallel, Semigroup}
Expand All @@ -48,6 +46,7 @@ import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}

import monix.bio.tracing.{IOEvent, IOTrace}
import cats.effect.Temporal

/** `Task` represents a specification for a possibly lazy or
* asynchronous computation, which when executed will produce an `A`
Expand Down Expand Up @@ -5453,11 +5452,11 @@ private[bio] abstract class TaskTimers extends TaskClocks {
* [[monix.execution.Scheduler Scheduler]]
* (that's being injected in [[IO.runToFuture]]).
*/
implicit def timer[E]: Timer[IO[E, *]] =
timerAny.asInstanceOf[Timer[IO[E, *]]]
implicit def timer[E]: Temporal[IO[E, *]] =
timerAny.asInstanceOf[Temporal[IO[E, *]]]

private[this] final val timerAny: Timer[IO[Any, *]] =
new Timer[IO[Any, *]] {
private[this] final val timerAny: Temporal[IO[Any, *]] =
new Temporal[IO[Any, *]] {

override def sleep(duration: FiniteDuration): IO[Any, Unit] =
IO.sleep(duration)
Expand All @@ -5469,8 +5468,8 @@ private[bio] abstract class TaskTimers extends TaskClocks {
/** Builds a `cats.effect.Timer` instance, given a
* [[monix.execution.Scheduler Scheduler]] reference.
*/
def timer[E](s: Scheduler): Timer[IO[E, *]] =
new Timer[IO[E, *]] {
def timer[E](s: Scheduler): Temporal[IO[E, *]] =
new Temporal[IO[E, *]] {

override def sleep(duration: FiniteDuration): IO[E, Unit] =
IO.sleep(duration).executeOn(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private[bio] object TaskConversions {
case IO.Termination(e) => F.raiseError(e)
case IO.Eval(thunk) => F.delay(thunk())
case IO.EvalTotal(thunk) => F.delay(thunk())
case _ => F.async(cb => eff.runAsync(source)(r => { cb(r); CIO.unit }).unsafeRunSync())
case _ => F.async_(cb => eff.runAsync(source)(r => { cb(r); CIO.unit }).unsafeRunSync())
}

/** Implementation for `IO.fromEffect`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
package monix.bio.internal

import cats.effect.ExitCase
import cats.effect.concurrent.Deferred
import monix.bio.{Cause, IO, Task, UIO}
import monix.catnap.ConcurrentQueue
import monix.execution.exceptions.UncaughtErrorException
import monix.execution.{BufferCapacity, ChannelType}
import cats.effect.Deferred

private[bio] object TaskParSequenceN {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

package monix.bio

import cats.effect.concurrent.Deferred
import cats.laws._
import cats.laws.discipline._
import monix.execution.exceptions.{CompositeException, DummyException}
import monix.execution.internal.Platform

import scala.util.{Failure, Success}
import scala.concurrent.duration._
import cats.effect.Deferred

object TaskBracketSuite extends BaseTestSuite {
test("equivalence with onErrorHandleWith") { implicit sc =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package monix.bio

import java.util.concurrent.TimeUnit

import cats.effect.{Clock, ContextShift, Timer}
import cats.effect.Clock
import monix.execution.exceptions.DummyException
import monix.execution.schedulers.TestScheduler

import scala.concurrent.duration._
import scala.util.{Failure, Success}
import cats.effect.Temporal

object TaskClockTimerAndContextShiftSuite extends BaseTestSuite {
test("IO.clock is implicit") { _ =>
Expand Down Expand Up @@ -70,7 +71,7 @@ object TaskClockTimerAndContextShiftSuite extends BaseTestSuite {
}

test("IO.timer is implicit") { implicit s =>
assertEquals(IO.timer[Any], implicitly[Timer[IO[Any, *]]])
assertEquals(IO.timer[Any], implicitly[Temporal[IO[Any, *]]])
assertEquals(IO.timer[Any].clock, implicitly[Clock[IO[Any, *]]])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package monix.bio

import cats.effect.{ContextShift, IO => CIO}
import cats.effect.{IO => CIO}
import monix.catnap.SchedulerEffect

import scala.util.Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,13 @@ object TaskConversionsSuite extends BaseTestSuite {
fa.io.runAsync(cb)

override def async[A](k: (Either[Throwable, A] => Unit) => Unit): CEIO[A] =
CEIO(CIO.async(k))
CEIO(CIO.async_(k))

override def asyncF[A](k: (Either[Throwable, A] => Unit) => CEIO[Unit]): CEIO[A] =
CEIO(CIO.asyncF(cb => k(cb).io))

override def suspend[A](thunk: => CEIO[A]): CEIO[A] =
CEIO(CIO.suspend(thunk.io))
CEIO(CIO.defer(thunk.io))

override def flatMap[A, B](fa: CEIO[A])(f: A => CEIO[B]): CEIO[B] =
CEIO(fa.io.flatMap(a => f(a).io))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package monix.bio

import cats.Eval
import cats.effect.{ContextShift, IO => CIO, SyncIO}
import cats.effect.{IO => CIO, SyncIO}
import cats.laws._
import cats.laws.discipline._
import cats.syntax.all._
Expand Down