Idris2Doc : IO.Async.Util

IO.Async.Util

(source)

Definitions

0Handler : Type->Type->Type->Type
Totality: total
Visibility: public export
injectIO : Hasxes=>IO (Eitherxa) ->Asynceesa
  Inject an `IO (Either e a)` computation into an `Async` monad dealing
with several possible errors.

Totality: total
Visibility: export
embed : Lazy (Asynceesa) ->Outcomeesa->Asynceesa
Totality: total
Visibility: export
join : Fiberesa->Asyncefs (Outcomeesa)
  Semantically blocks the current fiber until the given fiber
produces and outcome, and returns the outcome produced.

Totality: total
Visibility: export
wait : Fiberesa->Asyncefs ()
  Awaits the termination of a fiber ignoring its outcome.

Totality: total
Visibility: export
cancel : Fiberesa->Asyncefs ()
  Cancels the given fiber.

This will semantically block the current fiber, until the target has
completed.

Totality: total
Visibility: export
primAsync_ : ((Resultesa->IO1 ()) ->IO1 ()) ->Asynceesa
  Like `primAsync` but does not provide a hook for canceling.

Totality: total
Visibility: export
never : Asynceesa
  A (cancelable) asynchronous computation that will never produce a
result

Totality: total
Visibility: export
awaitOnce : OnceWorlda->Asynceesa
  Awaits the completion of a `Once a`.

Totality: total
Visibility: export
await : DeferredWorlda->Asynceesa
  Awaits the completion of a `Deferred a`.

Totality: total
Visibility: export
racePair : Asynceesa->Asyncefsb->Asyncegs (Either (Outcomeesa, Fiberfsb) (Fiberesa, Outcomefsb))
  A low-level primitive for racing the evaluation of two fibers that returns the [[Outcome]]
of the winner and the [[Fiber]] of the loser. The winner of the race is considered to be
the first fiber that completes with an outcome.

`racePair` is a cancelation-unsafe function; it is recommended to use the safer variants.

Totality: total
Visibility: export
joinWith : Fiberesa-> Lazy (Asynceesa) ->Asynceesa
  Awaits the completion of the bound fiber and returns its result once it completes.

If the fiber completes with [[Outcome.Succeeded]], the successful value is returned. If the
fiber completes with [[Outcome.Errored]], the error is raised. If the fiber completes with
[[Outcome.Canceled]], `onCancel` is run.

Totality: total
Visibility: export
joinWithNeutral : Monoida=>Fiberesa->Asynceesa
  Like `joinWith`, returning the `neutral` value of the `Monoid` in case of
cancelation.

Totality: total
Visibility: export
cancelable : Asynceesa->Asynce [] () ->Asyncees (Maybea)
Totality: total
Visibility: export
raceOutcome : Asynceesa->Asyncefsb->Asyncegs (Either (Outcomeesa) (Outcomefsb))
  Races the evaluation of two fibers that returns the [[Outcome]] of the winner. The winner
of the race is considered to be the first fiber that completes with an outcome. The loser
of the race is canceled before returning.

@param fa
the effect for the first racing fiber
@param fb
the effect for the second racing fiber

@see
[[race]] for a simpler variant that returns the successful outcome.

Totality: total
Visibility: export
race2 : Asynceesa->Asynceesb-> (a->c) -> (b->c) -> Lazy c->Asynceesc
  Races the evaluation of several fibers, returning the result
of the winnner. The other fibers are canceled as soon as one of the
fibers produced an outcome.
case of cancelation.

The semantics of [[race]] are described by the following rules:

1. If the winner completes with [[Outcome.Succeeded]], the race returns the successful
value. The loser is canceled before returning.
2. If the winner completes with [[Outcome.Errored]], the race raises the error.
The loser is canceled before returning.
3. If the winner completes with [[Outcome.Canceled]], the race cancels
the loser and returns its result, fires an error, or returns `Nothing`
its outcome is `Canceled`.

@param fa
the effect for the first racing fiber
@param fb
the effect for the second racing fiber

@see
[[raceOutcome]] for a variant that returns the outcome of the winner.

Totality: total
Visibility: export
hrace : All (Asyncees) ts->Asyncees (Maybe (HSumts))
  This generalizes `race2` to an arbitrary heterogeneous list.

