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

Removes Usages Of ZIO.succeedNow #654

Merged
merged 1 commit into from
Mar 2, 2023
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
16 changes: 8 additions & 8 deletions zio-interop-cats/shared/src/main/scala/zio/interop/cats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private final class ZioRef[R, E, A](ref: ZRef[A]) extends effect.Ref[ZIO[R, E, _
def setter(a: A): F[Boolean] =
ZIO.suspendSucceed {
if (called.getAndSet(true)) {
ZIO.succeedNow(false)
ZIO.succeed(false)
} else {
ref.modify { updated =>
if (current == updated) (true, a)
Expand Down Expand Up @@ -665,7 +665,7 @@ private abstract class ZioMonadError[R, E, E1] extends MonadError[ZIO[R, E, _],
type F[A] = ZIO[R, E, A]

override final def pure[A](a: A): F[A] =
ZIO.succeedNow(a)
ZIO.succeed(a)

override final def map[A, B](fa: F[A])(f: A => B): F[B] = {
implicit def trace: Trace = InteropTracer.newTrace(f)
Expand Down Expand Up @@ -710,7 +710,7 @@ private abstract class ZioMonadError[R, E, E1] extends MonadError[ZIO[R, E, _],
override final def tailRecM[A, B](a: A)(f: A => F[Either[A, B]]): F[B] = {
def loop(a: A): F[B] = f(a).flatMap {
case Left(a) => loop(a)
case Right(b) => ZIO.succeedNow(b)
case Right(b) => ZIO.succeed(b)
}

ZIO.suspendSucceed(loop(a))
Expand Down Expand Up @@ -783,7 +783,7 @@ private trait ZioMonadErrorExitThrowable[R]
protected final def toOutcomeOtherFiber[A](interruptedHandle: zio.Ref[Boolean])(
exit: Exit[Throwable, A]
): UIO[Outcome[F, Throwable, A]] =
interruptedHandle.get.map(toOutcomeThrowableOtherFiber(_)(ZIO.succeedNow, exit))
interruptedHandle.get.map(toOutcomeThrowableOtherFiber(_)(ZIO.succeed(_), exit))
}

private trait ZioMonadErrorExitCause[R, E] extends ZioMonadErrorExit[R, E, Cause[E]] with ZioMonadErrorCause[R, E] {
Expand All @@ -794,7 +794,7 @@ private trait ZioMonadErrorExitCause[R, E] extends ZioMonadErrorExit[R, E, Cause
protected final def toOutcomeOtherFiber[A](interruptedHandle: zio.Ref[Boolean])(
exit: Exit[E, A]
): UIO[Outcome[F, Cause[E], A]] =
interruptedHandle.get.map(toOutcomeCauseOtherFiber(_)(ZIO.succeedNow, exit))
interruptedHandle.get.map(toOutcomeCauseOtherFiber(_)(ZIO.succeed(_), exit))
}

private class ZioSemigroupK[R, E] extends SemigroupK[ZIO[R, E, _]] {
Expand Down Expand Up @@ -851,7 +851,7 @@ private class ZioParApplicative[R, E] extends CommutativeApplicative[ParallelF[Z
type F[A] = ParallelF[G, A]

final override def pure[A](x: A): F[A] =
ParallelF[G, A](ZIO.succeedNow(x))
ParallelF[G, A](ZIO.succeed(x))

final override def map2[A, B, Z](fa: F[A], fb: F[B])(f: (A, B) => Z): F[Z] = {
implicit def trace: Trace = InteropTracer.newTrace(f)
Expand Down Expand Up @@ -890,7 +890,7 @@ private class ZioSemigroup[R, E, A](implicit semigroup: Semigroup[A]) extends Se

private class ZioMonoid[R, E, A](implicit monoid: Monoid[A]) extends ZioSemigroup[R, E, A] with Monoid[ZIO[R, E, A]] {
override final val empty: T =
ZIO.succeedNow(monoid.empty)
ZIO.succeed(monoid.empty)
}

private class ZioParSemigroup[R, E, A](implicit semigroup: CommutativeSemigroup[A])
Expand All @@ -910,7 +910,7 @@ private class ZioParMonoid[R, E, A](implicit monoid: CommutativeMonoid[A])
with CommutativeMonoid[ParallelF[ZIO[R, E, _], A]] {

override final val empty: T =
ParallelF[ZIO[R, E, _], A](ZIO.succeedNow(monoid.empty))
ParallelF[ZIO[R, E, _], A](ZIO.succeed(monoid.empty))
}

private class ZioLiftIO[R](implicit runtime: IORuntime) extends LiftIO[RIO[R, _]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class ZIOResourceSyntax[R, E <: Throwable, A](private val resource: Resour
eval.fa

case pure: Resource.Pure[F, B] =>
ZIO.succeedNow(pure.a)
ZIO.succeed(pure.a)
}

go(resource)
Expand Down Expand Up @@ -115,7 +115,7 @@ final class ScopedSyntax(private val self: Resource.type) extends AnyVal {
Resource.suspend(
scope.extend[R] {
zio.map { case a =>
Resource.applyCase[F, A](ZIO.succeedNow((a, _ => ZIO.unit)))
Resource.applyCase[F, A](ZIO.succeed((a, _ => ZIO.unit)))
}
}
)
Expand Down Expand Up @@ -186,7 +186,7 @@ private class ZManagedMonadError[R, E] extends MonadError[ZManaged[R, E, _], E]
type F[A] = ZManaged[R, E, A]

override final def pure[A](a: A): F[A] =
ZManaged.succeedNow(a)
ZManaged.succeed(a)

override final def map[A, B](fa: F[A])(f: A => B): F[B] =
fa.map(f)(InteropTracer.newTrace(f))
Expand Down Expand Up @@ -235,7 +235,7 @@ private class ZManagedMonadError[R, E] extends MonadError[ZManaged[R, E, _], E]

ZManaged.suspend(f(a)).flatMap {
case Left(a) => tailRecM(a)(f)
case Right(b) => ZManaged.succeedNow(b)
case Right(b) => ZManaged.succeed(b)
}
}
}
Expand All @@ -252,7 +252,7 @@ private class ZManagedMonoid[R, E, A](implicit monoid: Monoid[A])
with Monoid[ZManaged[R, E, A]] {

override final val empty: T =
ZManaged.succeedNow(monoid.empty)
ZManaged.succeed(monoid.empty)
}

private class ZManagedSemigroupK[R, E] extends SemigroupK[ZManaged[R, E, _]] {
Expand Down Expand Up @@ -292,7 +292,7 @@ private class ZManagedParMonoid[R, E, A](implicit monoid: CommutativeMonoid[A])
with CommutativeMonoid[ParallelF[ZManaged[R, E, _], A]] {

override final val empty: T =
ParallelF[ZManaged[R, E, _], A](ZManaged.succeedNow(monoid.empty))
ParallelF[ZManaged[R, E, _], A](ZManaged.succeed(monoid.empty))
}

private class ZManagedBifunctor[R] extends Bifunctor[ZManaged[R, _, _]] {
Expand Down Expand Up @@ -325,7 +325,7 @@ private class ZManagedParApplicative[R, E] extends CommutativeApplicative[Parall
type F[A] = ParallelF[G, A]

final override def pure[A](x: A): F[A] =
ParallelF[G, A](ZManaged.succeedNow(x))
ParallelF[G, A](ZManaged.succeed(x))

final override def map2[A, B, Z](fa: F[A], fb: F[B])(f: (A, B) => Z): F[Z] = {
implicit val tracer: Trace = InteropTracer.newTrace(f)
Expand Down
18 changes: 9 additions & 9 deletions zio-interop-cats/shared/src/main/scala/zio/interop/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ package object interop {
convertDie: Cause[Nothing] => E1
): UIO[Outcome[ZIO[R, E, _], E1, A]] = exit match {
case Exit.Success(value) =>
ZIO.succeedNow(Outcome.Succeeded(ZIO.succeedNow(value)))
ZIO.succeed(Outcome.Succeeded(ZIO.succeed(value)))
case Exit.Failure(cause) =>
lazy val nonCanceledOutcome: UIO[Outcome[ZIO[R, E, _], E1, A]] = cause.failureOrCause match {
case Left(error) =>
ZIO.succeedNow(Outcome.Errored(convertFail(error, cause)))
ZIO.succeed(Outcome.Errored(convertFail(error, cause)))
case Right(cause) =>
ZIO.succeedNow(Outcome.Errored(convertDie(cause)))
ZIO.succeed(Outcome.Errored(convertDie(cause)))
}
// ZIO 2, unlike ZIO 1, _does not_ guarantee that the presence of a typed failure
// means we're NOT interrupting, so we have to check for interruption to matter what
Expand All @@ -143,7 +143,7 @@ package object interop {
) {
ZIO.descriptorWith { descriptor =>
if (descriptor.interrupters.nonEmpty)
ZIO.succeedNow(Outcome.Canceled())
ZIO.succeed(Outcome.Canceled())
else {
nonCanceledOutcome
}
Expand All @@ -156,15 +156,15 @@ package object interop {
private[interop] def toExitCaseThisFiber(exit: Exit[Any, Any])(implicit trace: Trace): UIO[Resource.ExitCase] =
exit match {
case Exit.Success(_) =>
ZIO.succeedNow(Resource.ExitCase.Succeeded)
ZIO.succeed(Resource.ExitCase.Succeeded)
case Exit.Failure(cause) =>
lazy val nonCanceledOutcome: UIO[Resource.ExitCase] = cause.failureOrCause match {
case Left(error: Throwable) =>
ZIO.succeedNow(Resource.ExitCase.Errored(error))
ZIO.succeed(Resource.ExitCase.Errored(error))
case Left(_) =>
ZIO.succeedNow(Resource.ExitCase.Errored(FiberFailure(cause)))
ZIO.succeed(Resource.ExitCase.Errored(FiberFailure(cause)))
case Right(cause) =>
ZIO.succeedNow(Resource.ExitCase.Errored(dieCauseToThrowable(cause)))
ZIO.succeed(Resource.ExitCase.Errored(dieCauseToThrowable(cause)))
}
// ZIO 2, unlike ZIO 1, _does not_ guarantee that the presence of a typed failure
// means we're NOT interrupting, so we have to check for interruption to matter what
Expand All @@ -179,7 +179,7 @@ package object interop {
) {
ZIO.descriptorWith { descriptor =>
if (descriptor.interrupters.nonEmpty) {
ZIO.succeedNow(Resource.ExitCase.Canceled)
ZIO.succeed(Resource.ExitCase.Canceled)
} else
nonCanceledOutcome
}
Expand Down