File: .lake/packages/lean4/src/lean/Lean/Server/AsyncList.lean

full_name: IO.AsyncList.delayed
code: /-- 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 `ε`. -/
inductive AsyncList (ε : Type u) (α : Type v) where
  | cons (hd : α) (tl : AsyncList ε α)
  | delayed (tl : Task $ Except ε $ AsyncList ε α)
  | nil
goal: IO.AsyncList ε α

full_name: IO.AsyncList.cons
code: /-- 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 `ε`. -/
inductive AsyncList (ε : Type u) (α : Type v) where
  | cons (hd : α) (tl : AsyncList ε α)
  | delayed (tl : Task $ Except ε $ AsyncList ε α)
  | nil
goal: IO.AsyncList ε α

full_name: IO.AsyncList.nil
code: /-- 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 `ε`. -/
inductive AsyncList (ε : Type u) (α : Type v) where
  | cons (hd : α) (tl : AsyncList ε α)
  | delayed (tl : Task $ Except ε $ AsyncList ε α)
  | nil
goal: IO.AsyncList ε α

full_name: IO.AsyncList
code: /-- 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 `ε`. -/
inductive AsyncList (ε : Type u) (α : Type v) where
  | cons (hd : α) (tl : AsyncList ε α)
  | delayed (tl : Task $ Except ε $ AsyncList ε α)
  | nil
goal: Type (max u v)

full_name: IO.AsyncList.instInhabited
code: instance : Inhabited (AsyncList ε α) 
goal: Inhabited (IO.AsyncList ε α)

full_name: IO.AsyncList.append
code: partial def append : AsyncList ε α → AsyncList ε α → AsyncList ε α
  
goal: IO.AsyncList ε α → IO.AsyncList ε α → IO.AsyncList ε α

full_name: IO.AsyncList.instAppend
code: instance : Append (AsyncList ε α) 
goal: Append (IO.AsyncList ε α)

full_name: IO.AsyncList.ofList
code: def ofList : List α → AsyncList ε α 
goal: List α → IO.AsyncList ε α

full_name: IO.AsyncList.instCoeList
code: instance : Coe (List α) (AsyncList ε α) 
goal: Coe (List α) (IO.AsyncList ε α)

full_name: IO.AsyncList.unfoldAsync.step
code: /-- 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. -/
partial def unfoldAsync (f : StateT σ (EIO ε) $ Option α) (init : σ)
    : BaseIO (AsyncList ε α) 
goal: EIO ε (IO.AsyncList ε α)

full_name: IO.AsyncList.unfoldAsync
code: /-- 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. -/
partial def unfoldAsync (f : StateT σ (EIO ε) $ Option α) (init : σ)
    : BaseIO (AsyncList ε α) 
goal: BaseIO (IO.AsyncList ε α)

full_name: IO.AsyncList.getAll
code: /-- The computed, synchronous list. If an async tail was present, returns also
its terminating value. -/
partial def getAll : AsyncList ε α → List α × Option ε
  
goal: IO.AsyncList ε α → List α × Option ε

full_name: IO.AsyncList.waitUntil
code: /-- Spawns a `Task` returning the prefix of elements up to (including) the first element for which `p` is true.
When `p` is not true of any element, it returns the entire list. -/
partial def waitUntil (p : α → Bool) : AsyncList ε α → Task (List α × Option ε)
  
goal: IO.AsyncList ε α → Task (List α × Option ε)

full_name: IO.AsyncList.waitAll
code: /-- Spawns a `Task` waiting on all elements. -/
def waitAll : AsyncList ε α → Task (List α × Option ε) 
goal: IO.AsyncList ε α → Task (List α × Option ε)

full_name: IO.AsyncList.waitFind?
code: /-- Spawns a `Task` acting like `List.find?` but which will wait for tail evaluation
when necessary to traverse the list. If the tail terminates before a matching element
is found, the task throws the terminating value. -/
partial def waitFind? (p : α → Bool) : AsyncList ε α → Task (Except ε (Option α))
  
goal: IO.AsyncList ε α → Task (Except ε (Option α))

full_name: IO.AsyncList.getFinishedPrefix
code: /-- Retrieve the already-computed prefix of the list. If computation has finished with an error, return it as well. -/
partial def getFinishedPrefix : AsyncList ε α → BaseIO (List α × Option ε)
  
goal: IO.AsyncList ε α → BaseIO (List α × Option ε)

full_name: IO.AsyncList.waitHead?
code: def waitHead? (as : AsyncList ε α) : Task (Except ε (Option α)) 
goal: Task (Except ε (Option α))

full_name: IO.AsyncList.cancel
code: /-- Cancels all tasks in the list. -/
partial def cancel : AsyncList ε α → BaseIO Unit
  
goal: IO.AsyncList ε α → BaseIO Unit