ZIO

object ZIO
Companion:
class
class Object
trait Matchable
class Any
ZIO.type

Type members

Classlikes

final class AccessMPartiallyApplied[R](dummy: Boolean) extends AnyVal
final class AccessPartiallyApplied[R](dummy: Boolean) extends AnyVal
final class BracketAcquire[-R, +E, +A](acquire: ZIO[R, E, A]) extends AnyVal
final class BracketAcquire_[-R, +E](acquire: ZIO[R, E, Any]) extends AnyVal
final class BracketExitAcquire[-R, +E, +A](acquire: ZIO[R, E, A]) extends AnyVal
final class BracketExitRelease[-R, +E, E1, +A, B](acquire: ZIO[R, E, A], release: (A, Exit[E1, B]) => URIO[R, Any])
final class BracketRelease[-R, +E, +A](acquire: ZIO[R, E, A], release: A => URIO[R, Any])
final class BracketReleaseFn[R, E, A, B](val underlying: A => URIO[R, Any])
final class BracketRelease_[-R, +E](acquire: ZIO[R, E, Any], release: URIO[R, Any])
@implicitNotFound("Pattern guards are only supported when the error type is a supertype of NoSuchElementException. However, your effect has ${E} for the error type.")
abstract class CanFilter[+E]
Companion:
object
object CanFilter
Companion:
class
final class ConstFn[A, B](val underlying: () => B)
final class ConstZIOFn[R, E, A, B](val underlying: () => B)
final class FoldCauseMFailureFn[R, E, E2, A](val underlying: E => ZIO[R, E2, A])
final class FoldCauseMFailureTraceFn[R, E, E2, A](val underlying: (E, Option[ZTrace]) => ZIO[R, E2, A])
final class ForkScopeRestore(scope: ZScope[Exit[Any, Any]]) extends AnyVal
final class Grafter(scope: ZScope[Exit[Any, Any]]) extends AnyVal
final class IfM[R, E](b: ZIO[R, E, Boolean]) extends AnyVal
final class InterruptStatusRestore(flag: InterruptStatus) extends AnyVal
final class MapErrorCauseFn[R, E, E2, A](val underlying: Cause[E] => Cause[E2])
final class MapErrorFn[R, E, E2, A](val underlying: E => E2)
final class MapFn[R, E, A, B](val underlying: A => B)
final class ProvideSomeLayer[R0 <: Has[_], -R, +E, +A](self: ZIO[R, E, A]) extends AnyVal
final class ServiceWithPartiallyApplied[Service](dummy: Boolean) extends AnyVal
final class SucceedFn[R, E, A](val underlying: AnyRef)
final class TapCauseRefailFn[R, E, E1 >: E, A](val underlying: Cause[E] => ZIO[R, E1, Any])
final class TapDefectRefailFn[R, E, E1 >: E](val underlying: Cause[Nothing] => ZIO[R, E, Any])
final class TapErrorRefailFn[R, E, E1 >: E, A](val underlying: E => ZIO[R, E1, Any])
final class TapErrorTraceRefailFn[R, E, E1 >: E, A](val underlying: (E, Option[ZTrace]) => ZIO[R, E1, Any])
final class TapFn[R, E, A](val underlying: A => ZIO[R, E, Any])
final class TimeoutTo[-R, +E, +A, +B](self: ZIO[R, E, A], b: B)
final class UnlessM[R, E](b: ZIO[R, E, Boolean]) extends AnyVal
final class UpdateService[-R, +E, +A, M](self: ZIO[R, E, A]) extends AnyVal
final class WhenM[R, E](b: ZIO[R, E, Boolean]) extends AnyVal
final implicit class ZIOAutoCloseableOps[R, E, A <: AutoCloseable](io: ZIO[R, E, A]) extends AnyVal
final implicit class ZIOWithFilterOps[R, E, A](self: ZIO[R, E, A]) extends AnyVal
final implicit class ZioRefineToOrDieOps[R, E <: Throwable, A](self: ZIO[R, E, A]) extends AnyVal
final class ZipLeftFn[R, E, A, B](val underlying: () => ZIO[R, E, A])
final class ZipRightFn[R, E, A, B](val underlying: () => ZIO[R, E, B])

Value members

Concrete methods

def absolve[R, E, A](v: ZIO[R, E, Either[E, A]]): ZIO[R, E, A]

Submerges the error case of an Either into the ZIO. The inverse operation of IO.either.

Submerges the error case of an Either into the ZIO. The inverse operation of IO.either.

Accesses the environment of the effect.

Accesses the environment of the effect.

val portNumber = effect.access(_.config.portNumber)

Effectfully accesses the environment of the effect.

Effectfully accesses the environment of the effect.

Makes an explicit check to see if the fiber has been interrupted, and if so, performs self-interruption

Makes an explicit check to see if the fiber has been interrupted, and if so, performs self-interruption

def apply[A](a: => A): Task[A]
def bracket[R, E, A](acquire: ZIO[R, E, A]): BracketAcquire[R, E, A]

When this effect represents acquisition of a resource (for example, opening a file, launching a thread, etc.), bracket can be used to ensure the acquisition is not interrupted and the resource is always released.

When this effect represents acquisition of a resource (for example, opening a file, launching a thread, etc.), bracket can be used to ensure the acquisition is not interrupted and the resource is always released.

The function does two things:

  1. Ensures this effect, which acquires the resource, will not be interrupted. Of course, acquisition may fail for internal reasons (an uncaught exception). 2. Ensures the release effect will not be interrupted, and will be executed so long as this effect successfully acquires the resource.

In between acquisition and release of the resource, the use effect is executed.

If the release effect fails, then the entire effect will fail even if the use effect succeeds. If this fail-fast behavior is not desired, errors produced by the release effect can be caught and ignored.

openFile("data.json").bracket(closeFile) { file =>
 for {
   header <- readHeader(file)
   ...
 } yield result
}
def bracket[R, E, A, B](acquire: ZIO[R, E, A], release: A => URIO[R, Any], use: A => ZIO[R, E, B]): ZIO[R, E, B]

Uncurried version. Doesn't offer curried syntax and have worse type-inference characteristics, but guarantees no extra allocations of intermediate zio.ZIO.BracketAcquire and zio.ZIO.BracketRelease objects.

Uncurried version. Doesn't offer curried syntax and have worse type-inference characteristics, but guarantees no extra allocations of intermediate zio.ZIO.BracketAcquire and zio.ZIO.BracketRelease objects.

def bracketExit[R, E, A](acquire: ZIO[R, E, A]): BracketExitAcquire[R, E, A]

Acquires a resource, uses the resource, and then releases the resource. Neither the acquisition nor the release will be interrupted, and the resource is guaranteed to be released, so long as the acquire effect succeeds. If use fails, then after release, the returned effect will fail with the same error.

Acquires a resource, uses the resource, and then releases the resource. Neither the acquisition nor the release will be interrupted, and the resource is guaranteed to be released, so long as the acquire effect succeeds. If use fails, then after release, the returned effect will fail with the same error.

def bracketExit[R, E, A, B](acquire: ZIO[R, E, A], release: (A, Exit[E, B]) => URIO[R, Any], use: A => ZIO[R, E, B]): ZIO[R, E, B]

Uncurried version. Doesn't offer curried syntax and has worse type-inference characteristics, but guarantees no extra allocations of intermediate zio.ZIO.BracketExitAcquire and zio.ZIO.BracketExitRelease objects.

Uncurried version. Doesn't offer curried syntax and has worse type-inference characteristics, but guarantees no extra allocations of intermediate zio.ZIO.BracketExitAcquire and zio.ZIO.BracketExitRelease objects.

def checkInterruptible[R, E, A](f: InterruptStatus => ZIO[R, E, A]): ZIO[R, E, A]

Checks the interrupt status, and produces the effect returned by the specified callback.

Checks the interrupt status, and produces the effect returned by the specified callback.

def checkTraced[R, E, A](f: TracingStatus => ZIO[R, E, A]): ZIO[R, E, A]

