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.
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 occured 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.
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.
Flattens a nested action.
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
.
Lifts an Option
into an IO
.
Lifts a Try
into an IO
.
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
.
Shifts the operation to another execution context.
Shifts the operation to another execution context.
IO.shift(myPool) *> myTask
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())
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, 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))
Terminates the fiber executing this action with the specified error(s), running all finalizers.
Terminates the fiber executing this action, running all finalizers.
Terminates the fiber executing this action, running all finalizers.
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]