Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file caqti_stream_sig.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475(* Copyright (C) 2022 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the LGPL-3.0 Linking Exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* and the LGPL-3.0 Linking Exception along with this library. If not, see
* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.
*)(** Concurrent stream signature. *)moduletypeS=sigtype+'afibertype('a,'err)t=unit->('a,'err)nodefiber(** A stream, represented as a lazy chain of {!Cons}-nodes terminating in a
{!Nil} or an {!Error}. *)and('a,'err)node=|Nil(** The node of an empty stream *)|Errorof'err(** A node of a permanently failed stream. *)|Consof'a*('a,'err)t(** A node holding the next element and continuation of a stream. *)valfold:f:('a->'state->'state)->('a,'err)t->'state->('state,'err)resultfiber(** [fold ~f stream acc] consumes the remainder elements [e1], ..., [eN] of
[stream] and returns [Ok (acc |> f e1 |> ... |> f eN)] if no error
occurred *)valfold_s:f:('a->'state->('state,'err)resultfiber)->('a,'clog)t->'state->('state,[>`Congestedof'clog]as'err)resultfiber(** [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. *)valiter_s:f:('a->(unit,'err)resultfiber)->('a,'clog)t->(unit,[>`Congestedof'clog]as'err)resultfiber(** [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. *)valto_rev_list:('a,'err)t->('alist,'err)resultfiber(** [to_rev_list stream] consumes the remainder of [stream], returning a list
of its element in reverse order of production. *)valto_list:('a,'err)t->('alist,'err)resultfiber(** [to_list stream] consumes the remainder of [stream], returning a list of
its element in order of production. *)valof_list:'alist->('a,'err)t(** [of_list xs] is a non-failing finite stream (re)producing the elements
[xs] in order of occurrence. *)valmap_result:f:('a->('b,'err)result)->('a,'err)t->('b,'err)tend