Checks the ZIO Tracing status, and produces the effect returned by the specified callback.

Checks the ZIO Tracing status, and produces the effect returned by the specified callback.

def collect[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, Option[E], B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Evaluate each effect in the structure from left to right, collecting the the successful values and discarding the empty cases. For a parallel version, see collectPar.

Evaluate each effect in the structure from left to right, collecting the the successful values and discarding the empty cases. For a parallel version, see collectPar.

def collectAll[R, E, A, Collection <: (Iterable)](in: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): ZIO[R, E, Collection[A]]

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

def collectAll[R, E, A](in: Set[ZIO[R, E, A]]): ZIO[R, E, Set[A]]

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

def collectAll[R, E, A : ClassTag](in: Array[ZIO[R, E, A]]): ZIO[R, E, Array[A]]

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

def collectAll[R, E, A](in: Option[ZIO[R, E, A]]): ZIO[R, E, Option[A]]

Evaluate effect if present, and return its result as Option[A].

Evaluate effect if present, and return its result as Option[A].

def collectAll[R, E, A](in: NonEmptyChunk[ZIO[R, E, A]]): ZIO[R, E, NonEmptyChunk[A]]

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

Evaluate each effect in the structure from left to right, and collect the results. For a parallel version, see collectAllPar.

def collectAllPar[R, E, A, Collection <: (Iterable)](as: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): ZIO[R, E, Collection[A]]

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

def collectAllPar[R, E, A](as: Set[ZIO[R, E, A]]): ZIO[R, E, Set[A]]

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

def collectAllPar[R, E, A : ClassTag](as: Array[ZIO[R, E, A]]): ZIO[R, E, Array[A]]

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

def collectAllPar[R, E, A](as: NonEmptyChunk[ZIO[R, E, A]]): ZIO[R, E, NonEmptyChunk[A]]

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

def collectAllParN[R, E, A, Collection <: (Iterable)](n: Int)(as: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): ZIO[R, E, Collection[A]]

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Evaluate each effect in the structure in parallel, and collect the results. For a sequential version, see collectAll.

Unlike collectAllPar, this method will use at most n fibers.

def collectAllParN_[R, E, A](n: Int)(as: Iterable[ZIO[R, E, A]]): ZIO[R, E, Unit]

Evaluate each effect in the structure in parallel, and discard the results. For a sequential version, see collectAll_.

Evaluate each effect in the structure in parallel, and discard the results. For a sequential version, see collectAll_.

Unlike collectAllPar_, this method will use at most n fibers.

def collectAllPar_[R, E, A](as: Iterable[ZIO[R, E, A]]): ZIO[R, E, Unit]

Evaluate each effect in the structure in parallel, and discard the results. For a sequential version, see collectAll_.

Evaluate each effect in the structure in parallel, and discard the results. For a sequential version, see collectAll_.

def collectAllSuccesses[R, E, A, Collection <: (Iterable)](in: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): URIO[R, Collection[A]]

Evaluate and run each effect in the structure and collect discarding failed ones.

Evaluate and run each effect in the structure and collect discarding failed ones.

def collectAllSuccessesPar[R, E, A, Collection <: (Iterable)](in: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): URIO[R, Collection[A]]

Evaluate and run each effect in the structure in parallel, and collect discarding failed ones.

Evaluate and run each effect in the structure in parallel, and collect discarding failed ones.

def collectAllSuccessesParN[R, E, A, Collection <: (Iterable)](n: Int)(in: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): URIO[R, Collection[A]]

Evaluate and run each effect in the structure in parallel, and collect discarding failed ones.

Evaluate and run each effect in the structure in parallel, and collect discarding failed ones.

Unlike collectAllSuccessesPar, this method will use at most up to n fibers.

def collectAllWith[R, E, A, B, Collection <: (Iterable)](in: Collection[ZIO[R, E, A]])(f: PartialFunction[A, B])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], B, Collection[B]]): ZIO[R, E, Collection[B]]

Evaluate each effect in the structure with collectAll, and collect the results with given partial function.

Evaluate each effect in the structure with collectAll, and collect the results with given partial function.

def collectAllWithPar[R, E, A, U, Collection <: (Iterable)](in: Collection[ZIO[R, E, A]])(f: PartialFunction[A, U])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], U, Collection[U]]): ZIO[R, E, Collection[U]]

Evaluate each effect in the structure with collectAllPar, and collect the results with given partial function.

Evaluate each effect in the structure with collectAllPar, and collect the results with given partial function.

def collectAllWithParN[R, E, A, B, Collection <: (Iterable)](n: Int)(in: Collection[ZIO[R, E, A]])(f: PartialFunction[A, B])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], B, Collection[B]]): ZIO[R, E, Collection[B]]

Evaluate each effect in the structure with collectAllPar, and collect the results with given partial function.

Evaluate each effect in the structure with collectAllPar, and collect the results with given partial function.

Unlike collectAllWithPar, this method will use at most up to n fibers.

def collectAll_[R, E, A](in: Iterable[ZIO[R, E, A]]): ZIO[R, E, Unit]

Evaluate each effect in the structure from left to right, and discard the results. For a parallel version, see collectAllPar_.

Evaluate each effect in the structure from left to right, and discard the results. For a parallel version, see collectAllPar_.

def collectFirst[R, E, A, B](as: Iterable[A])(f: A => ZIO[R, E, Option[B]]): ZIO[R, E, Option[B]]

Collects the first element of the Iterable[A] for which the effectual function f returns Some.

Collects the first element of the Iterable[A] for which the effectual function f returns Some.

