A generator is a consumer-driven source of data. Unlike Async streams, these
* objects are stateful. For example, if one generator is shared between two clients
* that both invoke next
, then they will see different sequences of items
val empty : 'a t
val create : (unit ‑> [ `Done | `Ok of 'a ] Async.Deferred.t) ‑> 'a t
val unfold : 'state ‑> ('state ‑> [ `Done | `Ok of 'a * 'state ] Async.Deferred.t) ‑> 'a t
val of_list : 'a list ‑> 'a t
val find : 'a t ‑> f:('a ‑> bool) ‑> 'a option Async.Deferred.t
find gen ~f
finds the first item for which f item
is true.
f item
is true,
or None if no such element is found.val fold' : 'a t ‑> init:'b ‑> f:('b ‑> 'a ‑> 'b Async.Deferred.t) ‑> 'b Async.Deferred.t
val fold : 'a t ‑> init:'b ‑> f:('b ‑> 'a ‑> 'b) ‑> 'b Async.Deferred.t
val iter' : 'a t ‑> f:('a ‑> unit Async.Deferred.t) ‑> unit Async.Deferred.t
val iter : 'a t ‑> f:('a ‑> unit) ‑> unit Async.Deferred.t
val to_list : 'a t ‑> 'a list Async.Deferred.t
Generates all elements from generator and returns the resulting list.
val map' : 'a t ‑> f:('a ‑> 'b Async.Deferred.t) ‑> 'b t
map' t f
creates a new generator that with the result of the deferred (f v),
for each element v of t.
val next : 'a t ‑> [ `Done | `Ok of 'a ] Async.Deferred.t
val to_stream : 'a t ‑> 'a Async.Stream.t