package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/bare_structs/Bare_structs/Seq_e/index.html
Module Bare_structs.Seq_e
Source
include Bare_sigs.Seq_e.S
type ('a, 'e) t = unit -> (('a, 'e) node, 'e) Stdlib.result
include Seqes.Sigs.SEQMON2ALL
with type ('a, 'e) mon := ('a, 'e) Stdlib.result
with type ('a, 'e) t := ('a, 'e) t
val iter : ('a -> unit) -> ('a, 'e) t -> (unit, 'e) Stdlib.result
val fold_left : ('a -> 'b -> 'a) -> 'a -> ('b, 'e) t -> ('a, 'e) Stdlib.result
val iteri : (int -> 'a -> unit) -> ('a, 'e) t -> (unit, 'e) Stdlib.result
val fold_lefti :
('b -> int -> 'a -> 'b) ->
'b ->
('a, 'e) t ->
('b, 'e) Stdlib.result
val for_all : ('a -> bool) -> ('a, 'e) t -> (bool, 'e) Stdlib.result
val exists : ('a -> bool) -> ('a, 'e) t -> (bool, 'e) Stdlib.result
val find : ('a -> bool) -> ('a, 'e) t -> ('a option, 'e) Stdlib.result
val find_map : ('a -> 'b option) -> ('a, 'e) t -> ('b option, 'e) Stdlib.result
val init : int -> (int -> 'a) -> ('a, 'e) t
val unfold : ('b -> ('a * 'b) option) -> 'b -> ('a, 'e) t
val forever : (unit -> 'a) -> ('a, 'e) t
val iterate : ('a -> 'a) -> 'a -> ('a, 'e) t
val of_dispenser : (unit -> 'a option) -> ('a, 'e) t
val is_empty : ('a, 'e) t -> (bool, 'e) Stdlib.result
val length : ('a, 'e) t -> (int, 'e) Stdlib.result
val empty : ('a, 'e) t
val return : 'a -> ('a, 'e) t
val repeat : 'a -> ('a, 'e) t
val to_dispenser : ('a, 'e) t -> unit -> ('a option, 'e) Stdlib.result
val ints : int -> (int, 'e) t
val of_seq : 'a Stdlib.Seq.t -> ('a, 'e) t
return_e (Ok x)
is a whole sequence containing the single element x
. return_e (Error e)
is a sequence immediately interrupted by the error e
.
interrupted e
is a sequence immediately interrupted by the error e
.
map_error f seq
is a sequence feq
.
- If
seq
is a whole sequence, thenfeq
is the same whole sequence. - If
seq
is an interrupted sequence, thenfeq
is a sequence interrupted byError (f e)
where the elements of the successful prefix are the elements of the successful prefix ofseq
.
iter_p f seq
is a promise p
.
- If
seq
is a whole sequence, thenp
resolves toOk ()
once all the promises created byf
on the elements ofseq
have resolved. - If
seq
is interrupted byError e
, thenp
resolves toError e
once all the promises created byf
on the elements of the successful prefix ofseq
have resolved.
Note that the behaviour for interrupted sequences is in line with the best-effort semantic of Lwtreslib.
cons_e (Ok x) s
is the sequence containing x
followed by s
. It is a whole sequence if s
is.
cons_e (Error e) s
is a sequence immediately interrupted by e
.
module E :
Seqes.Sigs.SEQMON2TRANSFORMERS
with type ('a, 'e) t := ('a, 'e) t
and type ('a, 'e) mon := ('a, 'e) Stdlib.result
and type ('a, 'e) callermon := ('a, 'e) Stdlib.result
module S :
Seqes.Sigs.SEQMON2TRAVERSORS
with type ('a, 'e) t := ('a, 'e) t
and type ('a, 'e) mon := ('a, 'e) Stdlib.result Lwt.t
and type ('a, 'e) callermon := 'a Lwt.t
module ES :
Seqes.Sigs.SEQMON2TRAVERSORS
with type ('a, 'e) t := ('a, 'e) t
and type ('a, 'e) mon := ('a, 'e) Stdlib.result Lwt.t
and type ('a, 'e) callermon := ('a, 'e) Stdlib.result Lwt.t
of_seq_catch s
is a sequence with the same elements as s
which is interrupted when forcing an element of the sequence raises an exception.
of_seq_once ~when_forced_twice s
is a sequence with the same elements as s
which is interrupted when an element of the sequence is forced twice.
In other words, it is equivalent to
map_error
(function Seq.Forced_twice -> when_forced_twice | e -> raise e)
(of_seq_catch (Seq.once s))