def collectPar[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, Option[E], B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Evaluate each effect in the structure in parallel, collecting the the successful values and discarding the empty cases.

Evaluate each effect in the structure in parallel, collecting the the successful values and discarding the empty cases.

def collectParN[R, E, A, B, Collection <: (Iterable)](n: Int)(in: Collection[A])(f: A => ZIO[R, Option[E], B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Evaluate each effect in the structure in parallel, collecting the the successful values and discarding the empty cases.

Evaluate each effect in the structure in parallel, collecting the the successful values and discarding the empty cases.

Unlike collectPar, this method will use at most up to n fibers.

def cond[E, A](predicate: Boolean, result: => A, error: => E): IO[E, A]

Similar to Either.cond, evaluate the predicate, return the given A as success if predicate returns true, and the given E as error otherwise

Similar to Either.cond, evaluate the predicate, return the given A as success if predicate returns true, and the given E as error otherwise

For effectful conditionals, see ZIO.ifM

def debug(value: Any): UIO[Unit]

Prints the specified message to the console for debugging purposes.

Prints the specified message to the console for debugging purposes.

Returns information about the current fiber, such as its identity.

Returns information about the current fiber, such as its identity.

def descriptorWith[R, E, A](f: Descriptor => ZIO[R, E, A]): ZIO[R, E, A]

Constructs an effect based on information about the current fiber, such as its identity.

Constructs an effect based on information about the current fiber, such as its identity.

def die(t: => Throwable): UIO[Nothing]

Returns an effect that dies with the specified Throwable. This method can be used for terminating a fiber because a defect has been detected in the code.

Returns an effect that dies with the specified Throwable. This method can be used for terminating a fiber because a defect has been detected in the code.

def dieMessage(message: => String): UIO[Nothing]

Returns an effect that dies with a java.lang.RuntimeException having the specified text message. This method can be used for terminating a fiber because a defect has been detected in the code.

Returns an effect that dies with a java.lang.RuntimeException having the specified text message. This method can be used for terminating a fiber because a defect has been detected in the code.

def done[E, A](r: => Exit[E, A]): IO[E, A]

Returns an effect from a zio.Exit value.

Returns an effect from a zio.Exit value.

def effect[A](effect: => A): Task[A]

Imports a synchronous side-effect into a pure ZIO value, translating any thrown exceptions into typed failed effects creating with ZIO.fail.

Imports a synchronous side-effect into a pure ZIO value, translating any thrown exceptions into typed failed effects creating with ZIO.fail.

def putStrLn(line: String): Task[Unit] = Task.effect(println(line))
def effectAsync[R, E, A](register: ZIO[R, E, A] => Unit => Any, blockingOn: List[Id]): ZIO[R, E, A]

Imports an asynchronous side-effect into a pure ZIO value. See effectAsyncMaybe for the more expressive variant of this function that can return a value synchronously.

Imports an asynchronous side-effect into a pure ZIO value. See effectAsyncMaybe for the more expressive variant of this function that can return a value synchronously.

The callback function ZIO[R, E, A] => Any must be called at most once.

The list of fibers, that may complete the async callback, is used to provide better diagnostics.

def effectAsyncInterrupt[R, E, A](register: ZIO[R, E, A] => Unit => Either[Canceler[R], ZIO[R, E, A]], blockingOn: List[Id]): ZIO[R, E, A]

Imports an asynchronous side-effect into a ZIO effect. The side-effect has the option of returning the value synchronously, which is useful in cases where it cannot be determined if the effect is synchronous or asynchronous until the side-effect is actually executed. The effect also has the option of returning a canceler, which will be used by the runtime to cancel the asynchronous effect if the fiber executing the effect is interrupted.

Imports an asynchronous side-effect into a ZIO effect. The side-effect has the option of returning the value synchronously, which is useful in cases where it cannot be determined if the effect is synchronous or asynchronous until the side-effect is actually executed. The effect also has the option of returning a canceler, which will be used by the runtime to cancel the asynchronous effect if the fiber executing the effect is interrupted.

If the register function returns a value synchronously, then the callback function ZIO[R, E, A] => Any must not be called. Otherwise the callback function must be called at most once.

The list of fibers, that may complete the async callback, is used to provide better diagnostics.

def effectAsyncM[R, E, A](register: ZIO[R, E, A] => Unit => ZIO[R, E, Any]): ZIO[R, E, A]

Imports an asynchronous effect into a pure ZIO value. This formulation is necessary when the effect is itself expressed in terms of ZIO.

Imports an asynchronous effect into a pure ZIO value. This formulation is necessary when the effect is itself expressed in terms of ZIO.

def effectAsyncMaybe[R, E, A](register: ZIO[R, E, A] => Unit => Option[ZIO[R, E, A]], blockingOn: List[Id]): ZIO[R, E, A]

Imports an asynchronous effect into a pure ZIO value, possibly returning the value synchronously.

Imports an asynchronous effect into a pure ZIO value, possibly returning the value synchronously.

If the register function returns a value synchronously, then the callback function ZIO[R, E, A] => Any must not be called. Otherwise the callback function must be called at most once.

The list of fibers, that may complete the async callback, is used to provide better diagnostics.

def effectSuspend[R, A](rio: => RIO[R, A]): RIO[R, A]

Returns a lazily constructed effect, whose construction may itself require effects. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effect(io)).

Returns a lazily constructed effect, whose construction may itself require effects. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effect(io)).

def effectSuspendTotal[R, E, A](zio: => ZIO[R, E, A]): ZIO[R, E, A]

Returns a lazily constructed effect, whose construction may itself require effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effectTotal(zio)). If you wonder if the effect throws exceptions, do not use this method, use Task.effectSuspend or ZIO.effectSuspend.

Returns a lazily constructed effect, whose construction may itself require effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effectTotal(zio)). If you wonder if the effect throws exceptions, do not use this method, use Task.effectSuspend or ZIO.effectSuspend.

def effectSuspendTotalWith[R, E, A](f: (Platform, Id) => ZIO[R, E, A]): ZIO[R, E, A]

Returns a lazily constructed effect, whose construction may itself require effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effectTotal(zio)). If you wonder if the effect throws exceptions, do not use this method, use Task.effectSuspend or ZIO.effectSuspend.

Returns a lazily constructed effect, whose construction may itself require effects. The effect must not throw any exceptions. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effectTotal(zio)). If you wonder if the effect throws exceptions, do not use this method, use Task.effectSuspend or ZIO.effectSuspend.

def effectSuspendWith[R, A](f: (Platform, Id) => RIO[R, A]): RIO[R, A]

Returns a lazily constructed effect, whose construction may itself require effects. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effect(io)).

Returns a lazily constructed effect, whose construction may itself require effects. When no environment is required (i.e., when R == Any) it is conceptually equivalent to flatten(effect(io)).

def effectTotal[A](effect: => A): UIO[A]

Imports a total synchronous effect into a pure ZIO value. The effect must not throw any exceptions. If you wonder if the effect throws exceptions, then do not use this method, use Task.effect, IO.effect, or ZIO.effect.

Imports a total synchronous effect into a pure ZIO value. The effect must not throw any exceptions. If you wonder if the effect throws exceptions, then do not use this method, use Task.effect, IO.effect, or ZIO.effect.

val nanoTime: UIO[Long] = IO.effectTotal(System.nanoTime())
def environment[R]: URIO[R, R]

Accesses the whole environment of the effect.

Accesses the whole environment of the effect.

Retrieves the executor for this effect.

Retrieves the executor for this effect.

