Bare_structs.Seq
include Bare_sigs.Seq.S
Common interface with Stdlib
Note that some functions (namely init
, take
, and drop
) are shadowed with exception-less versions.
Note that once
is not shadowed. Be careful when using once
: the resulting sequence is ephemeral and using in a non-ephemeral way raises an exception. As a safer alternative, you can use Seq_e.of_seq_once
which gives you a result-based (exception-less) ephemeral sequence.
include module type of Stdlib.Seq
with type 'a t = 'a Stdlib.Seq.t
and type 'a node = 'a Stdlib.Seq.node
val is_empty : 'a t -> bool
val length : 'a t -> int
val iter : ('a -> unit) -> 'a t -> unit
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
val iteri : (int -> 'a -> unit) -> 'a t -> unit
val fold_lefti : ('b -> int -> 'a -> 'b) -> 'b -> 'a t -> 'b
val for_all : ('a -> bool) -> 'a t -> bool
val exists : ('a -> bool) -> 'a t -> bool
val find : ('a -> bool) -> 'a t -> 'a option
val find_map : ('a -> 'b option) -> 'a t -> 'b option
val empty : 'a t
val return : 'a -> 'a t
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t
val repeat : 'a -> 'a t
val forever : (unit -> 'a) -> 'a t
val iterate : ('a -> 'a) -> 'a -> 'a t
val of_dispenser : (unit -> 'a option) -> 'a t
val to_dispenser : 'a t -> unit -> 'a option
val ints : int -> int t
val init :
when_negative_length:'err ->
int ->
(int -> 'a) ->
('a t, 'err) Stdlib.result
val iter_ep :
('a -> (unit, 'trace) Stdlib.result Lwt.t) ->
'a t ->
(unit, 'trace list) Stdlib.result Lwt.t
Similar to iter
but wraps the iteration in result Lwt.t
. All the steps of the iteration are started concurrently. The promise iter_ep
resolves once all the promises of the traversal resolve. At this point it either:
Error _
if at least one of the promises is, otherwiseOk ()
if all the promises are.val iter_p : ('a -> unit Lwt.t) -> 'a t -> unit Lwt.t
Similar to iter
but wraps the iteration in Lwt
. All the steps of the iteration are started concurrently. 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 iteri_ep :
(int -> 'a -> (unit, 'trace) Stdlib.result Lwt.t) ->
'a t ->
(unit, 'trace list) Stdlib.result Lwt.t
Similar to iteri
but wraps the iteration in result Lwt.t
. All the steps of the iteration are started concurrently. The promise iteri_ep
resolves once all the promises of the traversal resolve. At this point it either:
Error _
if at least one of the promises is, otherwiseOk ()
if all the promises are.val iteri_p : (int -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t
Similar to iteri
but wraps the iteration in Lwt
. All the steps of the iteration are started concurrently. 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 iter2_ep :
('a -> 'b -> (unit, 'trace) Stdlib.result Lwt.t) ->
'a t ->
'b t ->
(unit, 'trace list) Stdlib.result Lwt.t
Similar to iter2
but wraps the iteration in result Lwt.t
. All the steps of the iteration are started concurrently. The promise iter2_ep f s1 s2
resolves once all the promises of the traversal resolve. At this point it is either:
Error _
if at least one of the promises is,Ok ()
if all of the promises are.Note that similarly to Stdlib
.Seq.iter2 this function iterates on the common-length prefix of the two sequences. As a result, the iteration can be successful even if the two sequences are of different lengths.
Similar to iter2
but wraps the iteration in Lwt
. All the steps of the iteration are started concurrently. The promise iter2_p f s1 s2
resolves once all the promises of the traversal resolve. At this point it is either:
()
if all of the promises are.Note that similarly to Stdlib
.Seq.iter2 this function iterates on the common-length prefix of the two sequences. As a result, the iteration can be successful even if the two sequences are of different lengths.