Totality: total
Visibility: export
race : Lazy a->List (Asynceesa) ->Asynceesa
  A more efficient, monomorphic version of `hrace` with slightly
different semantics: The winner decides the outcome of the are
even if it has been cancele.

Totality: total
Visibility: export
race_ : List (Asyncees ()) ->Asyncees ()
  Runs several non-productive fibers in parallel, terminating
as soon as the first one completes.

Totality: total
Visibility: export
bothOutcome : Asynceesa->Asyncefsb->Asyncegs (Outcomeesa, Outcomefsb)
  Races the evaluation of two fibers and returns the [[Outcome]] of both. If the race is
canceled before one or both participants complete, then then whichever ones are incomplete
are canceled.

@param fa
the effect for the first racing fiber
@param fb
the effect for the second racing fiber

@see
[[both]] for a simpler variant that returns the results of both fibers.

Totality: total
Visibility: export
both : Asynceesa->Asynceesb->Asyncees (Maybe (a, b))
  Races the evaluation of two fibers and returns the result of both.

The following rules describe the semantics of [[both]]:

1. If the winner completes with [[Outcome.Succeeded]], the race waits for the loser to
complete.
2. If the winner completes with [[Outcome.Errored]], the race raises the
error. The loser is canceled.
3. If the winner completes with [[Outcome.Canceled]],
the loser and the race are canceled as well.
4. If the loser completes with
[[Outcome.Succeeded]], the race returns the successful value of both fibers.
5. If the
loser completes with [[Outcome.Errored]], the race returns the error.
6. If the loser
completes with [[Outcome.Canceled]], the race is canceled.
7. If the race is canceled
before one or both participants complete, then whichever ones are incomplete are
canceled.

@param fa
the effect for the first racing fiber
@param fb
the effect for the second racing fiber

@see
[[bothOutcome]] for a variant that returns the [[Outcome]] of both fibers.

Totality: total
Visibility: export
par : All (Asyncees) ts->Asyncees (Maybe (HListts))
  Runs the given heterogeneous list of asynchronous computations
in parallel, collecting the results again in a heterogeneous list.

Totality: total
Visibility: export
parseq : List (Asynceesa) ->Asyncees (Maybe (Lista))
  Runs the given list of computations in parallel.

This fails with an error, as soon as the first computation
fails, and it returns `Nothing` as soon as the first computation
is canceled.

Totality: total
Visibility: export
parTraverse : (a->Asynceesb) ->Lista->Asyncees (Maybe (Listb))
  Traverses a list of values effectfully in parallel.

This returns `Nothing` if one of the fibers was canceled.

Totality: total
Visibility: export
lazy : Lazy a->Asynceesa
  Wraps a lazy value in an `Async`.

Totality: total
Visibility: export
sleep : TimerHe=>ClockDuration->Asyncees ()
  Delay a computation by the given number of nanoseconds.

Totality: total
Visibility: export
waitTill : TimerHe=>ClockMonotonic->Asyncees ()
  Delay a computation by the given number of nanoseconds.

Totality: total
Visibility: export
delay : TimerHe=>ClockDuration->Asynceesa->Asynceesa
  Delay a computation by the given number of nanoseconds.

Totality: total
Visibility: export
.ns : Nat->ClockDuration
  Converts a number to nanoseconds

Totality: total
Visibility: export
.us : Nat->ClockDuration
  Converts a number of microseconds to nanoseconds

Totality: total
Visibility: export
.s : Nat->ClockDuration
  Converts a number of seconds to nanoseconds

Totality: total
Visibility: export
.ms : Nat->ClockDuration
  Converts a number of milliseconds to nanoseconds

Totality: total
Visibility: export
.min : Nat->ClockDuration
  Converts a number of minutes to nanoseconds

Totality: total
Visibility: export
.h : Nat->ClockDuration
  Converts a number of hours to nanoseconds

Totality: total
Visibility: export
.d : Nat->ClockDuration
  Converts a number of days to nanoseconds

Totality: total
Visibility: export
delta : HasIOio=>io () ->io (ClockDuration)
  Runs an IO action, returning the time delta it took to run.

Totality: total
Visibility: export
syncApp : AsyncSyncST [] () ->IO ()
Visibility: export
traverseList : (a->Asynceesb) ->Lista->Asyncees (Listb)
  A stack-safe alternative to `traverse`, specialized for `List`.

Totality: total
Visibility: export