def exists[R, E, A](as: Iterable[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Boolean]

Determines whether any element of the Iterable[A] satisfies the effectual predicate f.

Determines whether any element of the Iterable[A] satisfies the effectual predicate f.

def fail[E](error: => E): IO[E, Nothing]

Returns an effect that models failure with the specified error. The moral equivalent of throw for pure code.

Returns an effect that models failure with the specified error. The moral equivalent of throw for pure code.

def filter[R, E, A, Collection <: (Iterable)](as: Collection[A])(f: A => ZIO[R, E, Boolean])(implicit bf: BuildFrom[Collection[A], A, Collection[A]]): ZIO[R, E, Collection[A]]

Filters the collection using the specified effectual predicate.

Filters the collection using the specified effectual predicate.

def filter[R, E, A](as: Set[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Set[A]]

Filters the Set[A] using the specified effectual predicate.

Filters the Set[A] using the specified effectual predicate.

def filterNot[R, E, A, Collection <: (Iterable)](as: Collection[A])(f: A => ZIO[R, E, Boolean])(implicit bf: BuildFrom[Collection[A], A, Collection[A]]): ZIO[R, E, Collection[A]]

Filters the collection using the specified effectual predicate, removing all elements that satisfy the predicate.

Filters the collection using the specified effectual predicate, removing all elements that satisfy the predicate.

def filterNot[R, E, A](as: Set[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Set[A]]

Filters the Set[A] using the specified effectual predicate, removing all elements that satisfy the predicate.

Filters the Set[A] using the specified effectual predicate, removing all elements that satisfy the predicate.

def filterNotPar[R, E, A, Collection <: (Iterable)](as: Collection[A])(f: A => ZIO[R, E, Boolean])(implicit bf: BuildFrom[Collection[A], A, Collection[A]]): ZIO[R, E, Collection[A]]

Filters the collection in parallel using the specified effectual predicate, removing all elements that satisfy the predicate. See [[filterNot[R,E,A,Collection*]] for a sequential version of it.

Filters the collection in parallel using the specified effectual predicate, removing all elements that satisfy the predicate. See [[filterNot[R,E,A,Collection*]] for a sequential version of it.

def filterNotPar[R, E, A](as: Set[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Set[A]]

Filters the Set[A] in parallel using the specified effectual predicate, removing all elements that satisfy the predicate. See filterNot for a sequential version of it.

Filters the Set[A] in parallel using the specified effectual predicate, removing all elements that satisfy the predicate. See filterNot for a sequential version of it.

def filterPar[R, E, A, Collection <: (Iterable)](as: Collection[A])(f: A => ZIO[R, E, Boolean])(implicit bf: BuildFrom[Collection[A], A, Collection[A]]): ZIO[R, E, Collection[A]]

Filters the collection in parallel using the specified effectual predicate. See [[filter[R,E,A,Collection*]] for a sequential version of it.

Filters the collection in parallel using the specified effectual predicate. See [[filter[R,E,A,Collection*]] for a sequential version of it.

def filterPar[R, E, A](as: Set[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Set[A]]

Filters the Set[A] in parallel using the specified effectual predicate. See [[filter[R,E,A,Collection*]] for a sequential version of it.

Filters the Set[A] in parallel using the specified effectual predicate. See [[filter[R,E,A,Collection*]] for a sequential version of it.

def first[A]: ZIO[(A, Any), Nothing, A]

Returns an effectful function that extracts out the first element of a tuple.

Returns an effectful function that extracts out the first element of a tuple.

def firstSuccessOf[R, R1 <: R, E, A](zio: ZIO[R, E, A], rest: Iterable[ZIO[R1, E, A]]): ZIO[R1, E, A]

Returns an effect that runs the first effect and in case of failure, runs each of the specified effects in order until one of them succeeds.

Returns an effect that runs the first effect and in case of failure, runs each of the specified effects in order until one of them succeeds.

def flatten[R, E, A](zio: ZIO[R, E, ZIO[R, E, A]]): ZIO[R, E, A]

Returns an effect that first executes the outer effect, and then executes the inner effect, returning the value from the inner effect, and effectively flattening a nested effect.

Returns an effect that first executes the outer effect, and then executes the inner effect, returning the value from the inner effect, and effectively flattening a nested effect.

def foldLeft[R, E, S, A](in: Iterable[A])(zero: S)(f: (S, A) => ZIO[R, E, S]): ZIO[R, E, S]

Folds an Iterable[A] using an effectual function f, working sequentially from left to right.

Folds an Iterable[A] using an effectual function f, working sequentially from left to right.

def foldRight[R, E, S, A](in: Iterable[A])(zero: S)(f: (A, S) => ZIO[R, E, S]): ZIO[R, E, S]

Folds an Iterable[A] using an effectual function f, working sequentially from right to left.

Folds an Iterable[A] using an effectual function f, working sequentially from right to left.

def forall[R, E, A](as: Iterable[A])(f: A => ZIO[R, E, Boolean]): ZIO[R, E, Boolean]

Determines whether all elements of the Iterable[A] satisfy the effectual predicate f.

Determines whether all elements of the Iterable[A] satisfy the effectual predicate f.

def foreach[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Applies the function f to each element of the Collection[A] and returns the results in a new Collection[B].

Applies the function f to each element of the Collection[A] and returns the results in a new Collection[B].

For a parallel version of this method, see foreachPar. If you do not need the results, see foreach_ for a more efficient implementation.

final def foreach[R, E, A, B](in: Set[A])(f: A => ZIO[R, E, B]): ZIO[R, E, Set[B]]

Applies the function f to each element of the Set[A] and returns the results in a new Set[B].

Applies the function f to each element of the Set[A] and returns the results in a new Set[B].

For a parallel version of this method, see foreachPar. If you do not need the results, see foreach_ for a more efficient implementation.

final def foreach[R, E, A, B : ClassTag](in: Array[A])(f: A => ZIO[R, E, B]): ZIO[R, E, Array[B]]

Applies the function f to each element of the Array[A] and returns the results in a new Array[B].

Applies the function f to each element of the Array[A] and returns the results in a new Array[B].

For a parallel version of this method, see foreachPar. If you do not need the results, see foreach_ for a more efficient implementation.

def foreach[R, E, Key, Key2, Value, Value2](map: Map[Key, Value])(f: (Key, Value) => ZIO[R, E, (Key2, Value2)]): ZIO[R, E, Map[Key2, Value2]]

Applies the function f to each element of the Map[Key, Value] and returns the results in a new Map[Key2, Value2].

Applies the function f to each element of the Map[Key, Value] and returns the results in a new Map[Key2, Value2].

For a parallel version of this method, see foreachPar. If you do not need the results, see foreach_ for a more efficient implementation.

final def foreach[R, E, A, B](in: Option[A])(f: A => ZIO[R, E, B]): ZIO[R, E, Option[B]]

Applies the function f if the argument is non-empty and returns the results in a new Option[B].

Applies the function f if the argument is non-empty and returns the results in a new Option[B].

final def foreach[R, E, A, B](in: NonEmptyChunk[A])(f: A => ZIO[R, E, B]): ZIO[R, E, NonEmptyChunk[B]]

Applies the function f to each element of the NonEmptyChunk[A] and returns the results in a new NonEmptyChunk[B].

Applies the function f to each element of the NonEmptyChunk[A] and returns the results in a new NonEmptyChunk[B].

For a parallel version of this method, see foreachPar. If you do not need the results, see foreach_ for a more efficient implementation.

final def foreachExec[R, E, A, B, Collection <: (Iterable)](as: Collection[A])(exec: ExecutionStrategy)(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Applies the function f to each element of the Collection[A] and returns the result in a new Collection[B] using the specified execution strategy.

Applies the function f to each element of the Collection[A] and returns the result in a new Collection[B] using the specified execution strategy.

def foreachPar[R, E, A, B, Collection <: (Iterable)](as: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Applies the function f to each element of the Collection[A] in parallel, and returns the results in a new Collection[B].

Applies the function f to each element of the Collection[A] in parallel, and returns the results in a new Collection[B].

For a sequential version of this method, see foreach.

final def foreachPar[R, E, A, B](as: Set[A])(fn: A => ZIO[R, E, B]): ZIO[R, E, Set[B]]

Applies the function f to each element of the Set[A] in parallel, and returns the results in a new Set[B].

Applies the function f to each element of the Set[A] in parallel, and returns the results in a new Set[B].

For a sequential version of this method, see foreach.

final def foreachPar[R, E, A, B : ClassTag](as: Array[A])(f: A => ZIO[R, E, B]): ZIO[R, E, Array[B]]

Applies the function f to each element of the Array[A] in parallel, and returns the results in a new Array[B].

Applies the function f to each element of the Array[A] in parallel, and returns the results in a new Array[B].

For a sequential version of this method, see foreach.

def foreachPar[R, E, Key, Key2, Value, Value2](map: Map[Key, Value])(f: (Key, Value) => ZIO[R, E, (Key2, Value2)]): ZIO[R, E, Map[Key2, Value2]]

Applies the function f to each element of the Map[Key, Value] in parallel and returns the results in a new Map[Key2, Value2].

Applies the function f to each element of the Map[Key, Value] in parallel and returns the results in a new Map[Key2, Value2].

For a sequential version of this method, see foreach.

final def foreachPar[R, E, A, B](as: NonEmptyChunk[A])(fn: A => ZIO[R, E, B]): ZIO[R, E, NonEmptyChunk[B]]

Applies the function f to each element of the NonEmptyChunk[A] in parallel, and returns the results in a new NonEmptyChunk[B].

Applies the function f to each element of the NonEmptyChunk[A] in parallel, and returns the results in a new NonEmptyChunk[B].

For a sequential version of this method, see foreach.

def foreachParN[R, E, A, B, Collection <: (Iterable)](n: Int)(as: Collection[A])(fn: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]]): ZIO[R, E, Collection[B]]

Applies the function f to each element of the Collection[A] in parallel, and returns the results in a new Collection[B].

Applies the function f to each element of the Collection[A] in parallel, and returns the results in a new Collection[B].

Unlike foreachPar, this method will use at most up to n fibers.

def foreachParN_[R, E, A](n: Int)(as: Iterable[A])(f: A => ZIO[R, E, Any]): ZIO[R, E, Unit]

Applies the function f to each element of the Iterable[A] and runs produced effects in parallel, discarding the results.

Applies the function f to each element of the Iterable[A] and runs produced effects in parallel, discarding the results.

Unlike foreachPar_, this method will use at most up to n fibers.

def foreachPar_[R, E, A](as: Iterable[A])(f: A => ZIO[R, E, Any]): ZIO[R, E, Unit]

Applies the function f to each element of the Iterable[A] and runs produced effects in parallel, discarding the results.

Applies the function f to each element of the Iterable[A] and runs produced effects in parallel, discarding the results.

For a sequential version of this method, see foreach_.

Optimized to avoid keeping full tree of effects, so that method could be able to handle large input sequences. Behaves almost like this code:

as.foldLeft(ZIO.unit) { (acc, a) => acc.zipParLeft(f(a)) }

Additionally, interrupts all effects on any failure.

def foreach_[R, E, A](as: Iterable[A])(f: A => ZIO[R, E, Any]): ZIO[R, E, Unit]

Applies the function f to each element of the Iterable[A] and runs produced effects sequentially.

Applies the function f to each element of the Iterable[A] and runs produced effects sequentially.

Equivalent to foreach(as)(f).unit, but without the cost of building the list of results.

def forkAll[R, E, A, Collection <: (Iterable)](as: Collection[ZIO[R, E, A]])(implicit bf: BuildFrom[Collection[ZIO[R, E, A]], A, Collection[A]]): URIO[R, Fiber[E, Collection[A]]]

Returns an effect that forks all of the specified values, and returns a composite fiber that produces a list of their results, in order.

Returns an effect that forks all of the specified values, and returns a composite fiber that produces a list of their results, in order.

def forkAll_[R, E, A](as: Iterable[ZIO[R, E, A]]): URIO[R, Unit]

Returns an effect that forks all of the specified values, and returns a composite fiber that produces unit. This version is faster than forkAll in cases where the results of the forked fibers are not needed.

Returns an effect that forks all of the specified values, and returns a composite fiber that produces unit. This version is faster than forkAll in cases where the results of the forked fibers are not needed.

def forkScope: UIO[ZScope[Exit[Any, Any]]]

Retrieves the scope that will be used to supervise forked effects.

Retrieves the scope that will be used to supervise forked effects.

def forkScopeMask[R, E, A](newScope: ZScope[Exit[Any, Any]])(f: ForkScopeRestore => ZIO[R, E, A]): ZIO[R, E, A]

Captures the fork scope, before overriding it with the specified new scope, passing a function that allows restoring the fork scope to what it was originally.

Captures the fork scope, before overriding it with the specified new scope, passing a function that allows restoring the fork scope to what it was originally.

def forkScopeWith[R, E, A](f: ZScope[Exit[Any, Any]] => ZIO[R, E, A]): ZIO[R, E, A]

Retrieves the scope that will be used to supervise forked effects.

Retrieves the scope that will be used to supervise forked effects.

def fromEither[E, A](v: => Either[E, A]): IO[E, A]

Lifts an Either into a ZIO value.

Lifts an Either into a ZIO value.

def fromFiber[E, A](fiber: => Fiber[E, A]): IO[E, A]

Creates a ZIO value that represents the exit value of the specified fiber.

Creates a ZIO value that represents the exit value of the specified fiber.

def fromFiberM[E, A](fiber: IO[E, Fiber[E, A]]): IO[E, A]

Creates a ZIO value that represents the exit value of the specified fiber.

Creates a ZIO value that represents the exit value of the specified fiber.

def fromFunction[R, A](f: R => A): URIO[R, A]

Lifts a function R => A into a URIO[R, A].

Lifts a function R => A into a URIO[R, A].

def fromFunctionFuture[R, A](f: R => Future[A]): RIO[R, A]

Lifts a function returning Future into an effect that requires the input to the function.

Lifts a function returning Future into an effect that requires the input to the function.

def fromFunctionM[R, E, A](f: R => IO[E, A]): ZIO[R, E, A]

Lifts an effectful function whose effect requires no environment into an effect that requires the input to the function.

Lifts an effectful function whose effect requires no environment into an effect that requires the input to the function.

def fromFuture[A](make: ExecutionContext => Future[A]): Task[A]

Imports a function that creates a scala.concurrent.Future from an scala.concurrent.ExecutionContext into a ZIO.

Imports a function that creates a scala.concurrent.Future from an scala.concurrent.ExecutionContext into a ZIO.

Imports a function that creates a scala.concurrent.Future from an scala.concurrent.ExecutionContext into a ZIO. The provided ExecutionContext will interrupt the Future between asynchronous operations such as map and flatMap if this effect is interrupted. Note that no attempt will be made to interrupt a Future blocking on a synchronous operation and that the Future must be created using the provided ExecutionContext.

Imports a function that creates a scala.concurrent.Future from an scala.concurrent.ExecutionContext into a ZIO. The provided ExecutionContext will interrupt the Future between asynchronous operations such as map and flatMap if this effect is interrupted. Note that no attempt will be made to interrupt a Future blocking on a synchronous operation and that the Future must be created using the provided ExecutionContext.

def fromOption[A](v: => Option[A]): IO[Option[Nothing], A]

Lifts an Option into a ZIO but preserves the error as an option in the error channel, making it easier to compose in some scenarios.

Lifts an Option into a ZIO but preserves the error as an option in the error channel, making it easier to compose in some scenarios.

def fromPromiseScala[A](promise: Promise[A]): Task[A]

Imports a scala.concurrent.Promise we generate a future from promise, and we pass to [fromFuture] to transform into Task[A]

Imports a scala.concurrent.Promise we generate a future from promise, and we pass to [fromFuture] to transform into Task[A]

def fromTry[A](value: => Try[A]): Task[A]

Lifts a Try into a ZIO.

Lifts a Try into a ZIO.

final def getOrFail[A](v: => Option[A]): Task[A]

Lifts an Option into a ZIO, if the option is not defined it fails with NoSuchElementException.

Lifts an Option into a ZIO, if the option is not defined it fails with NoSuchElementException.

final def getOrFailUnit[A](v: => Option[A]): IO[Unit, A]

Lifts an Option into a IO, if the option is not defined it fails with Unit.

Lifts an Option into a IO, if the option is not defined it fails with Unit.

final def getOrFailWith[E, A](e: => E)(v: => Option[A]): IO[E, A]

Lifts an Option into a ZIO. If the option is not defined, fail with the e value.

Lifts an Option into a ZIO. If the option is not defined, fail with the e value.

def halt[E](cause: => Cause[E]): IO[E, Nothing]

Returns an effect that models failure with the specified Cause.

Returns an effect that models failure with the specified Cause.

def haltWith[E](function: () => ZTrace => Cause[E]): IO[E, Nothing]

Returns an effect that models failure with the specified Cause.

Returns an effect that models failure with the specified Cause.

This version takes in a lazily-evaluated trace that can be attached to the Cause via Cause.Traced.

def identity[R]: URIO[R, R]

Returns the identity effectful function, which performs no effects

Returns the identity effectful function, which performs no effects

def ifM[R, E](b: ZIO[R, E, Boolean]): IfM[R, E]

Runs onTrue if the result of b is true and onFalse otherwise.

Runs onTrue if the result of b is true and onFalse otherwise.

def interruptAs(fiberId: => Id): UIO[Nothing]

Returns an effect that is interrupted as if by the specified fiber.

Returns an effect that is interrupted as if by the specified fiber.

def interruptible[R, E, A](zio: ZIO[R, E, A]): ZIO[R, E, A]

Prefix form of ZIO#interruptible.

Prefix form of ZIO#interruptible.

def interruptibleMask[R, E, A](k: InterruptStatusRestore => ZIO[R, E, A]): ZIO[R, E, A]

Makes the effect interruptible, but passes it a restore function that can be used to restore the inherited interruptibility from whatever region the effect is composed into.

Makes the effect interruptible, but passes it a restore function that can be used to restore the inherited interruptibility from whatever region the effect is composed into.

def iterate[R, E, S](initial: S)(cont: S => Boolean)(body: S => ZIO[R, E, S]): ZIO[R, E, S]

Iterates with the specified effectual function. The moral equivalent of:

Iterates with the specified effectual function. The moral equivalent of:

var s = initial

while (cont(s)) {
 s = body(s)
}

s
def left[A](a: => A): UIO[Either[A, Nothing]]

Returns an effect with the value on the left part.

Returns an effect with the value on the left part.

def lock[R, E, A](executor: => Executor)(zio: ZIO[R, E, A]): ZIO[R, E, A]

Returns an effect that will execute the specified effect fully on the provided executor, before returning to the default executor. See ZIO!.lock.

Returns an effect that will execute the specified effect fully on the provided executor, before returning to the default executor. See ZIO!.lock.

def loop[R, E, A, S](initial: S)(cont: S => Boolean, inc: S => S)(body: S => ZIO[R, E, A]): ZIO[R, E, List[A]]

Loops with the specified effectual function, collecting the results into a list. The moral equivalent of:

Loops with the specified effectual function, collecting the results into a list. The moral equivalent of:

var s  = initial
var as = List.empty[A]

while (cont(s)) {
 as = body(s) :: as
 s  = inc(s)
}

as.reverse
def loop_[R, E, S](initial: S)(cont: S => Boolean, inc: S => S)(body: S => ZIO[R, E, Any]): ZIO[R, E, Unit]

Loops with the specified effectual function purely for its effects. The moral equivalent of:

Loops with the specified effectual function purely for its effects. The moral equivalent of:

var s = initial

while (cont(s)) {
 body(s)
 s = inc(s)
}
def mapN[R, E, A, B, C](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B])(f: (A, B) => C): ZIO[R, E, C]

Sequentially zips the specified effects using the specified combiner function.

Sequentially zips the specified effects using the specified combiner function.

def mapN[R, E, A, B, C, D](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C])(f: (A, B, C) => D): ZIO[R, E, D]

Sequentially zips the specified effects using the specified combiner function.

Sequentially zips the specified effects using the specified combiner function.

def mapN[R, E, A, B, C, D, F](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C], zio4: ZIO[R, E, D])(f: (A, B, C, D) => F): ZIO[R, E, F]

Sequentially zips the specified effects using the specified combiner function.

Sequentially zips the specified effects using the specified combiner function.

def mapParN[R, E, A, B, C](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B])(f: (A, B) => C): ZIO[R, E, C]

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

def mapParN[R, E, A, B, C, D](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C])(f: (A, B, C) => D): ZIO[R, E, D]

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

def mapParN[R, E, A, B, C, D, F](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C], zio4: ZIO[R, E, D])(f: (A, B, C, D) => F): ZIO[R, E, F]

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

Returns an effect that executes the specified effects in parallel, combining their results with the specified f function. If any effect fails, then the other effects will be interrupted.

def memoize[R, E, A, B](f: A => ZIO[R, E, B]): UIO[A => ZIO[R, E, B]]

Returns a memoized version of the specified effectual function.

Returns a memoized version of the specified effectual function.

def mergeAll[R, E, A, B](in: Iterable[ZIO[R, E, A]])(zero: B)(f: (B, A) => B): ZIO[R, E, B]

Merges an Iterable[IO] to a single IO, working sequentially.

Merges an Iterable[IO] to a single IO, working sequentially.

def mergeAllPar[R, E, A, B](in: Iterable[ZIO[R, E, A]])(zero: B)(f: (B, A) => B): ZIO[R, E, B]

Merges an Iterable[IO] to a single IO, working in parallel.

Merges an Iterable[IO] to a single IO, working in parallel.

Due to the parallel nature of this combinator, f must be both:

  • commutative: f(a, b) == f(b, a)
  • associative: f(a, f(b, c)) == f(f(a, b), c)

It's unsafe to execute side effects inside f, as f may be executed more than once for some of in elements during effect execution.

def mergeAllParN[R, E, A, B](n: Int)(in: Iterable[ZIO[R, E, A]])(zero: B)(f: (B, A) => B): ZIO[R, E, B]

Merges an Iterable[IO] to a single IO, working in with up to n fibers in parallel.

Merges an Iterable[IO] to a single IO, working in with up to n fibers in parallel.

Due to the parallel nature of this combinator, f must be both:

  • commutative: f(a, b) == f(b, a)
  • associative: f(a, f(b, c)) == f(f(a, b), c)

It's unsafe to execute side effects inside f, as f may be executed more than once for some of in elements during effect execution.

def noneOrFail[E](o: Option[E]): IO[E, Unit]

Lifts an Option into a IO. If the option is empty it succeeds with Unit. If the option is defined it fails with the content.

Lifts an Option into a IO. If the option is empty it succeeds with Unit. If the option is defined it fails with the content.

def noneOrFailWith[E, O](o: Option[O])(f: O => E): IO[E, Unit]

Lifts an Option into a IO. If the option is empty it succeeds with Unit. If the option is defined it fails with an error adapted with f.

Lifts an Option into a IO. If the option is empty it succeeds with Unit. If the option is defined it fails with an error adapted with f.

def not[R, E](effect: ZIO[R, E, Boolean]): ZIO[R, E, Boolean]

Returns a new effect where boolean value of this effect is negated.

Returns a new effect where boolean value of this effect is negated.

def partition[R, E, A, B](in: Iterable[A])(f: A => ZIO[R, E, B])(implicit ev: CanFail[E]): ZIO[R, Nothing, (Iterable[E], Iterable[B])]

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in a tupled fashion.

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in a tupled fashion.

def partitionPar[R, E, A, B](in: Iterable[A])(f: A => ZIO[R, E, B])(implicit ev: CanFail[E]): ZIO[R, Nothing, (Iterable[E], Iterable[B])]

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in parallel and returns the result as a tuple.

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in parallel and returns the result as a tuple.

def partitionParN[R, E, A, B](n: Int)(in: Iterable[A])(f: A => ZIO[R, E, B])(implicit ev: CanFail[E]): ZIO[R, Nothing, (Iterable[E], Iterable[B])]

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in parallel and returns the result as a tuple.

Feeds elements of type A to a function f that returns an effect. Collects all successes and failures in parallel and returns the result as a tuple.

Unlike partitionPar, this method will use at most up to n fibers.

def provide[R, E, A](r: => R): ZIO[R, E, A] => IO[E, A]

Given an environment R, returns a function that can supply the environment to programs that require it, removing their need for any specific environment.

Given an environment R, returns a function that can supply the environment to programs that require it, removing their need for any specific environment.

This is similar to dependency injection, and the provide function can be thought of as inject.

def raceAll[R, R1 <: R, E, A](zio: ZIO[R, E, A], ios: Iterable[ZIO[R1, E, A]]): ZIO[R1, E, A]

Races an IO[E, A] against zero or more other effects. Yields either the first success or the last failure.

Races an IO[E, A] against zero or more other effects. Yields either the first success or the last failure.

def raceFirst[R, R1 <: R, E, A](zio: ZIO[R, E, A], ios: Iterable[ZIO[R1, E, A]]): ZIO[R1, E, A]

Returns an effect that races this effect with all the specified effects, yielding the first result to complete, whether by success or failure. If neither effect completes, then the composed effect will not complete.

Returns an effect that races this effect with all the specified effects, yielding the first result to complete, whether by success or failure. If neither effect completes, then the composed effect will not complete.

WARNING: The raced effect will safely interrupt the "losers", but will not resume until the losers have been cleanly terminated. If early return is desired, then instead of performing ZIO.raceFirst(l, rs), perform ZIO.raceFirst(l.disconnect, rs.map(_.disconnect)), which disconnects left and rights interrupt signal, allowing a fast return, with interruption performed in the background.

def reduceAll[R, R1 <: R, E, A](a: ZIO[R, E, A], as: Iterable[ZIO[R1, E, A]])(f: (A, A) => A): ZIO[R1, E, A]

Reduces an Iterable[IO] to a single IO, working sequentially.

Reduces an Iterable[IO] to a single IO, working sequentially.

def reduceAllPar[R, R1 <: R, E, A](a: ZIO[R, E, A], as: Iterable[ZIO[R1, E, A]])(f: (A, A) => A): ZIO[R1, E, A]

Reduces an Iterable[IO] to a single IO, working in parallel.

Reduces an Iterable[IO] to a single IO, working in parallel.

def reduceAllParN[R, R1 <: R, E, A](n: Int)(a: ZIO[R, E, A], as: Iterable[ZIO[R1, E, A]])(f: (A, A) => A): ZIO[R1, E, A]

Reduces an Iterable[IO] to a single IO, working in up to n fibers in parallel.

Reduces an Iterable[IO] to a single IO, working in up to n fibers in parallel.

def replicate[R, E, A](n: Int)(effect: ZIO[R, E, A]): Iterable[ZIO[R, E, A]]

Replicates the given effect n times. If 0 or negative numbers are given, an empty Iterable will be returned. This method is more efficient than using List.fill or similar methods, because the returned Iterable consumes only a small amount of heap regardless of n.

Replicates the given effect n times. If 0 or negative numbers are given, an empty Iterable will be returned. This method is more efficient than using List.fill or similar methods, because the returned Iterable consumes only a small amount of heap regardless of n.

def replicateM[R, E, A](n: Int)(effect: ZIO[R, E, A]): ZIO[R, E, Iterable[A]]

Performs this effect the specified number of times and collects the results.

Performs this effect the specified number of times and collects the results.

def replicateM_[R, E, A](n: Int)(effect: ZIO[R, E, A]): ZIO[R, E, Unit]

Performs this effect the specified number of times, discarding the results.

Performs this effect the specified number of times, discarding the results.

def require[R, E, A](error: => E): ZIO[R, E, Option[A]] => ZIO[R, E, A]

Requires that the given ZIO[R, E, Option[A]] contain a value. If there is no value, then the specified error will be raised.

Requires that the given ZIO[R, E, Option[A]] contain a value. If there is no value, then the specified error will be raised.

def reserve[R, E, A, B](reservation: ZIO[R, E, Reservation[R, E, A]])(use: A => ZIO[R, E, B]): ZIO[R, E, B]

Acquires a resource, uses the resource, and then releases the resource. However, unlike bracket, the separation of these phases allows the acquisition to be interruptible.

Acquires a resource, uses the resource, and then releases the resource. However, unlike bracket, the separation of these phases allows the acquisition to be interruptible.

Useful for concurrent data structures and other cases where the 'deallocator' can tell if the allocation succeeded or not just by inspecting internal / external state.

def right[B](b: => B): UIO[Either[Nothing, B]]

Returns an effect with the value on the right part.

Returns an effect with the value on the right part.

def runtime[R]: URIO[R, Runtime[R]]

Returns an effect that accesses the runtime, which can be used to (unsafely) execute tasks. This is useful for integration with legacy code that must call back into ZIO code.

Returns an effect that accesses the runtime, which can be used to (unsafely) execute tasks. This is useful for integration with legacy code that must call back into ZIO code.

def scopeWith[R, E, A](f: ZScope[Exit[Any, Any]] => ZIO[R, E, A]): ZIO[R, E, A]

Passes the fiber's scope to the specified function, which creates an effect that will be returned from this method.

Passes the fiber's scope to the specified function, which creates an effect that will be returned from this method.

def second[A]: URIO[(Any, A), A]

Returns an effectful function that extracts out the second element of a tuple.

Returns an effectful function that extracts out the second element of a tuple.

def service[A : Tag]: URIO[Has[A], A]

Accesses the specified service in the environment of the effect.

Accesses the specified service in the environment of the effect.

Effectfully accesses the specified service in the environment of the effect.

Effectfully accesses the specified service in the environment of the effect.

Especially useful for creating "accessor" methods on Services' companion objects.

def foo(int: Int) = ZIO.serviceWith[Foo](_.foo(int))
def services[A : Tag, B : Tag]: URIO[Has[A] & Has[B], (A, B)]

Accesses the specified services in the environment of the effect.

Accesses the specified services in the environment of the effect.

def services[A : Tag, B : Tag, C : Tag]: URIO[Has[A] & Has[B] & Has[C], (A, B, C)]

Accesses the specified services in the environment of the effect.

Accesses the specified services in the environment of the effect.

def services[A : Tag, B : Tag, C : Tag, D : Tag]: URIO[Has[A] & Has[B] & Has[C] & Has[D], (A, B, C, D)]

Accesses the specified services in the environment of the effect.

Accesses the specified services in the environment of the effect.

def shift(executor: Executor): UIO[Unit]

Returns an effect that shifts execution to the specified executor. This is useful to specify a default executor that effects sequenced after this one will be run on if they are not shifted somewhere else. It can also be used to implement higher level operators to manage where an effect is run such as ZIO!.lock and ZIO!.on.

Returns an effect that shifts execution to the specified executor. This is useful to specify a default executor that effects sequenced after this one will be run on if they are not shifted somewhere else. It can also be used to implement higher level operators to manage where an effect is run such as ZIO!.lock and ZIO!.on.

def sleep(duration: => Duration): URIO[Clock, Unit]

Returns an effect that suspends for the specified duration. This method is asynchronous, and does not actually block the fiber executing the effect.

Returns an effect that suspends for the specified duration. This method is asynchronous, and does not actually block the fiber executing the effect.

def some[A](a: => A): UIO[Option[A]]

Returns an effect with the optional value.

Returns an effect with the optional value.

def succeed[A](a: => A): UIO[A]

Returns an effect that models success with the specified value.

Returns an effect that models success with the specified value.

def swap[A, B]: URIO[(A, B), (B, A)]

Returns an effectful function that merely swaps the elements in a Tuple2.

Returns an effectful function that merely swaps the elements in a Tuple2.

Capture ZIO trace at the current point

Capture ZIO trace at the current point

def traced[R, E, A](zio: ZIO[R, E, A]): ZIO[R, E, A]

Prefix form of ZIO#traced.

Prefix form of ZIO#traced.

def transplant[R, E, A](f: Grafter => ZIO[R, E, A]): ZIO[R, E, A]

Transplants specified effects so that when those effects fork other effects, the forked effects will be governed by the scope of the fiber that executes this effect.

Transplants specified effects so that when those effects fork other effects, the forked effects will be governed by the scope of the fiber that executes this effect.

This can be used to "graft" deep grandchildren onto a higher-level scope, effectively extending their lifespans into the parent scope.

def tupled[R, E, A, B](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B]): ZIO[R, E, (A, B)]

Sequentially zips the specified effects. Specialized version of mapN.

Sequentially zips the specified effects. Specialized version of mapN.

def tupled[R, E, A, B, C](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C]): ZIO[R, E, (A, B, C)]

Sequentially zips the specified effects. Specialized version of mapN.

Sequentially zips the specified effects. Specialized version of mapN.

def tupled[R, E, A, B, C, D](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C], zio4: ZIO[R, E, D]): ZIO[R, E, (A, B, C, D)]

Sequentially zips the specified effects. Specialized version of mapN.

Sequentially zips the specified effects. Specialized version of mapN.

def tupledPar[R, E, A, B](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B]): ZIO[R, E, (A, B)]

Zips the specified effects in parallel. Specialized version of mapParN.

Zips the specified effects in parallel. Specialized version of mapParN.

def tupledPar[R, E, A, B, C](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C]): ZIO[R, E, (A, B, C)]

Zips the specified effects in parallel. Specialized version of mapParN.

Zips the specified effects in parallel. Specialized version of mapParN.

def tupledPar[R, E, A, B, C, D](zio1: ZIO[R, E, A], zio2: ZIO[R, E, B], zio3: ZIO[R, E, C], zio4: ZIO[R, E, D]): ZIO[R, E, (A, B, C, D)]

Zips the specified effects in parallel. Specialized version of mapParN.

Zips the specified effects in parallel. Specialized version of mapParN.

def uninterruptible[R, E, A](zio: ZIO[R, E, A]): ZIO[R, E, A]

Prefix form of ZIO#uninterruptible.

Prefix form of ZIO#uninterruptible.

def uninterruptibleMask[R, E, A](k: InterruptStatusRestore => ZIO[R, E, A]): ZIO[R, E, A]

Makes the effect uninterruptible, but passes it a restore function that can be used to restore the inherited interruptibility from whatever region the effect is composed into.

Makes the effect uninterruptible, but passes it a restore function that can be used to restore the inherited interruptibility from whatever region the effect is composed into.

def unless[R, E](b: => Boolean)(zio: => ZIO[R, E, Any]): ZIO[R, E, Unit]

The moral equivalent of if (!p) exp

The moral equivalent of if (!p) exp

def unlessM[R, E](b: ZIO[R, E, Boolean]): UnlessM[R, E]

The moral equivalent of if (!p) exp when p has side-effects

The moral equivalent of if (!p) exp when p has side-effects

def unsandbox[R, E, A](v: ZIO[R, Cause[E], A]): ZIO[R, E, A]

The inverse operation IO.sandboxed

The inverse operation IO.sandboxed

Terminates with exceptions on the Left side of the Either error, if it exists. Otherwise extracts the contained IO[E, A]

def untraced[R, E, A](zio: ZIO[R, E, A]): ZIO[R, E, A]

Prefix form of ZIO#untraced.

Prefix form of ZIO#untraced.

def validate[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]], ev: CanFail[E]): ZIO[R, ::[E], Collection[B]]

