package caqti-async
-
caqti-async
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
type ('a, 'err) t = unit -> ('a, 'err) node Async_kernel.Deferred.t
and ('a, 'err) node =
| Nil
The node of an empty stream
*)| Error of 'err
A node of a permanently failed stream.
*)| Cons of 'a * ('a, 'err) t
A node holding the next element and continuation of a stream.
*)val fold :
f:('a -> 'state -> 'state) ->
('a, 'err) t ->
'state ->
('state, 'err) result Async_kernel.Deferred.t
fold ~f stream acc
consumes the remainder elements e1
, ..., eN
of stream
and returns Ok (acc |> f e1 |> ... |> f eN)
if no error occurred
val fold_s :
f:('a -> 'state -> ('state, 'err) result Async_kernel.Deferred.t) ->
('a, 'clog) t ->
'state ->
('state, [> `Congested of 'clog ] as 'err) result Async_kernel.Deferred.t
fold_s ~f stream acc
consumes the remainder of stream
, passing each element in order to f
along with the latest accumulation starting at acc
, and returning the final accumulation if successful. An error result may be due to either the stream provider or the callback, as distinguished with the `Congested
constructor.
val iter_s :
f:('a -> (unit, 'err) result Async_kernel.Deferred.t) ->
('a, 'clog) t ->
(unit, [> `Congested of 'clog ] as 'err) result Async_kernel.Deferred.t
iter_s ~f stream
consumes the remainder of stream
, passing each element in order to f
. An error result may be due to either the steram provider or the callback, as distinguished with the `Congested
constructor.
val to_rev_list :
('a, 'err) t ->
('a list, 'err) result Async_kernel.Deferred.t
to_rev_list stream
consumes the remainder of stream
, returning a list of its element in reverse order of production.
val to_list : ('a, 'err) t -> ('a list, 'err) result Async_kernel.Deferred.t
to_list stream
consumes the remainder of stream
, returning a list of its element in order of production.
val of_list : 'a list -> ('a, 'err) t
of_list xs
is a non-failing finite stream (re)producing the elements xs
in order of occurrence.