arrow-fx / arrow.fx / IO

IO

sealed class IO<out A> : IOOf<A>

Types

Companion companion object Companion : IOParMap, IORace

Functions

ap Given both the value and the function are within IO, apply the function to the value.fun <B> ap(ff: IOOf<(A) -> B>): IO<B>
attempt Safely attempts the IO and lift any errors to the value side into Either.fun attempt(): IO<Either<Throwable, A>>
bracket Meant for specifying tasks with safe resource acquisition and release in the face of errors and interruption. It would be the the equivalent of try/catch/finally statements in mainstream imperative languages for resource acquisition and release.fun <B> bracket(release: (A) -> IOOf<Unit>, use: (A) -> IOOf<B>): IO<B>
bracketCase A way to safely acquire a resource and release in the face of errors and cancellation. It uses ExitCase to distinguish between different exit cases when releasing the acquired resource.fun <B> bracketCase(release: (A, ExitCase<Throwable>) -> IOOf<Unit>, use: (A) -> IOOf<B>): IO<B>
continueOn Continue the evaluation on provided CoroutineContextopen fun continueOn(ctx: CoroutineContext): IO<A>
flatMap Transform the IO value of A by sequencing an effect IO that results in B.open fun <B> flatMap(f: (A) -> IOOf<B>): IO<B>
followedBy Compose this IO with another IO while ignoring the output.fun <B> followedBy(fb: IOOf<B>): IO<B>
fork Create a new IO that upon execution starts the receiver IO within a Fiber on ctx.fun fork(ctx: CoroutineContext): IO<Fiber<ForIO, A>>
guarantee Executes the given finalizer when the source is finished, either in success or in error, or if cancelled.fun guarantee(finalizer: IOOf<Unit>): IO<A>
guaranteeCase Executes the given finalizer when the source is finished, either in success or in error, or if cancelled, allowing for differentiating between exit conditions. That’s thanks to the ExitCase argument of the finalizer.fun guaranteeCase(finalizer: (ExitCase<Throwable>) -> IOOf<Unit>): IO<A>
map Transform the IO wrapped value of A into B preserving the IO structure.open fun <B> map(f: (A) -> B): IO<B>
redeem Redeem an IO to an IO of B by resolving the error or mapping the value A to B.fun <B> redeem(fe: (Throwable) -> B, fb: (A) -> B): IO<B>
redeemWith Redeem an IO to an IO of B by resolving the error or mapping the value A to B with an effect.fun <B> redeemWith(fe: (Throwable) -> IOOf<B>, fb: (A) -> IOOf<B>): IO<B>
runAsync runAsync allows you to run any IO in a referential transparent manner.fun runAsync(cb: (Either<Throwable, A>) -> IOOf<Unit>): IO<Unit>
runAsyncCancellable A pure version of unsafeRunAsyncCancellable, it defines how an IO is ran in a cancellable manner but it doesn’t run yet.fun runAsyncCancellable(onCancel: OnCancel = Silent, cb: (Either<Throwable, A>) -> IOOf<Unit>): IO<Disposable>
suspended Run the IO in a suspended environment.suspend fun suspended(): A
uncancelable fun ~~uncancelable~~(): IO<A>
uncancellable Makes the source IO uncancellable such that a Fiber.cancel signal has no effect.fun uncancellable(): IO<A>
unsafeRunAsync unsafeRunAsync allows you to run any IO and receive the values in a callback cb and thus has the ability to run NonBlocking but that depends on the implementation. When the underlying effects/program runs blocking on the callers thread this method will run blocking.fun unsafeRunAsync(cb: (Either<Throwable, A>) -> Unit): Unit
unsafeRunAsyncCancellable unsafeRunAsyncCancellable allows you to run any IO and receive the values in a callback cb while being cancellable. It has the ability to run NonBlocking but that depends on the implementation, when the underlying effects/program runs blocking on the callers thread this method will run blocking.fun unsafeRunAsyncCancellable(onCancel: OnCancel = Silent, cb: (Either<Throwable, A>) -> Unit): Disposable
unsafeRunSync unsafeRunSync allows you to run any IO to its wrapped value A.fun unsafeRunSync(): A
unsafeRunTimed Run with a limitation on how long to await for individual async results. It’s possible that this methods runs forever i.e. for an infinite recursive IO.fun unsafeRunTimed(limit: Duration): Option<A>

