- EnvIO
- Resources
- Token
- Source
- SyncContext
- New ( Resources? resources = null, CancellationToken token = default, CancellationTokenSource? source = null, SynchronizationContext? syncContext = null)
- Local
- LocalResources
- LocalCancel
- LocalSyncContext
- Dispose ()
- ToString ()
- ForkIO <A> ( IO<Unit> Cancel, IO<A> Await)
- IO <A>
- Pure (A value)
- Fail (Error value)
- Empty
- Lift (Func<A> f)
- Lift (Func<IOResponse<A>> f)
- Lift (Func<EnvIO, A> f)
- Lift (Func<EnvIO, IOResponse<A>> f)
- LiftAsync (Func<Task<IOResponse<A>>> f)
- LiftAsync (Func<EnvIO, Task<IOResponse<A>>> f)
- LiftAsync (Func<Task<A>> f)
- LiftAsync (Func<EnvIO, Task<A>> f)
- Map <B> (Func<A, B> f)
- Map <B> (B value)
- MapFail (Func<Error, Error> f)
- BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail)
- Match <B> (Func<A, B> Succ, Func<Error, B> Fail)
- IfFail (Func<Error, A> Fail)
- IfFail (A Fail)
- IfFail (Func<Error, IO<A>> Fail)
- IfFail (IO<A> Fail)
- Fold <S> ( Schedule schedule, S initialState, Func<S, A, S> folder)
- Fold <S> ( S initialState, Func<S, A, S> folder)
- FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldWhile <S> ( S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldWhile <S> ( S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldWhile <S> ( S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldUntil <S> ( S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldUntil <S> ( S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldUntil <S> ( S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- Post ()
- Bind <B> (Func<A, IO<B>> f)
- Bind <B> (Func<A, K<IO, B>> f)
- Bind <B> (Func<A, Pure<B>> f)
- Select <B> (Func<A, B> f)
- SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project)
- SelectMany <B, C> (Func<A, K<IO, B>> bind, Func<A, B, C> project)
- SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project)
- SelectMany <M, B, C> (Func<A, OptionT<M, B>> bind, Func<A, B, C> project)
- SelectMany <M, B, C> (Func<A, TryT<M, B>> bind, Func<A, B, C> project)
- SelectMany <L, M, B, C> (Func<A, EitherT<L, M, B>> bind, Func<A, B, C> project)
- SelectMany <M, B, C> (Func<A, FinT<M, B>> bind, Func<A, B, C> project)
- SelectMany <F, M, B, C> (Func<A, ValidationT<F, M, B>> bind, Func<A, B, C> project)
- SelectMany <Env, M, B, C> (Func<A, ReaderT<Env, M, B>> bind, Func<A, B, C> project)
- SelectMany <S, M, B, C> (Func<A, StateT<S, M, B>> bind, Func<A, B, C> project)
- SelectMany <B, C> (Func<A, Eff<B>> bind, Func<A, B, C> project)
- SelectMany <RT, B, C> (Func<A, Eff<RT, B>> bind, Func<A, B, C> project)
- SelectMany <C> (Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project)
- | (IO<A> lhs, IO<A> rhs)
- | (IO<A> lhs, K<IO, A> rhs)
- | (K<IO, A> lhs, IO<A> rhs)
- | (IO<A> lhs, Pure<A> rhs)
- | (IO<A> lhs, Fail<Error> rhs)
- | (IO<A> lhs, CatchM<Error, IO, A> rhs)
- | (IO<A> lhs, A rhs)
- >> (IO<A> lhs, IO<A> rhs)
- >> (IO<A> lhs, K<IO, A> rhs)
- >> (IO<A> lhs, IO<Unit> rhs)
- >> (IO<A> lhs, K<IO, Unit> rhs)
- Bracket ()
- Bracket <B, C> (Func<A, IO<C>> Use, Func<A, IO<B>> Fin)
- Bracket <B, C> (Func<A, IO<C>> Use, Func<Error, IO<C>> Catch, Func<A, IO<B>> Fin)
- Timeout (TimeSpan timeout)
- Local ()
- Fork (Option<TimeSpan> timeout = default)
- RunAsync (EnvIO? envIO = null)
- Run (EnvIO? envIO = null)
- Try ()
- Repeat ()
- Repeat (Schedule schedule)
- RepeatWhile (Func<A, bool> predicate)
- RepeatWhile ( Schedule schedule, Func<A, bool> predicate)
- RepeatUntil ( Func<A, bool> predicate)
- RepeatUntil ( Schedule schedule, Func<A, bool> predicate)
- Retry ()
- Retry (Schedule schedule)
- RetryWhile (Func<Error, bool> predicate)
- RetryWhile ( Schedule schedule, Func<Error, bool> predicate)
- RetryUntil ( Func<Error, bool> predicate)
- RetryUntil ( Schedule schedule, Func<Error, bool> predicate)
- Catch (Func<Error, bool> Predicate, Func<Error, K<IO, A>> Fail)
- Combine (IO<A> rhs)
- ToString ()
- IOResponse <A>
- CompleteIO <A> (A Value)
- RecurseIO <A> (IO<A> Computation)
- BindIO <A>
- BindIO <X, A> (X Value, Func<X, IO<A>> Computation)
- IOResponse
- Complete <A> (A value)
- Recurse <A> (IO<A> computation)
- Bind <X, A> (X value, Func<X, IO<A>> computation)
- IOExtensions
- As <A> (this K<IO, A> ma)
- Run <A> (this K<IO, A> ma, EnvIO? envIO = null)
- RunSafe <A> (this K<IO, A> ma, EnvIO? envIO = null)
- RunAsync <A> (this K<IO, A> ma, EnvIO? envIO = null)
- RunSafeAsync <A> (this K<IO, A> ma, EnvIO? envIO = null)
- Flatten <A> (this Task<IO<A>> tma)
- Flatten <A> (this IO<IO<A>> mma)
- SelectMany <A, B, C> (this K<IO, A> ma, Func<A, K<IO, B>> bind, Func<A, B, C> project)
- LocalIO <M, A> (this K<M, A> ma)
- PostIO <M, A> (this K<M, A> ma)
- Await <M, A> (this K<M, ForkIO<A>> ma)
- ForkIO <M, A> (this K<M, A> ma, Option<TimeSpan> timeout = default)
- ForkIO <M, A> (this StreamT<M, A> ma, Option<TimeSpan> timeout = default)
- TimeoutIO <M, A> (this K<M, A> ma, TimeSpan timeout)
- BracketIO <M, A> (this K<M, A> ma)
- BracketIO <M, A, B, C> ( this K<M, A> acq, Func<A, IO<C>> Use, Func<A, IO<B>> Fin)
- BracketIO <M, A, B, C> ( this K<M, A> acq, Func<A, IO<C>> Use, Func<Error, IO<C>> Catch, Func<A, IO<B>> Fin)
- RepeatIO <M, A> (this K<M, A> ma)
- RepeatIO <M, A> ( this K<M, A> ma, Schedule schedule)
- RepeatWhileIO <M, A> ( this K<M, A> ma, Func<A, bool> predicate)
- RepeatWhileIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<A, bool> predicate)
- RepeatUntilIO <M, A> ( this K<M, A> ma, Func<A, bool> predicate)
- RepeatUntilIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<A, bool> predicate)
- RetryIO <M, A> (this K<M, A> ma)
- RetryIO <M, A> ( this K<M, A> ma, Schedule schedule)
- RetryWhileIO <M, A> ( this K<M, A> ma, Func<Error, bool> predicate)
- RetryWhileIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<Error, bool> predicate)
- RetryUntilIO <M, A> ( this K<M, A> ma, Func<Error, bool> predicate)
- RetryUntilIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<Error, bool> predicate)
- FoldIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder)
- FoldIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate)
- ZipIO <M, A, B> ( this (K<M, A> First, K<M, B> Second) tuple)
- ZipIO <M, A, B, C> ( this (K<M, A> First, K<M, B> Second, K<M, C> Third) tuple)
- ZipIO <M, A, B, C, D> ( this (K<M, A> First, K<M, B> Second, K<M, C> Third, K<M, D> Fourth) tuple)
- ZipIO <M, A, B> ( this K<M, A> First, K<M, B> Second)
- ZipIO <M, A, B, C> ( this K<M, A> First, K<M, B> Second, K<M, C> Third)
- ZipIO <M, A, B, C, D> ( this K<M, A> First, K<M, B> Second, K<M, C> Third, K<M, D> Fourth)
- IOExtensions
- Map <A, B> (this Func<A, B> f, K<IO, A> ma)
- Map <A, B> (this Func<A, B> f, IO<A> ma)
- Action <A, B> (this IO<A> ma, IO<B> mb)
- Apply <A, B> (this IO<Func<A, B>> mf, K<IO, A> ma)
- Apply <A, B> (this K<IO, Func<A, B>> mf, K<IO, A> ma)
- IO
- fail <A> (Error value)
- fail <A> (string value)
- lift (Action f)
- local <M, A> (K<M, A> ma)
- local <A> (K<IO, A> ma)
- lift <A> (Either<Error, A> ma)
- lift <A> (Fin<A> ma)
- lift <A> (Func<A> f)
- lift <A> (Func<EnvIO, A> f)
- lift <A> (Func<Fin<A>> f)
- lift <A> (Func<EnvIO, Fin<A>> f)
- lift <A> (Func<Either<Error, A>> f)
- lift <A> (Func<EnvIO, Either<Error, A>> f)
- liftAsync <A> (Func<Task<A>> f)
- liftAsync <A> (Func<EnvIO, Task<A>> f)
- env = lift(e => e)
- token = lift(e => e.Token)
- source = lift(e => e.Source)
- syncContext = lift(e => Optional(e.SyncContext))
- empty <A> ()
- combine <A> (K<IO, A> ma, K<IO, A> mb)
- mapIO <M, A, B> (K<M, A> ma, Func<IO<A>, IO<B>> f)
- fork <A> (K<IO, A> ma, Option<TimeSpan> timeout = default)
- fork <M, A> (K<M, A> ma, Option<TimeSpan> timeout = default)
- yieldFor (Duration duration)
- yieldFor (TimeSpan timeSpan)
- IO
- Prelude
- refIO <A> (A value, Func<A, bool>? validator = null)
- atomicIO <R> (Func<R> op, Isolation isolation = Isolation.Snapshot)
- atomicIO (Action op, Isolation isolation = Isolation.Snapshot)
- snapshotIO <R> (Func<R> op)
- snapshotIO (Action op)
- serialIO <R> (Func<R> op)
- serialIO (Action op)
- swapIO <A> (Ref<A> r, Func<A, A> f)
- commuteIO <A> (Ref<A> r, Func<A, A> f)
- atomIO <A> (A value)
- atomIO <A> (A value, Func<A, bool> validator)
- atomIO <M, A> (M metadata, A value)
- atomIO <M, A> (M metadata, A value, Func<A, bool> validator)
- swapIO <A> (Atom<A> ma, Func<A, A> f)
- swapIO <M, A> (Atom<M, A> ma, Func<M, A, A> f)
- swapIO <A> (Atom<A> ma, Func<A, Option<A>> f)
- swapIO <M, A> (Atom<M, A> ma, Func<M, A, Option<A>> f)
- valueIO <A> (Atom<A> ma)
- valueIO <M, A> (Atom<M, A> ma)
- writeIO <A> (Atom<A> ma, A value)
- writeIO <M, A> (Atom<M, A> ma, A value)
- Prelude
- cancelToken = IO.lift(e => e.Token)
- cancel = new IOSync<Unit>( e => { e.Source.Cancel(); throw new TaskCanceledException(); })
- unitIO = IO<Unit>.Pure(default)
- envIO = IO<EnvIO>.Lift(e => e)
- postIO <M, A> (K<M, A> ma)
- post <A> (K<IO, A> ma)
- fork <A> (K<IO, A> ma, Option<TimeSpan> timeout = default)
- fork <M, A> (K<M, A> ma, Option<TimeSpan> timeout = default)
- fork <M, A> (StreamT<M, A> ma, Option<TimeSpan> timeout = default)
- fork <A> (StreamT<IO, A> ma, Option<TimeSpan> timeout = default)
- awaitIO <M, A> (K<M, ForkIO<A>> ma)
- awaitIO <A> (K<IO, ForkIO<A>> ma)
- yieldFor (Duration duration)
- yieldFor (TimeSpan timeSpan)
- awaitAll <M, A> (params K<M, A>[] ms)
- awaitAll <A> (params K<IO, A>[] ms)
- awaitAll <A> (params IO<A>[] ms)
- awaitAll <M, A> (params K<M, ForkIO<A>>[] forks)
- awaitAll <A> (params IO<ForkIO<A>>[] mfs)
- awaitAll <M, A> (Seq<K<M, A>> ms)
- awaitAll <A> (Seq<K<IO, A>> ms)
- awaitAll <A> (Seq<IO<A>> ms)
- awaitAll <M, A> (Seq<K<M, ForkIO<A>>> forks)
- awaitAll <A> (Seq<IO<ForkIO<A>>> mfs)
- awaitAny <M, A> (params K<M, A>[] forks)
- awaitAny <A> (params IO<A>[] ms)
- awaitAny <A> (params K<IO, A>[] ms)
- awaitAny <M, A> (params K<M, ForkIO<A>>[] forks)
- awaitAny <A> (params IO<ForkIO<A>>[] forks)
- awaitAny <M, A> (Seq<K<M, ForkIO<A>>> forks)
- awaitAny <M, A> (Seq<K<M, A>> forks)
- awaitAny <A> (Seq<K<IO, A>> ms)
- awaitAny <A> (Seq<IO<A>> ms)
- awaitAny <A> (Seq<IO<ForkIO<A>>> mfs)
- timeout <M, A> (TimeSpan timeout, K<M, A> ma)
- timeout <A> (TimeSpan timeout, K<IO, A> ma)
- repeat <M, A> (K<M, A> ma)
- repeat <A> (IO<A> ma)
- repeat <M, A> (Schedule schedule, K<M, A> ma)
- repeat <A> (Schedule schedule, K<IO, A> ma)
- repeatWhile <M, A> (K<M, A> ma, Func<A, bool> predicate)
- repeatWhile <A> (IO<A> ma, Func<A, bool> predicate)
- repeatWhile <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate)
- repeatWhile <A> ( Schedule schedule, K<IO, A> ma, Func<A, bool> predicate)
- repeatUntil <M, A> ( K<M, A> ma, Func<A, bool> predicate)
- repeatUntil <A> ( K<IO, A> ma, Func<A, bool> predicate)
- repeatUntil <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate)
- repeatUntil <A> ( Schedule schedule, K<IO, A> ma, Func<A, bool> predicate)
- retry <M, A> (K<M, A> ma)
- retry <A> (K<IO, A> ma)
- retry <M, A> (Schedule schedule, K<M, A> ma)
- retry <A> (Schedule schedule, K<IO, A> ma)
- retryWhile <M, A> ( K<M, A> ma, Func<Error, bool> predicate)
- retryWhile <A> ( K<IO, A> ma, Func<Error, bool> predicate)
- retryWhile <M, A> ( Schedule schedule, K<M, A> ma, Func<Error, bool> predicate)
- retryWhile <A> ( Schedule schedule, K<IO, A> ma, Func<Error, bool> predicate)
- retryUntil <M, A> ( K<M, A> ma, Func<Error, bool> predicate)
- retryUntil <A> ( K<IO, A> ma, Func<Error, bool> predicate)
- retryUntil <M, A> ( Schedule schedule, K<M, A> ma, Func<Error, bool> predicate)
- retryUntil <A> ( Schedule schedule, K<IO, A> ma, Func<Error, bool> predicate)
- Prelude
- map <A, B> (Func<A, B> f, K<IO, A> ma)
- action <A, B> (K<IO, A> ma, K<IO, B> mb)
- apply <A, B> (K<IO, Func<A, B>> mf, K<IO, A> ma)
- Resources
Sub modules
Async |
Fail |
Pure |
Sync |
Environment for the IO monad
field SynchronizationContext? SyncContext Source #
property EnvIO LocalResources Source #
property EnvIO LocalCancel Source #
property EnvIO LocalSyncContext Source #
record ForkIO <A> ( IO<Unit> Cancel, IO<A> Await) Source #
Result of forking an IO
monad
type | A | Bound value type |
param | Cancel | An |
param | Await | An |
A value of type IO
is a computation which, when performed, does some I/O before returning
a value of type A
.
There is really only one way you should "perform" an I/O action: bind it to Main
in your
program: When your program is run, the I/O will be performed. It shouldn't be possible to
perform I/O from an arbitrary function, unless that function is itself in the IO
monad and
called at some point, directly or indirectly, from Main
.
Obviously, as this is C#, the above restrictions are for you to enforce. It would be reasonable to relax that approach and have I/O invoked from, say, web-request handlers - or any other 'edges' of your application.
IO
is a monad, so IO
actions can be combined using either the LINQ-notation or the bind
operations from the Monad
class.
type | A | Bound value |
param | runIO | The lifted thunk that is the IO operation |
method IO<S> FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method IO<S> FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method IO<S> FoldWhile <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method IO<S> FoldWhile <S> ( S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method IO<S> FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method IO<S> FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method IO<S> FoldUntil <S> ( S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method IO<S> FoldUntil <S> ( Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
Make this IO 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 IO<C> SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project) Source #
method IO<C> SelectMany <B, C> (Func<A, K<IO, B>> bind, Func<A, B, C> project) Source #
method IO<C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #
method OptionT<M, C> SelectMany <M, B, C> (Func<A, OptionT<M, B>> bind, Func<A, B, C> project) Source #
method TryT<M, C> SelectMany <M, B, C> (Func<A, TryT<M, B>> bind, Func<A, B, C> project) Source #
method EitherT<L, M, C> SelectMany <L, M, B, C> (Func<A, EitherT<L, M, B>> bind, Func<A, B, C> project) Source #
method FinT<M, C> SelectMany <M, B, C> (Func<A, FinT<M, B>> bind, Func<A, B, C> project) Source #
method ValidationT<F, M, C> SelectMany <F, M, B, C> (Func<A, ValidationT<F, M, B>> bind, Func<A, B, C> project) Source #
method ReaderT<Env, M, C> SelectMany <Env, M, B, C> (Func<A, ReaderT<Env, M, B>> bind, Func<A, B, C> project) Source #
method StateT<S, M, C> SelectMany <S, M, B, C> (Func<A, StateT<S, M, B>> bind, Func<A, B, C> project) Source #
method Eff<C> SelectMany <B, C> (Func<A, Eff<B>> bind, Func<A, B, C> project) Source #
method Eff<RT, C> SelectMany <RT, B, C> (Func<A, Eff<RT, B>> bind, Func<A, B, C> project) Source #
method IO<C> SelectMany <C> (Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project) Source #
method IO<A> Bracket () Source #
The IO monad tracks resources automatically, this creates a local resource environment
to run this computation in. Once the computation has completed any resources acquired
are automatically released. Imagine this as the ultimate using
statement.
method IO<C> Bracket <B, C> (Func<A, IO<C>> Use, Func<A, IO<B>> Fin) Source #
When acquiring, using, and releasing various resources, it can be quite convenient to write a function to manage the acquisition and releasing, taking a function of the acquired value that specifies an action to be performed in between.
param | Use | Function to use the acquired resource |
param | Fin | Function to invoke to release the resource |
method IO<C> Bracket <B, C> (Func<A, IO<C>> Use, Func<Error, IO<C>> Catch, Func<A, IO<B>> Fin) Source #
When acquiring, using, and releasing various resources, it can be quite convenient to write a function to manage the acquisition and releasing, taking a function of the acquired value that specifies an action to be performed in between.
param | Use | Function to use the acquired resource |
param | Catch | Function to run to handle any exceptions |
param | Fin | Function to invoke to release the resource |
method IO<A> Timeout (TimeSpan timeout) Source #
Applies a time limit to the IO computation. If exceeded an exception is thrown.
param | timeout | Timeout |
returns | Result of the operation or throws if the time limit exceeded. |
method IO<ForkIO<A>> Fork (Option<TimeSpan> timeout = default) Source #
Queues the specified work to run on the thread pool
Any resources acquired within a forked IO computation will automatically be released upon the forked computation's completion (successful or otherwise). Resources acquired in the parent thread will be available to the forked thread, and can be released from there, but they are shared resources at that point and should be treated with care.
param | timeout | Optional timeout |
returns |
|
method ValueTask<A> RunAsync (EnvIO? envIO = null) Source #
Run the IO
monad to get its result
This forks the operation to run on a new task that is then awaited.
Any lifted asynchronous operations will yield to the thread-scheduler, allowing other queued operations to run concurrently. So, even though this call isn't awaitable it still plays nicely and doesn't block the thread.
NOTE: An exception will always be thrown if the IO operation fails. Lift this monad into other error handling monads to leverage more declarative error handling.
returns | Result of the IO operation |
method A Run (EnvIO? envIO = null) Source #
Run the IO
monad to get its result
Any lifted asynchronous operations will yield to the thread-scheduler, allowing other queued operations to run concurrently. So, even though this call isn't awaitable it still plays nicely and doesn't block the thread.
NOTE: An exception will always be thrown if the IO operation fails. Lift this monad into other error handling monads to leverage more declarative error handling.
param | env | IO environment |
returns | Result of the IO operation |
method FinT<IO, A> Try () Source #
Run the IO
monad to get its result. Differs from Run
in that it catches any exceptions and turns
them into a Fin<A>
result.
method IO<A> Repeat () Source #
Keeps repeating the computation forever, or until an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
returns | The result of the last invocation |
method IO<A> Repeat (Schedule schedule) Source #
Keeps repeating the computation, until the scheduler expires, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
returns | The result of the last invocation |
method IO<A> RepeatWhile (Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns false, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | predicate | Keep repeating while this predicate returns |
returns | The result of the last invocation |
method IO<A> RepeatWhile ( Schedule schedule, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns false, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
param | predicate | Keep repeating while this predicate returns |
returns | The result of the last invocation |
method IO<A> RepeatUntil ( Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns true, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | predicate | Keep repeating until this predicate returns |
returns | The result of the last invocation |
method IO<A> RepeatUntil ( Schedule schedule, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns true, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
param | predicate | Keep repeating until this predicate returns |
returns | The result of the last invocation |
method IO<A> Retry () Source #
Retry if the IO computation fails
This variant will retry forever
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> Retry (Schedule schedule) Source #
Retry if the IO computation fails
This variant will retry until the schedule expires
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> RetryWhile (Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying whilst the predicate returns true
for the error generated at each iteration;
at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> RetryWhile ( Schedule schedule, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying whilst the predicate returns true
for the error generated at each iteration;
or, until the schedule expires; at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> RetryUntil ( Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying until the predicate returns true
for the error generated at each iteration;
at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> RetryUntil ( Schedule schedule, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying until the predicate returns true
for the error generated at each iteration;
or, until the schedule expires; at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method IO<A> Catch (Func<Error, bool> Predicate, Func<Error, K<IO, A>> Fail) Source #
Catches any error thrown by invoking this IO computation, passes it through a predicate, and if that returns true, returns the result of invoking the Fail function, otherwise this is returned.
param | Predicate | Predicate |
param | Fail | Fail functions |
operator >> (IO<A> lhs, IO<A> rhs) Source #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.
param | lhs | First action to run |
param | rhs | Second action to run |
returns | Result of the second action |
operator >> (IO<A> lhs, K<IO, A> rhs) Source #
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.
param | lhs | First action to run |
param | rhs | Second action to run |
returns | Result of the second action |
record IOResponse <A> Source #
record CompleteIO <A> (A Value) Source #
class IOResponse Source #
class IOExtensions Source #
method IO<A> As <A> (this K<IO, A> ma) Source #
Convert the kind version of the IO
monad to an IO
monad.
This is a simple cast operation which is just a bit more elegant than manually casting.
type | A | |
param | ma | |
returns |
method ValueTask<Fin<A>> RunSafeAsync <A> (this K<IO, A> ma, EnvIO? envIO = null) Source #
method IO<A> Flatten <A> (this Task<IO<A>> tma) Source #
Get the outer task and wrap it up in a new IO within the IO
method IO<C> SelectMany <A, B, C> (this K<IO, A> ma, Func<A, K<IO, B>> bind, Func<A, B, C> project) Source #
method K<M, A> LocalIO <M, A> (this K<M, A> ma) Source #
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 a IO.cancel
is invoked locally then it will still create an exception that
propagates upwards and so catching cancellations is still important.
type | A | Bound value |
param | ma | Computation to run within the local context |
returns | Result of the computation |
method K<M, A> PostIO <M, A> (this K<M, A> ma) Source #
Make this IO 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, A> Await <M, A> (this K<M, ForkIO<A>> ma) Source #
Await a forked operation
method K<M, ForkIO<A>> ForkIO <M, A> (this K<M, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, ForkIO<Option<A>>> ForkIO <M, A> (this StreamT<M, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, A> TimeoutIO <M, A> (this K<M, A> ma, TimeSpan timeout) Source #
Timeout operation if it takes too long
method K<M, A> BracketIO <M, A> (this K<M, A> ma) Source #
The IO monad tracks resources automatically, this creates a local resource environment
to run this computation in. Once the computation has completed any resources acquired
are automatically released. Imagine this as the ultimate using
statement.
method K<M, C> BracketIO <M, A, B, C> ( this K<M, A> acq, Func<A, IO<C>> Use, Func<A, IO<B>> Fin) Source #
When acquiring, using, and releasing various resources, it can be quite convenient to write a function to manage the acquisition and releasing, taking a function of the acquired value that specifies an action to be performed in between.
param | acq | Resource acquisition |
param | Use | Function to use the acquired resource |
param | Fin | Function to invoke to release the resource |
method K<M, C> BracketIO <M, A, B, C> ( this K<M, A> acq, Func<A, IO<C>> Use, Func<Error, IO<C>> Catch, Func<A, IO<B>> Fin) Source #
When acquiring, using, and releasing various resources, it can be quite convenient to write a function to manage the acquisition and releasing, taking a function of the acquired value that specifies an action to be performed in between.
param | acq | Resource acquisition |
param | Use | Function to use the acquired resource |
param | Catch | Function to run to handle any exceptions |
param | Fin | Function to invoke to release the resource |
method K<M, A> RepeatIO <M, A> (this K<M, A> ma) Source #
Keeps repeating the computation forever, or until an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
returns | The result of the last invocation |
method K<M, A> RepeatIO <M, A> ( this K<M, A> ma, Schedule schedule) Source #
Keeps repeating the computation, until the scheduler expires, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
returns | The result of the last invocation |
method K<M, A> RepeatWhileIO <M, A> ( this K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns false, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | predicate | Keep repeating while this predicate returns |
returns | The result of the last invocation |
method K<M, A> RepeatWhileIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns false, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
param | predicate | Keep repeating while this predicate returns |
returns | The result of the last invocation |
method K<M, A> RepeatUntilIO <M, A> ( this K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns true, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | predicate | Keep repeating until this predicate returns |
returns | The result of the last invocation |
method K<M, A> RepeatUntilIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns true, or an error occurs
Any resources acquired within a repeated IO computation will automatically be released. This also means you can't acquire resources and return them from within a repeated computation.
param | schedule | Scheduler strategy for repeating |
param | predicate | Keep repeating until this predicate returns |
returns | The result of the last invocation |
method K<M, A> RetryIO <M, A> (this K<M, A> ma) Source #
Retry if the IO computation fails
This variant will retry forever
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, A> RetryIO <M, A> ( this K<M, A> ma, Schedule schedule) Source #
Retry if the IO computation fails
This variant will retry until the schedule expires
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, A> RetryWhileIO <M, A> ( this K<M, A> ma, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying whilst the predicate returns true
for the error generated at each iteration;
at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, A> RetryWhileIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying whilst the predicate returns true
for the error generated at each iteration;
or, until the schedule expires; at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, A> RetryUntilIO <M, A> ( this K<M, A> ma, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying until the predicate returns true
for the error generated at each iteration;
at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, A> RetryUntilIO <M, A> ( this K<M, A> ma, Schedule schedule, Func<Error, bool> predicate) Source #
Retry if the IO computation fails
This variant will keep retrying until the predicate returns true
for the error generated at each iteration;
or, until the schedule expires; at which point the last raised error will be thrown.
Any resources acquired within a retrying IO computation will automatically be released if the operation fails. So, successive retries will not grow the acquired resources on each retry iteration. Any successful operation that acquires resources will have them tracked in the usual way.
method K<M, S> FoldIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder) Source #
method K<M, S> FoldIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method K<M, S> FoldWhileIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<S, bool> stateIs) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<A, bool> valueIs) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method K<M, S> FoldUntilIO <S, M, A> ( this K<M, A> ma, Schedule schedule, S initialState, Func<S, A, S> folder, Func<(S State, A Value), bool> predicate) Source #
method K<M, (A First, B Second)> ZipIO <M, A, B> ( this (K<M, A> First, K<M, B> Second) tuple) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
param | tuple | Tuple of IO monads to run |
returns | IO monad |
method K<M, (A First, B Second, C Third)> ZipIO <M, A, B, C> ( this (K<M, A> First, K<M, B> Second, K<M, C> Third) tuple) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
type | C | Third IO monad bound value type |
param | tuple | Tuple of IO monads to run |
returns | IO monad |
method K<M, (A First, B Second, C Third, D Fourth)> ZipIO <M, A, B, C, D> ( this (K<M, A> First, K<M, B> Second, K<M, C> Third, K<M, D> Fourth) tuple) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
type | C | Third IO monad bound value type |
type | D | Fourth IO monad bound value type |
param | tuple | Tuple of IO monads to run |
returns | IO monad |
method K<M, (A First, B Second)> ZipIO <M, A, B> ( this K<M, A> First, K<M, B> Second) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
returns | IO monad |
method K<M, (A First, B Second, C Third)> ZipIO <M, A, B, C> ( this K<M, A> First, K<M, B> Second, K<M, C> Third) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
type | C | Third IO monad bound value type |
returns | IO monad |
method K<M, (A First, B Second, C Third, D Fourth)> ZipIO <M, A, B, C, D> ( this K<M, A> First, K<M, B> Second, K<M, C> Third, K<M, D> Fourth) Source #
Takes two IO monads and zips their result
Asynchronous operations will run concurrently
type | M | Monad trait type |
type | A | First IO monad bound value type |
type | B | Second IO monad bound value type |
type | C | Third IO monad bound value type |
type | D | Fourth IO monad bound value type |
returns | IO monad |
class IOExtensions Source #
method IO<B> Map <A, B> (this Func<A, B> f, K<IO, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method IO<B> Map <A, B> (this Func<A, B> f, IO<A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method IO<B> Action <A, B> (this IO<A> ma, IO<B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method IO<B> Apply <A, B> (this IO<Func<A, B>> mf, K<IO, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
method IO<B> Apply <A, B> (this K<IO, Func<A, B>> mf, K<IO, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
field IO<EnvIO> env = lift(e => e) Source #
field IO<CancellationToken> token = lift(e => e.Token) Source #
field IO<CancellationTokenSource> source = lift(e => e.Source) Source #
field IO<Option<SynchronizationContext>> syncContext = lift(e => Optional(e.SyncContext)) Source #
method IO<A> fail <A> (Error value) Source #
Put the IO into a failure state
type | A | Bound value type |
param | value | Error value |
returns | IO in a failed state. Always yields an error. |
method IO<A> fail <A> (string value) Source #
Put the IO into a failure state
type | A | Bound value type |
param | value | Error value |
returns | IO in a failed state. Always yields an error. |
method K<M, A> local <M, A> (K<M, A> ma) Source #
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 a IO.cancel
is invoked locally then it will still create an exception that
propagates upwards and so catching cancellations is still important.
type | A | Bound value |
param | ma | Computation to run within the local context |
returns | Result of the computation |
method IO<A> local <A> (K<IO, A> ma) Source #
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 a IO.cancel
is invoked locally then it will still create an exception that
propagates upwards and so catching cancellations is still important.
type | A | Bound value |
param | ma | Computation to run within the local context |
returns | Result of the computation |
method K<M, B> mapIO <M, A, B> (K<M, A> ma, Func<IO<A>, IO<B>> f) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method IO<ForkIO<A>> fork <A> (K<IO, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, ForkIO<A>> fork <M, A> (K<M, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method IO<Ref<A>> refIO <A> (A value, Func<A, bool>? validator = null) Source #
Generates a new reference that can be used within a sync
transaction
Refs
ensure safe shared use of mutable storage locations via a software transactional
memory (STM) system. Refs
are bound to a single storage location for their lifetime,
and only allow mutation of that location to occur within a transaction.
Transactions (within a sync(() => ...)
) should be easy to understand if you’ve ever used database
transactions - they ensure that all actions on Refs are atomic, consistent, and isolated.
- Atomic - means that every change to Refs made within a transaction occurs or none do.
- Consistent - means that each new value can be checked with a validator function before allowing the transaction to commit.
- Isolated - means that no transaction sees the effects of any other transaction while it is running.
Another feature common to STMs is that, should a transaction have a conflict while running, it is automatically retried. The language-ext STM uses multi-version concurrency control for snapshot and serialisable isolation.
In practice, this means:
All reads of Refs will see a consistent snapshot of the Ref world as of the starting point of the transaction (its 'read point'). The transaction will see any changes it has made. This is called the in-transaction-value.
All changes made to Refs during a transaction will appear to occur at a single point in the Ref world timeline (its 'write point').
No changes will have been made by any other transactions to any Refs that have been modified by this transaction.
Readers will never block writers, or other readers.
Writers will never block readers.
I/O and other activities with side effects should be avoided in transactions, since transactions will be retried.
If a constraint on the validity of a value of a Ref that is being changed depends upon the
simultaneous value of a Ref that is not being changed, that second Ref can be protected from
modification by running the sync
transaction with Isolation.Serialisable
.
The language-ext STM is designed to work with the persistent collections (Map
, HashMap
,
Seq
, Lst
, Set,
HashSet` etc.), and it is strongly recommended that you use the language-ext
collections as the values of your Refs. Since all work done in an STM transaction is speculative,
it is imperative that there be a low cost to making copies and modifications. Persistent collections
have free copies (just use the original, it can’t be changed), and 'modifications' share structure
efficiently. In any case:
The values placed in Refs must be, or be considered, immutable. Otherwise, this library can’t help you.
See the concurrency section of the wiki for more info.
param | value | Initial value of the ref |
param | validator | Validator that is called on the ref value just
before any transaction is committed (within a |
method IO<R> atomicIO <R> (Func<R> op, Isolation isolation = Isolation.Snapshot) Source #
Snapshot isolation requires that nothing outside the transaction has written to any of the values that are written-to within the transaction. If anything does write to the values used within the transaction, then the transaction is rolled back and retried (using the latest 'world' state).
Serialisable isolation requires that nothing outside the transaction has written to any of the values that are read-from or written-to within the transaction. If anything does read from or written to the values used within the transaction, then it is rolled back and retried (using the latest 'world' state).
It is the strictest form of isolation, and the most likely to conflict; but protects against cross read/write inconsistencies. For example, if you have:
var x = Ref(1);
var y = Ref(2);
snapshot(() => x.Value = y.Value + 1);
Then something writing to y
mid-way through the transaction would not cause the transaction to fail.
Because y
was only read-from, not written to. However, this:
var x = Ref(1);
var y = Ref(2);
serial(() => x.Value = y.Value + 1);
... would fail if something wrote to y
.
method IO<Unit> atomicIO (Action op, Isolation isolation = Isolation.Snapshot) Source #
Run the op within a new transaction If a transaction is already running, then this becomes part of the parent transaction
Snapshot isolation requires that nothing outside the transaction has written to any of the values that are written-to within the transaction. If anything does write to the values used within the transaction, then the transaction is rolled back and retried (using the latest 'world' state).
Serialisable isolation requires that nothing outside the transaction has written to any of the values that are read-from or written-to within the transaction. If anything does read from or written to the values used within the transaction, then it is rolled back and retried (using the latest 'world' state).
It is the strictest form of isolation, and the most likely to conflict; but protects against cross read/write inconsistencies. For example, if you have:
var x = Ref(1);
var y = Ref(2);
snapshot(() => x.Value = y.Value + 1);
Then something writing to y
mid-way through the transaction would not cause the transaction to fail.
Because y
was only read-from, not written to. However, this:
var x = Ref(1);
var y = Ref(2);
serial(() => x.Value = y.Value + 1);
... would fail if something wrote to y
.
method IO<R> snapshotIO <R> (Func<R> op) Source #
Run the op within a new transaction If a transaction is already running, then this becomes part of the parent transaction
Snapshot isolation requires that nothing outside the transaction has written to any of the values that are written-to within the transaction. If anything does write to the values used within the transaction, then the transaction is rolled back and retried (using the latest 'world' state).
method IO<Unit> snapshotIO (Action op) Source #
Run the op within a new transaction If a transaction is already running, then this becomes part of the parent transaction
Snapshot isolation requires that nothing outside the transaction has written to any of the values that are written-to within the transaction. If anything does write to the values used within the transaction, then the transaction is rolled back and retried (using the latest 'world' state).
method IO<R> serialIO <R> (Func<R> op) Source #
Run the op within a new transaction If a transaction is already running, then this becomes part of the parent transaction
Serialisable isolation requires that nothing outside the transaction has written to any of the values that are read-from or written-to within the transaction. If anything does read from or written to the values used within the transaction, then it is rolled back and retried (using the latest 'world' state).
It is the strictest form of isolation, and the most likely to conflict; but protects against cross read/write inconsistencies. For example, if you have:
var x = Ref(1);
var y = Ref(2);
snapshot(() => x.Value = y.Value + 1);
Then something writing to y
mid-way through the transaction would not cause the transaction to fail.
Because y
was only read-from, not written to. However, this:
var x = Ref(1);
var y = Ref(2);
serial(() => x.Value = y.Value + 1);
... would fail if something wrote to y
.
method IO<Unit> serialIO (Action op) Source #
Run the op within a new transaction If a transaction is already running, then this becomes part of the parent transaction
Serialisable isolation requires that nothing outside the transaction has written to any of the values that are read-from or written-to within the transaction. If anything does read from or written to the values used within the transaction, then it is rolled back and retried (using the latest 'world' state).
It is the strictest form of isolation, and the most likely to conflict; but protects against cross read/write inconsistencies. For example, if you have:
var x = Ref(1);
var y = Ref(2);
snapshot(() => x.Value = y.Value + 1);
Then something writing to y
mid-way through the transaction would not cause the transaction to fail.
Because y
was only read-from, not written to. However, this:
var x = Ref(1);
var y = Ref(2);
serial(() => x.Value = y.Value + 1);
... would fail if something wrote to y
.
method IO<A> commuteIO <A> (Ref<A> r, Func<A, A> f) Source #
Must be called in a transaction. Sets the in-transaction-value of ref to:
`f(in-transaction-value-of-ref)`
and returns the in-transaction-value when complete.
At the commit point of the transaction, f
is run AGAIN with the
most recently committed value:
`f(most-recently-committed-value-of-ref)`
Thus f
should be commutative, or, failing that, you must accept
last-one-in-wins behavior.
Commute allows for more concurrency than just setting the Ref's value
method IO<Atom<A>> atomIO <A> (A value) Source #
Atoms provide a way to manage shared, synchronous, independent state without locks.
The intended use of atom is to hold one an immutable data structure. You change
the value by applying a function to the old value. This is done in an atomic
manner by Swap
.
Internally, Swap
reads the current value, applies the function to it, and
attempts to CompareExchange
it in. Since another thread may have changed the
value in the intervening time, it may have to retry, and does so in a spin loop.
The net effect is that the value will always be the result of the application of the supplied function to a current value, atomically. However, because the function might be called multiple times, it must be free of side effects.
Atoms are an efficient way to represent some state that will never need to be coordinated with any other, and for which you wish to make synchronous changes.
param | value | Initial value of the atom |
returns | The constructed Atom |
method IO<Atom<A>> atomIO <A> (A value, Func<A, bool> validator) Source #
Atoms provide a way to manage shared, synchronous, independent state without locks.
The intended use of atom is to hold one an immutable data structure. You change
the value by applying a function to the old value. This is done in an atomic
manner by Swap
.
Internally, Swap
reads the current value, applies the function to it, and
attempts to CompareExchange
it in. Since another thread may have changed the
value in the intervening time, it may have to retry, and does so in a spin loop.
The net effect is that the value will always be the result of the application of the supplied function to a current value, atomically. However, because the function might be called multiple times, it must be free of side effects.
Atoms are an efficient way to represent some state that will never need to be coordinated with any other, and for which you wish to make synchronous changes.
param | value | Initial value of the atom |
param | validator | Function to run on the value after each state change. If the function returns false for any proposed new state, then the |
returns | The constructed Atom or None if the validation faled for the initial
|
method IO<Atom<M, A>> atomIO <M, A> (M metadata, A value) Source #
Atoms provide a way to manage shared, synchronous, independent state without locks.
The intended use of atom is to hold one an immutable data structure. You change
the value by applying a function to the old value. This is done in an atomic
manner by Swap
.
Internally, Swap
reads the current value, applies the function to it, and
attempts to CompareExchange
it in. Since another thread may have changed the
value in the intervening time, it may have to retry, and does so in a spin loop.
The net effect is that the value will always be the result of the application of the supplied function to a current value, atomically. However, because the function might be called multiple times, it must be free of side effects.
Atoms are an efficient way to represent some state that will never need to be coordinated with any other, and for which you wish to make synchronous changes.
param | metadata | Metadata to be passed to the validation function |
param | value | Initial value of the atom |
returns | The constructed Atom |
method IO<Atom<M, A>> atomIO <M, A> (M metadata, A value, Func<A, bool> validator) Source #
Atoms provide a way to manage shared, synchronous, independent state without locks.
The intended use of atom is to hold one an immutable data structure. You change
the value by applying a function to the old value. This is done in an atomic
manner by Swap
.
Internally, Swap
reads the current value, applies the function to it, and
attempts to CompareExchange
it in. Since another thread may have changed the
value in the intervening time, it may have to retry, and does so in a spin loop.
The net effect is that the value will always be the result of the application of the supplied function to a current value, atomically. However, because the function might be called multiple times, it must be free of side effects.
Atoms are an efficient way to represent some state that will never need to be coordinated with any other, and for which you wish to make synchronous changes.
param | metadata | Metadata to be passed to the validation function |
param | value | Initial value of the atom |
param | validator | Function to run on the value after each state change. If the function returns false for any proposed new state, then the |
returns | The constructed Atom or None if the validation faled for the initial
|
method IO<A> swapIO <A> (Atom<A> ma, Func<A, A> f) Source #
Atomically updates the value by passing the old value to f
and updating
the atom with the result. Note: f
may be called multiple times, so it
should be free of side effects.
param | f | Function to update the atom |
returns | If the swap operation succeeded then a snapshot of the value that was set is returned.
If the swap operation fails (which can only happen due to its validator returning false),
then a snapshot of the current value within the Atom is returned.
If there is no validator for the Atom then the return value is always the snapshot of
the successful |
method IO<A> swapIO <M, A> (Atom<M, A> ma, Func<M, A, A> f) Source #
Atomically updates the value by passing the old value to f
and updating
the atom with the result. Note: f
may be called multiple times, so it
should be free of side effects.
param | f | Function to update the atom |
returns | If the swap operation succeeded then a snapshot of the value that was set is returned.
If the swap operation fails (which can only happen due to its validator returning false),
then a snapshot of the current value within the Atom is returned.
If there is no validator for the Atom then the return value is always the snapshot of
the successful |
method IO<A> swapIO <A> (Atom<A> ma, Func<A, Option<A>> f) Source #
Atomically updates the value by passing the old value to f
and updating
the atom with the result. Note: f
may be called multiple times, so it
should be free of side effects.
param | f | Function to update the atom |
returns |
|
method IO<A> swapIO <M, A> (Atom<M, A> ma, Func<M, A, Option<A>> f) Source #
Atomically updates the value by passing the old value to f
and updating
the atom with the result. Note: f
may be called multiple times, so it
should be free of side effects.
param | f | Function to update the atom |
returns |
|
method IO<A> valueIO <A> (Atom<A> ma) Source #
Retrieve an IO computation that on each invocation will snapshot of the value in an atom
type | A | Value type |
param | ma | Atom to snapshot |
returns | IO representation of the snapshot |
method IO<A> valueIO <M, A> (Atom<M, A> ma) Source #
Retrieve an IO computation that on each invocation will snapshot of the value in an atom
type | A | Value type |
param | ma | Atom to snapshot |
returns | IO representation of the snapshot |
method IO<A> writeIO <A> (Atom<A> ma, A value) Source #
Write a value to an atom.
Note, this can be dangerous and is usually better to use swapIO
if the
value
is derived from a snapshot of the atom's value (via valueIO
).
The computation is better run inside the swap operation for atomic consistency.
However, using writeIO
is reasonable if this is simply a forceful overwrite
of the atomic value without any dependency on the previous state.
type | A | Value type |
param | ma | Atom to write |
returns | IO representation of the write operation |
method IO<A> writeIO <M, A> (Atom<M, A> ma, A value) Source #
Write a value to an atom.
Note, this can be dangerous and is usually better to use swapIO
if the
value
is derived from a snapshot of the atom's value (via valueIO
).
The computation is better run inside the swap operation for atomic consistency.
However, using writeIO
is reasonable if this is simply a forceful overwrite
of the atomic value without any dependency on the previous state.
type | A | Value type |
param | ma | Atom to write |
returns | IO representation of the write operation |
field IO<CancellationToken> cancelToken = IO.lift(e => e.Token) Source #
Access the cancellation-token from the IO environment
returns | CancellationToken |
field IO<Unit> cancel = new IOSync<Unit>( e => { e.Source.Cancel(); throw new TaskCanceledException(); }) Source #
Request a cancellation of the IO expression
field IO<Unit> unitIO = IO<Unit>.Pure(default) Source #
Always yields a Unit
value
field IO<EnvIO> envIO = IO<EnvIO>.Lift(e => e) Source #
Yields the IO environment
method K<M, A> postIO <M, A> (K<M, A> ma) Source #
Make this IO 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<IO, A> post <A> (K<IO, A> ma) Source #
Make this IO 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 IO<ForkIO<A>> fork <A> (K<IO, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, ForkIO<A>> fork <M, A> (K<M, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, ForkIO<Option<A>>> fork <M, A> (StreamT<M, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method IO<ForkIO<Option<A>>> fork <A> (StreamT<IO, A> ma, Option<TimeSpan> timeout = default) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method K<M, A> awaitIO <M, A> (K<M, ForkIO<A>> ma) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method IO<A> awaitIO <A> (K<IO, ForkIO<A>> ma) Source #
Queue this IO operation to run on the thread-pool.
param | timeout | Maximum time that the forked IO operation can run for. |
returns | Returns a |
method IO<Unit> yieldFor (Duration duration) Source #
Yield the thread for the specified duration or until cancelled.
param | duration | Amount of time to yield for |
returns | Unit |
method IO<Unit> yieldFor (TimeSpan timeSpan) Source #
Yield the thread for the specified duration or until cancelled.
param | timeSpan | Amount of time to yield for |
returns | Unit |
method K<M, Seq<A>> awaitAll <M, A> (params K<M, A>[] ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (params K<IO, A>[] ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (params IO<A>[] ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method K<M, Seq<A>> awaitAll <M, A> (params K<M, ForkIO<A>>[] forks) Source #
Awaits all forks
param | forks | Forks to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (params IO<ForkIO<A>>[] mfs) Source #
Awaits all
param | ms | IO operations to await |
returns | Sequence of results |
method K<M, Seq<A>> awaitAll <M, A> (Seq<K<M, A>> ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (Seq<K<IO, A>> ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (Seq<IO<A>> ms) Source #
Awaits all operations
param | ms | Operations to await |
returns | Sequence of results |
method K<M, Seq<A>> awaitAll <M, A> (Seq<K<M, ForkIO<A>>> forks) Source #
Awaits all forks
param | forks | Forks to await |
returns | Sequence of results |
method IO<Seq<A>> awaitAll <A> (Seq<IO<ForkIO<A>>> mfs) Source #
Awaits all
param | ms | IO operations to await |
returns | Sequence of results |
method K<M, A> awaitAny <M, A> (params K<M, A>[] forks) Source #
Awaits for any forks to complete
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 IO<A> awaitAny <A> (params IO<A>[] ms) Source #
Awaits for any IO to complete
param | ms | IO 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 IO<A> awaitAny <A> (params K<IO, A>[] ms) Source #
Awaits for any IO to complete
param | ms | IO 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 #
Awaits for any forks to complete
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 IO<A> awaitAny <A> (params IO<ForkIO<A>>[] forks) Source #
Awaits for any forks to complete
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 #
Awaits for any forks to complete
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 #
Awaits for operations to complete
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 IO<A> awaitAny <A> (Seq<K<IO, A>> ms) Source #
Awaits for any IO to complete
param | ms | IO 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 IO<A> awaitAny <A> (Seq<IO<A>> ms) Source #
Awaits for any IO to complete
param | ms | IO 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 IO<A> awaitAny <A> (Seq<IO<ForkIO<A>>> mfs) Source #
Awaits for any forks to complete
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> timeout <M, A> (TimeSpan timeout, K<M, A> ma) Source #
Timeout operation if it takes too long
method IO<A> timeout <A> (TimeSpan timeout, K<IO, A> ma) Source #
Timeout operation if it takes too long
method K<M, A> repeat <M, A> (K<M, A> ma) Source #
Keeps repeating the computation
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method IO<A> repeat <A> (IO<A> ma) Source #
Keeps repeating the computation
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method K<M, A> repeat <M, A> (Schedule schedule, K<M, A> ma) Source #
Keeps repeating the computation, until the scheduler expires
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 |
method IO<A> repeat <A> (Schedule schedule, K<IO, A> ma) Source #
Keeps repeating the computation, until the scheduler expires
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 |
method K<M, A> repeatWhile <M, A> (K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns false
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method IO<A> repeatWhile <A> (IO<A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns false
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method K<M, A> repeatWhile <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns false
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 |
method IO<A> repeatWhile <A> ( Schedule schedule, K<IO, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns false
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 |
method K<M, A> repeatUntil <M, A> ( K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns true
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method IO<A> repeatUntil <A> ( K<IO, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation until the predicate returns true
type | A | Computation bound value type |
param | ma | Computation to repeat |
returns | The result of the last invocation of |
method K<M, A> repeatUntil <M, A> ( Schedule schedule, K<M, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns true
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 |
method IO<A> repeatUntil <A> ( Schedule schedule, K<IO, A> ma, Func<A, bool> predicate) Source #
Keeps repeating the computation, until the scheduler expires, or the predicate returns true
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 |
method K<M, A> retry <M, A> (K<M, A> ma) Source #
Keeps retrying the computation
type | A | Computation bound value type |
param | ma | Computation to retry |
returns | The result of the last invocation of ma |
method IO<A> retry <A> (K<IO, A> ma) Source #
Keeps retrying the computation
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 #
Keeps retrying the computation, until the scheduler expires
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 IO<A> retry <A> (Schedule schedule, K<IO, A> ma) Source #
Keeps retrying the computation, until the scheduler expires
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 #
Keeps retrying the computation until the predicate returns false
type | A | Computation bound value type |
param | ma | Computation to retry |
returns | The result of the last invocation of ma |
method IO<A> retryWhile <A> ( K<IO, A> ma, Func<Error, bool> predicate) Source #
Keeps retrying the computation until the predicate returns false
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 #
Keeps retrying the computation, until the scheduler expires, or the predicate returns false
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 IO<A> retryWhile <A> ( Schedule schedule, K<IO, A> ma, Func<Error, bool> predicate) Source #
Keeps retrying the computation, until the scheduler expires, or the predicate returns false
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 #
Keeps retrying the computation until the predicate returns true
type | A | Computation bound value type |
param | ma | Computation to retry |
returns | The result of the last invocation of ma |
method IO<A> retryUntil <A> ( K<IO, A> ma, Func<Error, bool> predicate) Source #
Keeps retrying the computation until the predicate returns true
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 #
Keeps retrying the computation, until the scheduler expires, or the predicate returns true
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 IO<A> retryUntil <A> ( Schedule schedule, K<IO, A> ma, Func<Error, bool> predicate) Source #
Keeps retrying the computation, until the scheduler expires, or the predicate returns true
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 IO<B> map <A, B> (Func<A, B> f, K<IO, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f
provided, and
then takes the mapped value and wraps it back up into a new functor.
param | ma | Functor to map |
param | f | Mapping function |
returns | Mapped functor |
method IO<B> action <A, B> (K<IO, A> ma, K<IO, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method IO<B> apply <A, B> (K<IO, Func<A, B>> mf, K<IO, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma
applicative-functor, passes it to the unwrapped function(s) within mf
, and
then takes the resulting value and wraps it back up into a new applicative-functor.
param | ma | Value(s) applicative functor |
param | mf | Mapping function(s) |
returns | Mapped applicative functor |
Holds the acquired resources for the ResourceT
monad transformer
method IO<Unit> ReleaseAll () Source #