arrow-fx / arrow.fx / IO

IO

sealed class ~~IO~~<out A> : IOOf<A> Deprecated: The IO datatype and it’s related type classes will disappear in Arrow 0.13.0. All useful operations are offered directly over suspend functions by Arrow Fx Coroutines. https://arrow-kt.io/docs/fx/async/

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>
effectEither Delay a suspended effect which results in an Either.fun <E : Throwable, A> effectEither(f: suspend () -> EitherOf<E, A>): IO<A>
Delay a suspended effect which results in an Either on provided CoroutineContext.fun <E : Throwable, A> effectEither(ctx: CoroutineContext, f: suspend () -> EitherOf<E, 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>

Extension Functions

effectMapEither Transform, as a suspend effect, the value of an IO into an Either and consequently flatten into an IOfun <E : Throwable, A, B> IO<A>.effectMapEither(f: suspend (A) -> EitherOf<E, B>): IO<B>
flattenEither Flatten an IO with a success of Either into an IO of A, when the left is the same error (E) as the original IO and the right is A.fun <E : Throwable, A> IO<EitherOf<E, A>>.flattenEither(): IO<A>
liftIO fun <A> IO<A>.~~liftIO~~(): IO<A>
liftIO fun <F, E, A> IO<A>.~~liftIO~~(FIO: MonadIO<F>, BR: Bracket<F, E>): Resource<F, E, A>
mapEither Transform the value of an IO into an Either and consequently flatten into an IOfun <E : Throwable, A, B> IO<A>.mapEither(f: (A) -> EitherOf<E, B>): IO<B>
maybeCombine fun <A> IO<A>.~~maybeCombine~~(SG: Semigroup<A>, arg1: IO<A>): IO<A>
plus fun <A> IO<A>.~~plus~~(SG: Semigroup<A>, arg1: IO<A>): IO<A>

Companion Object Extension Functions

applicative fun IO.Companion.~~applicative~~(): IOApplicative
applicativeError fun IO.Companion.~~applicativeError~~(): IOApplicativeError
apply fun IO.Companion.~~apply~~(): IOApply
async Async models how a data type runs an asynchronous computation that may fail. Defined by the Proc signature, which is the consumption of a callback.fun IO.Companion.~~async~~(): IOAsync
bracket Extension of MonadError exposing the bracket operation, a generalized abstracted pattern of safe resource acquisition and release in the face of errors or interruption.fun IO.Companion.~~bracket~~(): IOBracket
concurrent fun IO.Companion.~~concurrent~~(dispatchers: Dispatchers<ForIO>): Concurrent<ForIO>
concurrent fun IO.Companion.~~concurrent~~(): IODefaultConcurrent
concurrentEffect fun IO.Companion.concurrentEffect(dispatchers: Dispatchers<ForIO>): ConcurrentEffect<ForIO>
concurrentEffect fun IO.Companion.~~concurrentEffect~~(): IODefaultConcurrentEffect
dispatchers fun IO.Companion.~~dispatchers~~(): IODispatchers
effect fun IO.Companion.~~effect~~(): IOEffect
environment fun IO.Companion.~~environment~~(): IOEnvironment
functor fun IO.Companion.~~functor~~(): IOFunctor
fx fun <A> IO.Companion.~~fx~~(c: suspend ConcurrentSyntax<ForIO>.() -> A): IO<A>
monad fun IO.Companion.~~monad~~(): IOMonad
monadDefer fun IO.Companion.~~monadDefer~~(): IOMonadDefer
monadError fun IO.Companion.~~monadError~~(): IOMonadError
monadIO fun IO.Companion.~~monadIO~~(): IOMonadIO
monadThrow fun IO.Companion.~~monadThrow~~(): IOMonadThrow
monoid fun <A> IO.Companion.~~monoid~~(SG: Monoid<A>): IOMonoid<A>
semigroup fun <A> IO.Companion.~~semigroup~~(SG: Semigroup<A>): IOSemigroup<A>
semigroupK fun IO.Companion.~~semigroupK~~(): IOSemigroupK
timer fun IO.Companion.~~timer~~(CF: Concurrent<ForIO>): Timer<ForIO>
fun IO.Companion.~~timer~~(): Timer<ForIO>
unsafeCancellableRun fun IO.Companion.~~unsafeCancellableRun~~(): IOUnsafeCancellableRun
unsafeRun fun IO.Companion.~~unsafeRun~~(): IOUnsafeRun

Do you like Arrow?

Arrow Org
<