Companion Object Properties

lazy A lazy IO value of Unit.val lazy: IO<Unit>
never A pure IO value that never returns. Useful when you need to model non-terminating cases.val never: IO<Nothing>
unit A pure IO value of Unit.val unit: IO<Unit>

Companion Object Functions

async Create an IO that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that require no cancellation code.fun <A> async(k: IOProc<A>): IO<A>
asyncF Create an IO that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that require no cancellation code.fun <A> asyncF(k: IOProcF<A>): IO<A>
cancelable fun <A> ~~cancelable~~(cb: ((Either<Throwable, A>) -> Unit) -> CancelToken<ForIO>): IO<A>
cancelableF fun <A> ~~cancelableF~~(cb: ((Either<Throwable, A>) -> Unit) -> IOOf<CancelToken<ForIO>>): IO<A>
cancellable Creates a cancellable instance of IO that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that requires cancellation code.fun <A> cancellable(cb: ((Either<Throwable, A>) -> Unit) -> CancelToken<ForIO>): IO<A>
cancellableF Creates a cancellable instance of IO that executes an asynchronous process on evaluation. This combinator can be used to wrap callbacks or other similar impure code that requires cancellation code.fun <A> cancellableF(cb: ((Either<Throwable, A>) -> Unit) -> IOOf<CancelToken<ForIO>>): IO<A>
defer Defer a computation that results in an IO value.fun <A> defer(f: () -> IOOf<A>): IO<A>
effect Delay a suspended effect.fun <A> effect(f: suspend () -> A): IO<A>
Delay a suspended effect on provided CoroutineContext.fun <A> effect(ctx: CoroutineContext, f: suspend () -> A): IO<A>
eval Evaluates an Eval instance within a safe IO context.fun <A> eval(eval: Eval<A>): IO<A>
invoke operator fun <A> invoke(ctx: CoroutineContext, f: suspend () -> A): IO<A>
operator fun <A> invoke(f: suspend () -> A): IO<A>
just Just wrap a pure value A into IO.fun <A> just(a: A): IO<A>
later Wraps a function into IO to execute it later.fun <A> later(f: () -> A): IO<A>
raiseError Raise an error in a pure way without actually throwing.fun <A> raiseError(e: Throwable): IO<A>
sleep Sleeps for a given duration without blocking a thread.fun sleep(duration: Duration, continueOn: CoroutineContext = IODispatchers.CommonPool): IO<Unit>
tailRecM Perform a recursive operation in a stack-safe way, by checking the inner Either value. If you want to continue the recursive operation return Either.Left with the intermediate result A, Either.Right indicates the terminal event and must thus return the resulting value B.fun <A, B> tailRecM(a: A, f: (A) -> IOOf<Either<A, B>>): IO<B>

Companion Object Extension Functions

concurrent fun IO.Companion.concurrent(dispatchers: Dispatchers<ForIO>): Concurrent<ForIO>
concurrentEffect fun IO.Companion.concurrentEffect(dispatchers: Dispatchers<ForIO>): ConcurrentEffect<ForIO>
fx fun <A> IO.Companion.fx(c: suspend ConcurrentSyntax<ForIO>.() -> A): IO<A>
timer fun IO.Companion.timer(CF: Concurrent<ForIO>): Timer<ForIO>
fun IO.Companion.timer(): Timer<ForIO>

Do you like Arrow?

Arrow Org
<