Submerges the error case of an Either
into the IO
.
Submerges the error case of an Either
into the IO
. The inverse
operation of IO.attempt
.
Imports an asynchronous effect into a pure IO
value.
Imports an asynchronous effect into a pure IO
value. See async0
for
the more expressive variant of this function that can return a value
synchronously.
Imports an asynchronous effect into a pure IO
value, possibly returning
the value synchronously.
Imports an asynchronous effect into a pure IO
value.
Imports an asynchronous effect into a pure IO
value. The 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 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 effect into a pure IO
value.
Imports an asynchronous effect into a pure IO
value. This formulation is
necessary when the effect is itself expressed in terms of IO
.
Acquires a resource, do some work with it, and then release that resource.
Acquires a resource, do some work with it, and then release that resource. bracket
will release the resource no matter the outcome of the computation, and will
re-throw any exception that occurred in between.
Acquires a resource, do some work with it, and then release that resource.
Acquires a resource, do some work with it, and then release that resource. With bracket0
not only is the acquired resource be cleaned up, the outcome of the computation is also
reified for processing.
Evaluate each effect in the structure in parallel, and collect the results.
Evaluate each effect in the structure in parallel, and collect
the results. Only up to n
tasks run in parallel.
This is a version of collectPar
, with a throttle.
Returns information about the current fiber, such as its fiber identity.
Creates an IO
value from ExitResult
Creates an IO
value that represents failure with the specified error.
Creates an IO
value that represents failure with the specified error.
The moral equivalent of throw
for pure code.
Returns an IO
that fails with the specified Cause
.
Flattens a nested action.
Evaluate the elements of a traversable data structure in parallel and collect the results.
Evaluate the elements of a traversable data structure in parallel
and collect the results. Only up to n
tasks run in parallel.
This is a version of foreachPar
, with a throttle.
Forks all of the specified values, and returns a composite fiber that produces a list of their results, in order.
Forks all of the specified values, and returns a composite fiber that produces a list of their results, in order.
Lifts an Either
into an IO
.
Creates an IO
value that represents the exit value of the specified
fiber.
Creates an IO
value that represents the exit value of the specified
fiber.
Lifts an Option
into an IO
.
Imports a Try
into an IO
.
Returns an IO
that is interrupted.
Locks the io
to the specified executor.
Merges an Iterable[IO]
to a single IO, works in parallel.
Returns a action that will never produce anything.
Returns a action that will never produce anything. The moral
equivalent of while(true) {}
, only without the wasted CPU cycles.
Lifts a strictly evaluated value into the IO
monad.
Evaluate each effect in the structure in parallel, and collect the results.
Evaluate each effect in the structure in parallel, and collect
the results. This is the parallel version of sequence
.
Evaluate the elements of an Iterable[A]
in parallel
and collect the results.
Evaluate the elements of an Iterable[A]
in parallel
and collect the results. This is the parallel version of traverse
.
Lifts a non-strictly evaluated value into the IO
monad.
Lifts a non-strictly evaluated value into the IO
monad. Do not use this
function to capture effectful code. The result is undefined but may
include duplicated effects.
Races an IO[E, A]
against elements of a Iterable[IO[E, A]]
.
Races an IO[E, A]
against elements of a Iterable[IO[E, A]]
. Yields
either the first success or the last failure.
Reduces an Iterable[IO]
to a single IO, works in parallel.
Requires that the given IO[E, Option[A]]
contain a value.
Requires that the given IO[E, Option[A]]
contain a value. If there is no
value, then the specified error will be raised.
Evaluate each effect in the structure from left to right, and collect the results.
Evaluate each effect in the structure from left to right, and collect
the results. For parallelism use parAll
.
Sleeps for the specified duration.
Sleeps for the specified duration. This is always asynchronous.
Supervises the specified action, which ensures that any actions directly forked by the action are killed upon the action's own termination.
Supervises the specified action's spawned fibers.
Retrieves the supervisor associated with the fiber running the action returned by this method.
Lazily produces an IO
value whose construction may have actional costs
that should be deferred until evaluation.
Lazily produces an IO
value whose construction may have actional costs
that should be deferred until evaluation.
Do not use this method to effectfully construct IO
values. The results
will be undefined and most likely involve the physical explosion of your
computer in a heap of rubble.
Imports a synchronous effect into a pure IO
value.
Imports a synchronous effect into a pure IO
value.
val nanoTime: IO[Nothing, Long] = IO.sync(System.nanoTime())
Imports a synchronous effect into a pure IO
value.
Imports a synchronous effect into a pure IO
value. This variant of sync
lets you use the execution environment of the fiber.
val nanoTime: IO[Nothing, Long] = IO.sync(System.nanoTime())
Safely imports an exception-throwing synchronous effect into a pure IO
value, translating the specified throwables into E
with the provided
user-defined function.
Imports a synchronous effect into a pure IO
value, translating any
exceptions into an Exception
failure in the returned value.
Imports a synchronous effect into a pure IO
value, translating any
exceptions into an Exception
failure in the returned value.
def putStrLn(line: String): IO[Exception, Unit] = IO.syncException(println(line))
Imports a synchronous effect into a pure IO
value.
Imports a synchronous effect into a pure IO
value. This variant of sync
lets you use the current executor of the fiber.
Imports a synchronous effect into a pure IO
value, translating any
throwables into a Throwable
failure in the returned value.
Imports a synchronous effect into a pure IO
value, translating any
throwables into a Throwable
failure in the returned value.
def putStrLn(line: String): IO[Throwable, Unit] = IO.syncThrowable(println(line))
Returns an IO
that terminates with the specified Throwable
.
Apply the function fn to each element of the Iterable[A]
and
return the results in a new List[B]
.
Apply the function fn to each element of the Iterable[A]
and
return the results in a new List[B]
. For parallelism use parTraverse
.
Strictly-evaluated unit lifted into the IO
monad.
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]
A combinator that allows you to identify long-running IO
values to the
runtime system for improved scheduling.
The moral equivalent of if (p) exp
The moral equivalent of if (p) exp
when p
has side-effects
Yields to the runtime system, starting on a fresh stack.
Alias for collectParN
Alias for collectParN
(Since version scalaz-zio 0.3.3) Use collectParN
Shifts the operation to another execution context.
Shifts the operation to another execution context.
IO.shift(myPool) *> myTask
(Since version 0.6.0) use lock or on
Shifts execution to a thread in the default ExecutionContext
.
Shifts execution to a thread in the default ExecutionContext
.
(Since version 0.6.0) use yieldNow
Alias for foreachParN
Alias for foreachParN
(Since version scalaz-zio 0.3.3) Use foreachParN