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

Upgrade ZIO Interop Cats Effect 3 to ZIO 2.0.0-RC2 #496

Merged
merged 1 commit into from
Jan 31, 2022
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lazy val root = project
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
)

val zioVersion = "2.0.0-RC1"
val zioVersion = "2.0.0-RC2"
val catsVersion = "2.6.1"
val catsEffectVersion = "3.2.9"
val catsMtlVersion = "1.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private[zio] trait CatsSpecBase
}
}

implicit def eqForURIO[R: Arbitrary: Tag: IsNotIntersection, A: Eq](implicit ticker: Ticker): Eq[URIO[R, A]] =
implicit def eqForURIO[R: Arbitrary: Tag, A: Eq](implicit ticker: Ticker): Eq[URIO[R, A]] =
eqForZIO[R, Nothing, A]

implicit def execRIO(rio: RIO[ZEnv, Boolean])(implicit ticker: Ticker): Prop =
Expand All @@ -127,7 +127,7 @@ private[zio] trait CatsSpecBase
implicit def orderForUIOofFiniteDuration(implicit ticker: Ticker): Order[UIO[FiniteDuration]] =
Order.by(unsafeRun(_).toEither.toOption)

implicit def orderForRIOofFiniteDuration[R: Arbitrary: Tag: IsNotIntersection](implicit
implicit def orderForRIOofFiniteDuration[R: Arbitrary: Tag](implicit
ticker: Ticker
): Order[RIO[R, FiniteDuration]] =
(x, y) =>
Expand All @@ -139,12 +139,12 @@ private[zio] trait CatsSpecBase
implicit def eqForUManaged[A: Eq](implicit ticker: Ticker): Eq[UManaged[A]] =
zManagedEq[Any, Nothing, A]

implicit def eqForURManaged[R: Arbitrary: Tag: IsNotIntersection, A: Eq](implicit
implicit def eqForURManaged[R: Arbitrary: Tag, A: Eq](implicit
ticker: Ticker
): Eq[URManaged[R, A]] =
zManagedEq[R, Nothing, A]

implicit def cogenZIO[R: Arbitrary: Tag: IsNotIntersection, E: Cogen, A: Cogen](implicit
implicit def cogenZIO[R: Arbitrary: Tag, E: Cogen, A: Cogen](implicit
ticker: Ticker
): Cogen[ZIO[R, E, A]] =
Cogen[Outcome[Option, E, A]].contramap { (zio: ZIO[R, E, A]) =>
Expand Down Expand Up @@ -172,11 +172,11 @@ private[interop] sealed trait CatsSpecBaseLowPriority { this: CatsSpecBase =>
implicit def eqForIO[E: Eq, A: Eq](implicit ticker: Ticker): Eq[IO[E, A]] =
Eq.by(_.either)

implicit def eqForZIO[R: Arbitrary: Tag: IsNotIntersection, E: Eq, A: Eq](implicit ticker: Ticker): Eq[ZIO[R, E, A]] =
implicit def eqForZIO[R: Arbitrary: Tag, E: Eq, A: Eq](implicit ticker: Ticker): Eq[ZIO[R, E, A]] =
(x, y) =>
Arbitrary.arbitrary[ZEnvironment[R]].sample.exists(r => x.provideEnvironment(r) eqv y.provideEnvironment(r))

implicit def eqForRIO[R: Arbitrary: Tag: IsNotIntersection, A: Eq](implicit ticker: Ticker): Eq[RIO[R, A]] =
implicit def eqForRIO[R: Arbitrary: Tag, A: Eq](implicit ticker: Ticker): Eq[RIO[R, A]] =
eqForZIO[R, Throwable, A]

implicit def eqForTask[A: Eq](implicit ticker: Ticker): Eq[Task[A]] =
Expand All @@ -187,20 +187,20 @@ private[interop] sealed trait CatsSpecBaseLowPriority { this: CatsSpecBase =>
ZManaged.ReleaseMap.make.flatMap(rm => ZManaged.currentReleaseMap.locally(rm)(managed.zio.map(_._2)))
)

implicit def eqForRManaged[R: Arbitrary: Tag: IsNotIntersection, A: Eq](implicit ticker: Ticker): Eq[RManaged[R, A]] =
implicit def eqForRManaged[R: Arbitrary: Tag, A: Eq](implicit ticker: Ticker): Eq[RManaged[R, A]] =
zManagedEq[R, Throwable, A]

implicit def eqForManaged[E: Eq, A: Eq](implicit ticker: Ticker): Eq[Managed[E, A]] =
zManagedEq[Any, E, A]

implicit def eqForZManaged[R: Arbitrary: Tag: IsNotIntersection, E: Eq, A: Eq](implicit
implicit def eqForZManaged[R: Arbitrary: Tag, E: Eq, A: Eq](implicit
ticker: Ticker
): Eq[ZManaged[R, E, A]] =
zManagedEq[R, E, A]

implicit def eqForTaskManaged[A: Eq](implicit ticker: Ticker): Eq[TaskManaged[A]] =
zManagedEq[Any, Throwable, A]

implicit def arbitraryZEnvironment[R: Arbitrary: Tag: IsNotIntersection]: Arbitrary[ZEnvironment[R]] =
implicit def arbitraryZEnvironment[R: Arbitrary: Tag]: Arbitrary[ZEnvironment[R]] =
Arbitrary(Arbitrary.arbitrary[R].map(ZEnvironment(_)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ private[interop] trait ZioSpecBase extends CatsSpecBase with ZioSpecBaseLowPrior
implicit def arbitraryUIO[A: Arbitrary]: Arbitrary[UIO[A]] =
Arbitrary(genUIO[A])

implicit def arbitraryURIO[R: Cogen: Tag: IsNotIntersection, A: Arbitrary]: Arbitrary[URIO[R, A]] =
implicit def arbitraryURIO[R: Cogen: Tag, A: Arbitrary]: Arbitrary[URIO[R, A]] =
Arbitrary(Arbitrary.arbitrary[ZEnvironment[R] => UIO[A]].map(ZIO.environment[R].flatMap))

implicit def arbitraryUManaged[A: Arbitrary]: Arbitrary[UManaged[A]] =
zManagedArbitrary[Any, Nothing, A](arbitraryUIO[A])

implicit def arbitraryURManaged[R: Cogen: Tag: IsNotIntersection, A: Arbitrary]: Arbitrary[URManaged[R, A]] =
implicit def arbitraryURManaged[R: Cogen: Tag, A: Arbitrary]: Arbitrary[URManaged[R, A]] =
zManagedArbitrary[R, Nothing, A]

implicit def arbitraryClockAndBlocking(implicit ticker: Ticker): Arbitrary[Clock] =
Expand All @@ -34,11 +34,10 @@ private[interop] trait ZioSpecBaseLowPriority { self: ZioSpecBase =>
Arbitrary(Gen.oneOf(genIO[E, A], genLikeTrans(genIO[E, A]), genIdentityTrans(genIO[E, A])))
}

implicit def arbitraryZIO[R: Cogen: Tag: IsNotIntersection, E: CanFail: Arbitrary: Cogen, A: Arbitrary: Cogen]
: Arbitrary[ZIO[R, E, A]] =
implicit def arbitraryZIO[R: Cogen: Tag, E: CanFail: Arbitrary: Cogen, A: Arbitrary: Cogen]: Arbitrary[ZIO[R, E, A]] =
Arbitrary(Gen.function1[ZEnvironment[R], IO[E, A]](arbitraryIO[E, A].arbitrary).map(ZIO.environment[R].flatMap))

implicit def arbitraryRIO[R: Cogen: Tag: IsNotIntersection, A: Arbitrary: Cogen]: Arbitrary[RIO[R, A]] =
implicit def arbitraryRIO[R: Cogen: Tag, A: Arbitrary: Cogen]: Arbitrary[RIO[R, A]] =
arbitraryZIO[R, Throwable, A]

implicit def arbitraryTask[A: Arbitrary: Cogen]: Arbitrary[Task[A]] =
Expand All @@ -47,19 +46,19 @@ private[interop] trait ZioSpecBaseLowPriority { self: ZioSpecBase =>
def zManagedArbitrary[R, E, A](implicit zio: Arbitrary[ZIO[R, E, A]]): Arbitrary[ZManaged[R, E, A]] =
Arbitrary(zio.arbitrary.map(ZManaged.fromZIO(_)))

implicit def arbitraryRManaged[R: Cogen: Tag: IsNotIntersection, A: Arbitrary: Cogen]: Arbitrary[RManaged[R, A]] =
implicit def arbitraryRManaged[R: Cogen: Tag, A: Arbitrary: Cogen]: Arbitrary[RManaged[R, A]] =
zManagedArbitrary[R, Throwable, A]

implicit def arbitraryManaged[E: Arbitrary: Cogen, A: Arbitrary: Cogen]: Arbitrary[Managed[E, A]] =
zManagedArbitrary[Any, E, A]

implicit def arbitraryZManaged[R: Cogen: Tag: IsNotIntersection, E: Arbitrary: Cogen, A: Arbitrary: Cogen]
implicit def arbitraryZManaged[R: Cogen: Tag, E: Arbitrary: Cogen, A: Arbitrary: Cogen]
: Arbitrary[ZManaged[R, E, A]] =
zManagedArbitrary[R, E, A]

implicit def arbitraryTaskManaged[A: Arbitrary: Cogen]: Arbitrary[TaskManaged[A]] =
zManagedArbitrary[Any, Throwable, A]

implicit def cogenZEnvironment[R: Cogen: Tag: IsNotIntersection]: Cogen[ZEnvironment[R]] =
implicit def cogenZEnvironment[R: Cogen: Tag]: Cogen[ZEnvironment[R]] =
Cogen[R].contramap(_.get)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cats.syntax.all.*
import org.scalacheck.{ Arbitrary, Cogen, Gen }
import zio.interop.CatsSpecBase
import zio.stream.*
import zio.{ CanFail, Chunk, IsNotIntersection, Tag, ZEnvironment, ZIO }
import zio.{ CanFail, Chunk, Tag, ZEnvironment, ZIO }

private[interop] trait ZStreamSpecBase extends CatsSpecBase with ZStreamSpecBaseLowPriority with GenStreamInteropCats {

Expand All @@ -27,7 +27,7 @@ private[interop] trait ZStreamSpecBaseLowPriority { self: ZStreamSpecBase =>
implicit def eqForStream[E: Eq, A: Eq](implicit ticker: Ticker): Eq[Stream[E, A]] =
zStreamEq[Any, E, A]

implicit def eqForZStream[R: Arbitrary: Tag: IsNotIntersection, E: Eq, A: Eq](implicit
implicit def eqForZStream[R: Arbitrary: Tag, E: Eq, A: Eq](implicit
ticker: Ticker
): Eq[ZStream[R, E, A]] =
zStreamEq[R, E, A]
Expand All @@ -38,7 +38,7 @@ private[interop] trait ZStreamSpecBaseLowPriority { self: ZStreamSpecBase =>
}

implicit def arbitraryZStream[
R: Cogen: Tag: IsNotIntersection,
R: Cogen: Tag,
E: CanFail: Arbitrary: Cogen,
A: Arbitrary: Cogen
]: Arbitrary[ZStream[R, E, A]] = Arbitrary(
Expand All @@ -47,6 +47,6 @@ private[interop] trait ZStreamSpecBaseLowPriority { self: ZStreamSpecBase =>
.map(ZStream.fromZIO(ZIO.environment[R]).flatMap)
)

implicit def cogenZEnvironment[R: Cogen: Tag: IsNotIntersection]: Cogen[ZEnvironment[R]] =
implicit def cogenZEnvironment[R: Cogen: Tag]: Cogen[ZEnvironment[R]] =
Cogen[R].contramap(_.get)
}