Feeds elements of type A to f and accumulates all errors in error channel or successes in success channel.

Feeds elements of type A to f and accumulates all errors in error channel or successes in success channel.

This combinator is lossy meaning that if there are errors all successes will be lost. To retain all information please use partition.

def validate[R, E, A, B](in: NonEmptyChunk[A])(f: A => ZIO[R, E, B])(implicit ev: CanFail[E]): ZIO[R, ::[E], NonEmptyChunk[B]]

Feeds elements of type A to f and accumulates all errors in error channel or successes in success channel.

Feeds elements of type A to f and accumulates all errors in error channel or successes in success channel.

This combinator is lossy meaning that if there are errors all successes will be lost. To retain all information please use partition.

def validateFirst[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], E, Collection[E]], ev: CanFail[E]): ZIO[R, Collection[E], B]

Feeds elements of type A to f until it succeeds. Returns first success or the accumulation of all errors.

Feeds elements of type A to f until it succeeds. Returns first success or the accumulation of all errors.

def validateFirstPar[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], E, Collection[E]], ev: CanFail[E]): ZIO[R, Collection[E], B]

Feeds elements of type A to f, in parallel, until it succeeds. Returns first success or the accumulation of all errors.

Feeds elements of type A to f, in parallel, until it succeeds. Returns first success or the accumulation of all errors.

