package tezos-lwt-result-stdlib
Tezos: error-aware stdlib replacement
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-v12.3.tar.bz2
sha256=296bb5674bc6050afe6330326fbdd0dfc2255d414bfd6b79cc7666ac6b39316d
sha512=c061cd300a9410300851158d77bf8e56ca3c568b0b1161b38305e5b2efdcd9c746d391f832fdb2826f9a1d6babce10a9b764a4b04f5df42699f7314b9863123a
doc/src/bare_sigs/seq_s.ml.html
Source file seq_s.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
(*****************************************************************************) (* *) (* 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 promise. This allows some additional traversors ([map_s], etc.) to be applied lazily. The functions [of_seq] and [of_seq_s] allow conversion from vanilla sequences. *) module type S = sig (** This is similar to [S.t] but the suspended node is a promise. *) type +'a node = Nil | Cons of 'a * 'a t and 'a t = unit -> 'a node Lwt.t (** [empty] is a sequence with no elements. *) val empty : 'a t (** [return x] is a sequence with the single element [x]. *) val return : 'a -> 'a t (** [return_s p] is a sequence with the value the promise [p] resolves to as its single element. *) val return_s : 'a Lwt.t -> 'a t (** [cons x s] is the sequence containing [x] followed by [s]. It is a whole sequence if [s] is. *) val cons : 'a -> 'a t -> 'a t (** [cons_s p s] is the sequence containing the value the promise [p] resolves to, followed by [s]. *) val cons_s : 'a Lwt.t -> 'a t -> 'a t (** [append s1 s2] is a sequence [s] containing the elements of [s1] followed by the elements of [s2]. *) val append : 'a t -> 'a t -> 'a t (** [first s] resolves to [None] if [s] is empty (and its suspended node resolves), it resolves to [Some x] where [x] is the first element of [s], it does not resolve if the promised node of [s] doesn't. Note that [first] forces the first element of the sequence, which can have side-effects or be computationally expensive. Consider, e.g., the case where [s = filter (fun …) s']: [first s] can force multiple of the values from [s']. *) val first : 'a t -> 'a option Lwt.t (** Similar to {!fold_left} but applies to Lwt-suspended sequences. Because the nodes are suspended in promises, traversing may yield and, consequently, the function [fold_left] returns a promise. *) val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a Lwt.t (** Similar to {!fold_left} but wraps the traversal in {!result}. The traversal is interrupted if one of the step returns an [Error _]. *) val fold_left_e : ('a -> 'b -> ('a, 'trace) result) -> 'a -> 'b t -> ('a, 'trace) result Lwt.t (** Similar to {!fold_left} but the folder is within Lwt. *) val fold_left_s : ('a -> 'b -> 'a Lwt.t) -> 'a -> 'b t -> 'a Lwt.t (** Similar to {!fold_left} but the folder is within result-Lwt. Traversal is interrupted if one of the step resolves to an [Error _]. *) val fold_left_es : ('a -> 'b -> ('a, 'trace) result Lwt.t) -> 'a -> 'b t -> ('a, 'trace) result Lwt.t (** [iter f s] applies [f] to each element of [s]. *) val iter : ('a -> unit) -> 'a t -> unit Lwt.t (** Similar to {!iter} but wraps the iteration in {!result}. The iteration is interrupted if one of the steps returns an [Error _]. *) val iter_e : ('a -> (unit, 'trace) result) -> 'a t -> (unit, 'trace) result Lwt.t (** Similar to {!iter} but wraps the iteration in {!Lwt}. Each step of the iteration is started after the previous one is resolved. *) val iter_s : ('a -> unit Lwt.t) -> 'a t -> unit Lwt.t (** Similar to {!iter} but wraps the iteration in [result Lwt.t]. Each step of the iteration is started after the previous one resolved. The iteration is interrupted if one of the promise is rejected of fulfilled with an [Error _]. *) val iter_es : ('a -> (unit, 'trace) result Lwt.t) -> 'a t -> (unit, 'trace) result Lwt.t (** Similar to {!iter} but wraps the iteration in [result Lwt.t]. The steps of the iteration are started concurrently: one iteration starts as soon as a node becomes resolved. The promise [iter_ep] resolves once all the promises of the traversal resolve. At this point it either: - is rejected if at least one of the promises is, otherwise - is fulfilled with [Error _] if at least one of the promises is, otherwise - is fulfilled with [Ok ()] if all the promises are. *) val iter_ep : ('a -> (unit, 'trace) result Lwt.t) -> 'a t -> (unit, 'trace list) result Lwt.t (** Similar to {!iter} but wraps the iteration in {!Lwt}. The steps of the iteration are started concurrently: one iteration is started as soon as the node becomes resolved. The promise [iter_p f s] is resolved only once all the promises of the iteration are. At this point it is either fulfilled if all promises are, or rejected if at least one of them is. *) val iter_p : ('a -> unit Lwt.t) -> 'a t -> unit Lwt.t val map : ('a -> 'b) -> 'a t -> 'b t val map_s : ('a -> 'b Lwt.t) -> 'a t -> 'b t val filter : ('a -> bool) -> 'a t -> 'a t (** Similar to {!filter} but wraps the transformation in {!Lwt.t}. Each test of the predicate is done sequentially, only starting once the previous one has resolved. *) val filter_s : ('a -> bool Lwt.t) -> 'a t -> 'a t val filter_map : ('a -> 'b option) -> 'a t -> 'b t (** Similar to {!filter_map} but within [Lwt.t]. Not lazy and not tail-recursive. *) val filter_map_s : ('a -> 'b option Lwt.t) -> 'a t -> 'b t val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t val unfold_s : ('b -> ('a * 'b) option Lwt.t) -> 'b -> 'a t val of_seq : 'a Stdlib.Seq.t -> 'a t val of_seq_s : 'a Lwt.t Stdlib.Seq.t -> 'a t end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>