- cons: {ε : Type u} → {α : Type v} → α → IO.AsyncList ε α → IO.AsyncList ε α
- delayed: {ε : Type u} → {α : Type v} → Task (Except ε (IO.AsyncList ε α)) → IO.AsyncList ε α
- nil: {ε : Type u} → {α : Type v} → IO.AsyncList ε α
An async IO list is like a lazy list but instead of being unevaluated Thunk
s,
delayed
suffixes are Task
s being evaluated asynchronously. A delayed suffix can signal the end
of computation (successful or due to a failure) with a terminating value of type ε
.
Equations
- IO.AsyncList.instInhabitedAsyncList = { default := IO.AsyncList.nil }
Equations
- IO.AsyncList.instAppendAsyncList = { append := IO.AsyncList.append }
Equations
- IO.AsyncList.ofList = List.foldr IO.AsyncList.cons IO.AsyncList.nil
Equations
- IO.AsyncList.instCoeListAsyncList = { coe := IO.AsyncList.ofList }
A stateful step computation f
is applied iteratively, forming an async
stream. The stream ends once f
returns none
for the first time.
For cooperatively cancelling an ongoing computation, we recommend referencing
a cancellation token in f
and checking it when appropriate.
Equations
- IO.AsyncList.unfoldAsync f init = do let tInit ← EIO.asTask (IO.AsyncList.unfoldAsync.step f init) Task.Priority.default pure (IO.AsyncList.delayed tInit)
The computed, synchronous list. If an async tail was present, returns also its terminating value.
Spawns a Task
acting like List.find?
but which will wait for tail evalution
when necessary to traverse the list. If the tail terminates before a matching element
is found, the task throws the terminating value.
Retrieve the already-computed prefix of the list. If computation has finished with an error, return it as well.
Equations
- IO.AsyncList.waitHead? as = IO.AsyncList.waitFind? (fun x => true) as