LanguageExt.Core

LanguageExt.Core Effects

Effects are functorial, monadic, and applicative types that are designed to capture IO based side-effects.

Section Type Description
IO IO<A> Asynchronous and synchronous IO. Captures side-effects, manages resources, but throws exceptions. The IO monad is the base of all IO based operations and should be used in your monad-transformer stacks when you need IO.
Eff Eff<A> Asynchronous and synchronous IO. Captures side-effects, manages resources, handles exceptions elegantly.
Eff Eff<RT, A> Asynchronous and synchronous IO. Captures side-effects, manages resources, handles exceptions elegantly, and has an injectable runtime (RT) which can provide configuration and dependency-injection

Contents

Sub modules

Eff
IO
Schedule

struct MinRT Source #

Minimal runtime for running the non-runtime based IO monads

class Prelude Source #

Methods

method K<M, A> tailIO <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Tail call

Parameters

type A
param ma
returns

method K<M, A> postIO <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Make this computation run on the SynchronizationContext that was captured at the start of the IO chain (i.e. the one embedded within the EnvIO environment that is passed through all IO computations)

method K<M, B> mapIO <M, A, B> (K<M, A> ma, Func<IO<A>, IO<B>> f) Source #

where M : MonadUnliftIO<M>, Monad<M>

Queue this IO operation to run on the thread-pool.

Parameters

param timeout

Maximum time that the forked IO operation can run for. None for no timeout.

returns

Returns a ForkIO data-structure that contains two IO effects that can be used to either cancel the forked IO operation or to await the result of it.

method K<M, A> uninterruptible <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Wraps this computation in a local-environment that ignores any cancellation-token cancellation requests.

Parameters

returns

An uninterruptible computation

method K<M, A> localIO <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Creates a local cancellation environment

A local cancellation environment stops other IO computations, that rely on the same environmental cancellation token, from being taken down by a regional cancellation.

If an IO.cancel is invoked locally, then it will still create an exception that propagates upwards and so catching cancellations is still important.

Parameters

type A

Bound value

param ma

Computation to run within the local context

returns

Result of the computation

method K<M, ForkIO<A>> fork <M, A> (K<M, A> ma, Option<TimeSpan> timeout = default) Source #

where M : MonadUnliftIO<M>, Monad<M>

Queue this IO operation to run on the thread-pool.

Parameters

param timeout

Maximum time that the forked IO operation can run for. None for no timeout.

returns

Returns a ForkIO data-structure that contains two IO effects that can be used to either cancel the forked IO operation or to await the result of it.

method K<M, A> awaitIO <M, A> (K<M, ForkIO<A>> ma) Source #

where M : MonadUnliftIO<M>

Queue this IO operation to run on the thread-pool.

Parameters

param timeout

Maximum time that the forked IO operation can run for. None for no timeout.

returns

Returns a ForkIO data-structure that contains two IO effects that can be used to either cancel the forked IO operation or to await the result of it.

method K<M, Seq<A>> awaitAll <M, A> (params K<M, A>[] ms) Source #

where M : MonadUnliftIO<M>

Awaits all operations

Parameters

param ms

Operations to await

returns

Sequence of results

method K<M, Seq<A>> awaitAll <M, A> (params K<M, ForkIO<A>>[] forks) Source #

where M : MonadUnliftIO<M>

Awaits all forks

Parameters

param forks

Forks to await

returns

Sequence of results

method K<M, Seq<A>> awaitAll <M, A> (Seq<K<M, A>> ms) Source #

where M : MonadUnliftIO<M>

Awaits all operations

Parameters

param ms

Operations to await

returns

Sequence of results

method K<M, Seq<A>> awaitAll <M, A> (Seq<K<M, ForkIO<A>>> forks) Source #

where M : MonadUnliftIO<M>

Awaits all forks

Parameters

param forks

Forks to await

returns

Sequence of results

method K<M, A> awaitAny <M, A> (params K<M, A>[] ms) Source #

where M : MonadUnliftIO<M>

Awaits for any operation to complete

Parameters

param ms

Operations to await

returns

If we get one success, then we'll return straight away and cancel the others. If we get any errors, we'll collect them in the hope that at least one works. If we have collected as many errors as we have forks, then we'll return them all.

method K<M, A> awaitAny <M, A> (params K<M, ForkIO<A>>[] forks) Source #

where M : MonadUnliftIO<M>

Awaits for any forks to complete

Parameters

param forks

Forks to await

returns

If we get one success, then we'll return straight away and cancel the others. If we get any errors, we'll collect them in the hope that at least one works. If we have collected as many errors as we have forks, then we'll return them all.

method K<M, A> awaitAny <M, A> (Seq<K<M, ForkIO<A>>> forks) Source #

where M : MonadUnliftIO<M>

Awaits for any forks to complete

Parameters

param forks

Forks to await

returns

If we get one success, then we'll return straight away and cancel the others. If we get any errors, we'll collect them in the hope that at least one works. If we have collected as many errors as we have forks, then we'll return them all.

method K<M, A> awaitAny <M, A> (Seq<K<M, A>> forks) Source #

where M : MonadUnliftIO<M>

Awaits for operations to complete

Parameters

param ms

Operations to await

returns

If we get one success, then we'll return straight away and cancel the others. If we get any errors, we'll collect them in the hope that at least one works. If we have collected as many errors as we have forks, then we'll return them all.

method K<M, A> timeout <M, A> (TimeSpan timeout, K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Timeout operation if it takes too long

method K<M, A> repeat <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation

Parameters

type A

Computation bound value type

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> repeat <M, A> (Schedule schedule, K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation, until the scheduler expires

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for repeating

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> repeatWhile <M, A> (K<M, A> ma, Func<A, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation until the predicate returns false

Parameters

type A

Computation bound value type

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> repeatWhile <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation until the scheduler expires, or the predicate returns false

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for repeating

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> repeatUntil <M, A> ( K<M, A> ma, Func<A, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation until the predicate returns true

Parameters

type A

Computation bound value type

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> repeatUntil <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps repeating the computation until the scheduler expires, or the predicate returns true

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for repeating

param ma

Computation to repeat

returns

The result of the last invocation of ma

method K<M, A> retry <M, A> (K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation

Parameters

type A

Computation bound value type

param ma

Computation to retry

returns

The result of the last invocation of ma

method K<M, A> retry <M, A> (Schedule schedule, K<M, A> ma) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation until the scheduler expires

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for retrying

param ma

Computation to retry

returns

The result of the last invocation of ma

method K<M, A> retryWhile <M, A> ( K<M, A> ma, Func<Error, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation until the predicate returns false

Parameters

type A

Computation bound value type

param ma

Computation to retry

returns

The result of the last invocation of ma

method K<M, A> retryWhile <M, A> ( Schedule schedule, K<M, A> ma, Func<Error, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation until the scheduler expires, or the predicate returns false

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for retrying

param ma

Computation to retry

returns

The result of the last invocation of ma

method K<M, A> retryUntil <M, A> ( K<M, A> ma, Func<Error, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation until the predicate returns true

Parameters

type A

Computation bound value type

param ma

Computation to retry

returns

The result of the last invocation of ma

method K<M, A> retryUntil <M, A> ( Schedule schedule, K<M, A> ma, Func<Error, bool> predicate) Source #

where M : MonadUnliftIO<M>

Keeps retrying the computation until the scheduler expires, or the predicate returns true

Parameters

type A

Computation bound value type

param schedule

Scheduler strategy for retrying

param ma

Computation to retry

returns

The result of the last invocation of ma