In case of success all other running fibers are terminated.

def validatePar[R, E, A, B, Collection <: (Iterable)](in: Collection[A])(f: A => ZIO[R, E, B])(implicit bf: BuildFrom[Collection[A], B, Collection[B]], ev: CanFail[E]): ZIO[R, ::[E], Collection[B]]

Feeds elements of type A to fand accumulates, in parallel, all errors in error channel or successes in success channel.

Feeds elements of type A to fand accumulates, in parallel, all errors in error channel or successes in success channel.

This combinator is lossy meaning that if there are errors all successes will be lost. To retain all information please use partitionPar.

def validatePar[R, E, A, B](in: NonEmptyChunk[A])(f: A => ZIO[R, E, B])(implicit ev: CanFail[E]): ZIO[R, ::[E], NonEmptyChunk[B]]

Feeds elements of type A to fand accumulates, in parallel, all errors in error channel or successes in success channel.

Feeds elements of type A to fand accumulates, in parallel, all errors in error channel or successes in success channel.

This combinator is lossy meaning that if there are errors all successes will be lost. To retain all information please use partitionPar.

def validatePar_[R, E, A](in: Iterable[A])(f: A => ZIO[R, E, Any])(implicit ev: CanFail[E]): ZIO[R, ::[E], Unit]

