123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(** The [S] signature is similar to {!Seq.S} except that suspended nodes are
wrapped in a result-Lwt.
This allows some additional traversors ([map_ep], etc.) to be applied
lazily.
The functions [of_seq] and [of_seq_*] allow conversion from vanilla
sequences. *)moduletypeS=sigtype('a,'e)seq_e_t(* For substitution by [Seq_e.t] *)type'aseq_s_t(* For substitution by [Seq_s.t] *)(** This is similar to {!Seq.S}[.t] but the suspended node is a promised
result.
Similarly to [Seq_e], sequences of this module can be interrupted by an
error. In this case, traversal has fully applied to the successful prefix
before the returned promise evaluates to [Error _].
*)type(+'a,'e)node=Nil|Consof'a*('a,'e)tand('a,'e)t=unit->(('a,'e)node,'e)resultLwt.tvalempty:('a,'e)tvalnil:('a,'e)nodevalcons:'a->('a,'e)t->('a,'e)tvalcons_s:'aLwt.t->('a,'e)t->('a,'e)tvalcons_e:('a,'e)result->('a,'e)t->('a,'e)tvalcons_es:('a,'e)resultLwt.t->('a,'e)t->('a,'e)tvalappend:('a,'e)t->('a,'e)t->('a,'e)tvalreturn:'a->('a,'e)tvalreturn_e:('a,'e)result->('a,'e)tvalreturn_s:'aLwt.t->('a,'e)tvalreturn_es:('a,'e)resultLwt.t->('a,'e)tvalinterrupted:'e->('a,'e)tvalinterrupted_s:'eLwt.t->('a,'e)tvalfirst:('a,'e)t->('a,'e)resultoptionLwt.tvalfold_left:('a->'b->'a)->'a->('b,'e)t->('a,'e)resultLwt.tvalfold_left_e:('a->'b->('a,'e)result)->'a->('b,'e)t->('a,'e)resultLwt.tvalfold_left_e_discriminated:('a->'b->('a,'f)result)->'a->('b,'e)t->('a,('e,'f)Either.t)resultLwt.tvalfold_left_s:('a->'b->'aLwt.t)->'a->('b,'e)t->('a,'e)resultLwt.tvalfold_left_es:('a->'b->('a,'e)resultLwt.t)->'a->('b,'e)t->('a,'e)resultLwt.tvalfold_left_es_discriminated:('a->'b->('a,'f)resultLwt.t)->'a->('b,'e)t->('a,('e,'f)Either.t)resultLwt.tvaliter:('a->unit)->('a,'e)t->(unit,'e)resultLwt.tvaliter_e:('a->(unit,'e)result)->('a,'e)t->(unit,'e)resultLwt.tvaliter_e_discriminated:('a->(unit,'f)result)->('a,'e)t->(unit,('e,'f)Either.t)resultLwt.tvaliter_s:('a->unitLwt.t)->('a,'e)t->(unit,'e)resultLwt.tvaliter_es:('a->(unit,'e)resultLwt.t)->('a,'e)t->(unit,'e)resultLwt.tvaliter_es_discriminated:('a->(unit,'f)resultLwt.t)->('a,'e)t->(unit,('e,'f)Either.t)resultLwt.tvalmap:('a->'b)->('a,'e)t->('b,'e)tvalmap_e:('a->('b,'e)result)->('a,'e)t->('b,'e)tvalmap_s:('a->'bLwt.t)->('a,'e)t->('b,'e)tvalmap_es:('a->('b,'e)resultLwt.t)->('a,'e)t->('b,'e)tvalmap_error:('e->'f)->('a,'e)t->('a,'f)tvalmap_error_s:('e->'fLwt.t)->('a,'e)t->('a,'f)tvalfilter:('a->bool)->('a,'e)t->('a,'e)tvalfilter_e:('a->(bool,'e)result)->('a,'e)t->('a,'e)tvalfilter_s:('a->boolLwt.t)->('a,'e)t->('a,'e)tvalfilter_es:('a->(bool,'e)resultLwt.t)->('a,'e)t->('a,'e)tvalfilter_map:('a->'boption)->('a,'e)t->('b,'e)tvalfilter_map_e:('a->('boption,'e)result)->('a,'e)t->('b,'e)tvalfilter_map_s:('a->'boptionLwt.t)->('a,'e)t->('b,'e)tvalfilter_map_es:('a->('boption,'e)resultLwt.t)->('a,'e)t->('b,'e)tvalunfold:('b->('a*'b)option)->'b->('a,'e)tvalunfold_s:('b->('a*'b)optionLwt.t)->'b->('a,'e)tvalunfold_e:('b->(('a*'b)option,'e)result)->'b->('a,'e)tvalunfold_es:('b->(('a*'b)option,'e)resultLwt.t)->'b->('a,'e)tvalof_seq:'aStdlib.Seq.t->('a,'e)tvalof_seq_s:'aLwt.tStdlib.Seq.t->('a,'e)tvalof_seqs:'aseq_s_t->('a,'e)tvalof_seq_e:('a,'e)resultStdlib.Seq.t->('a,'e)tvalof_seqe:('a,'e)seq_e_t->('a,'e)tvalof_seq_es:('a,'e)resultLwt.tStdlib.Seq.t->('a,'e)tend