@[inline]
Construct an AsyncTask
that is already resolved with value x
.
Equations
- Std.Internal.IO.Async.AsyncTask.pure x = { get := Except.ok x }
Instances For
Equations
- Std.Internal.IO.Async.AsyncTask.instPure = { pure := fun {α : Type ?u.5} => Std.Internal.IO.Async.AsyncTask.pure }
@[inline]
def
Std.Internal.IO.Async.AsyncTask.bind
{α : Type u_1}
{β : Type u_2}
(x : AsyncTask α)
(f : α → AsyncTask β)
:
Create a new AsyncTask
that will run after x
has finished.
If x
:
- errors, return an
AsyncTask
that resolves to the error. - succeeds, run
f
on the result ofx
and return theAsyncTask
produced byf
.
Equations
- x.bind f = Task.bind x fun (r : Except IO.Error α) => match r with | Except.ok a => f a | Except.error e => { get := Except.error e }
Instances For
@[inline]
def
Std.Internal.IO.Async.AsyncTask.map
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(x : AsyncTask α)
:
Create a new AsyncTask
that will run after x
has finished.
If x
:
- errors, return an
AsyncTask
that reolves to the error. - succeeds, return an
AsyncTask
that resolves tof x
.
Equations
- Std.Internal.IO.Async.AsyncTask.map f x = Task.map (fun (r : Except IO.Error α) => match r with | Except.ok a => Except.ok (f a) | Except.error e => Except.error e) x
Instances For
@[inline]
def
Std.Internal.IO.Async.AsyncTask.bindIO
{α : Type u_1}
{β : Type}
(x : AsyncTask α)
(f : α → IO (AsyncTask β))
:
Similar to bind
, however f
has access to the IO
monad. If f
throws an error, the returned
AsyncTask
resolves to that error.
Equations
- x.bindIO f = IO.bindTask x fun (r : Except IO.Error α) => match r with | Except.ok a => f a | Except.error e => EStateM.Result.error e
Instances For
@[inline]
def
Std.Internal.IO.Async.AsyncTask.mapIO
{α : Type u_1}
{β : Type}
(f : α → IO β)
(x : AsyncTask α)
:
Similar to bind
, however f
has access to the IO
monad. If f
throws an error, the returned
AsyncTask
resolves to that error.
Equations
- Std.Internal.IO.Async.AsyncTask.mapIO f x = IO.mapTask (fun (r : Except IO.Error α) => match r with | Except.ok a => f a | Except.error e => EStateM.Result.error e) x
Instances For
Block until the AsyncTask
in x
finishes.
Equations
- x.block = match x.get with | Except.ok a => pure a | Except.error e => EStateM.Result.error e
Instances For
@[inline]
Create an AsyncTask
that resolves to the value of x
.