Feeds elements of type A to f in parallel and accumulates all errors, discarding the successes.

Feeds elements of type A to f in parallel and accumulates all errors, discarding the successes.

def validate_[R, E, A](in: Iterable[A])(f: A => ZIO[R, E, Any])(implicit ev: CanFail[E]): ZIO[R, ::[E], Unit]

Feeds elements of type A to f and accumulates all errors, discarding the successes.

Feeds elements of type A to f and accumulates all errors, discarding the successes.

def when[R, E](b: => Boolean)(zio: => ZIO[R, E, Any]): ZIO[R, E, Unit]

The moral equivalent of if (p) exp

The moral equivalent of if (p) exp

def whenCase[R, E, A](a: => A)(pf: PartialFunction[A, ZIO[R, E, Any]]): ZIO[R, E, Unit]

Runs an effect when the supplied PartialFunction matches for the given value, otherwise does nothing.

Runs an effect when the supplied PartialFunction matches for the given value, otherwise does nothing.

def whenCaseM[R, E, A](a: ZIO[R, E, A])(pf: PartialFunction[A, ZIO[R, E, Any]]): ZIO[R, E, Unit]

Runs an effect when the supplied PartialFunction matches for the given effectful value, otherwise does nothing.

Runs an effect when the supplied PartialFunction matches for the given effectful value, otherwise does nothing.

