= 1024" x-on:close-sidebar="sidebar=window.innerWidth >= 1024 && true">
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
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 singleton : 'a -> 'a t
singleton x
creates a generator containing only x.
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.
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.
map t f
creates a new generator that with one element, (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
append t1 t2
creates a new generator that first echos t1
until it is done, then echos t2