def whenM[R, E](b: ZIO[R, E, Boolean]): WhenM[R, E]

The moral equivalent of if (p) exp when p has side-effects

The moral equivalent of if (p) exp when p has side-effects

def withChildren[R, E, A](get: UIO[Chunk[Runtime[Any, Any]]] => ZIO[R, E, A]): ZIO[R, E, A]

Locally installs a supervisor and an effect that succeeds with all the children that have been forked in the returned effect.

Locally installs a supervisor and an effect that succeeds with all the children that have been forked in the returned effect.

Inherited methods

Inherited from:
ZIOCompanionPlatformSpecific

Alias for formCompletionStage for a concrete implementation of CompletionStage

Alias for formCompletionStage for a concrete implementation of CompletionStage

Inherited from:
ZIOCompanionPlatformSpecific
Inherited from:
ZIOCompanionPlatformSpecific
def fromFutureJava[A](future: => Future[A]): RIO[Blocking, A]

WARNING: this uses the blocking Future#get, consider using fromCompletionStage

WARNING: this uses the blocking Future#get, consider using fromCompletionStage

Inherited from:
ZIOCompanionPlatformSpecific

Concrete fields

val fiberId: UIO[Id]

Returns the Fiber.Id of the fiber executing the effect that calls this method.

Returns the Fiber.Id of the fiber executing the effect that calls this method.

val infinity: URIO[Clock, Nothing]

Like never, but fibers that running this effect won't be garbage collected unless interrupted.

Like never, but fibers that running this effect won't be garbage collected unless interrupted.

val interrupt: UIO[Nothing]

Returns an effect that is interrupted as if by the fiber calling this method.

Returns an effect that is interrupted as if by the fiber calling this method.

val never: UIO[Nothing]

Returns a effect that will never produce anything. The moral equivalent of while(true) {}, only without the wasted CPU cycles. Fibers that suspended running this effect are automatically garbage collected on the JVM, because they cannot be reactivated.

Returns a effect that will never produce anything. The moral equivalent of while(true) {}, only without the wasted CPU cycles. Fibers that suspended running this effect are automatically garbage collected on the JVM, because they cannot be reactivated.

val none: UIO[Option[Nothing]]

Returns an effect with the empty value.

Returns an effect with the empty value.

val unit: UIO[Unit]

An effect that succeeds with a unit value.

An effect that succeeds with a unit value.

Returns an effect that yields to the runtime system, starting on a fresh stack. Manual use of this method can improve fairness, at the cost of overhead.

Returns an effect that yields to the runtime system, starting on a fresh stack. Manual use of this method can improve fairness, at the cost of overhead.

Implicits

Implicits

final implicit def ZIOAutoCloseableOps[R, E, A <: AutoCloseable](io: ZIO[R, E, A]): ZIOAutoCloseableOps[R, E, A]
final implicit def ZIOWithFilterOps[R, E, A](self: ZIO[R, E, A]): ZIOWithFilterOps[R, E, A]
final implicit def ZioRefineToOrDieOps[R, E <: Throwable, A](self: ZIO[R, E, A]): ZioRefineToOrDieOps[R, E, A]