package tezos-lwt-result-stdlib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parameters

Signature

include Bare_sigs.Seq.S

Common interface with Stdlib

include module type of Stdlib.Seq with type 'a t = 'a Stdlib.Seq.t and type 'a node = 'a Stdlib.Seq.node
type !'a0 t = 'a Stdlib.Seq.t
and !'a1 node = 'a Stdlib.Seq.node =
  1. | Nil
  2. | Cons of 'a0 * 'a0 t
val is_empty : 'a t -> bool
val uncons : 'a t -> ('a * 'a t) option
val length : 'a t -> int
val iter : ('a -> unit) -> 'a t -> unit
val fold_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
val iteri : (int -> 'a -> unit) -> 'a t -> unit
val fold_lefti : ('acc -> int -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc
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_index : ('a -> bool) -> 'a t -> int option
val find_map : ('a -> 'b option) -> 'a t -> 'b option
val find_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b option
val iter2 : ('a -> 'b -> unit) -> 'a t -> 'b t -> unit
val fold_left2 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a t -> 'b t -> 'acc
val for_all2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val exists2 : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val equal : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val compare : ('a -> 'b -> int) -> 'a t -> 'b t -> int
val empty : 'a t
val return : 'a -> 'a t
val cons : 'a -> 'a t -> 'a t
val init : int -> (int -> 'a) -> 'a t
val unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t
val repeat : 'a -> 'a t
val forever : (unit -> 'a) -> 'a t
val cycle : 'a t -> 'a t
val iterate : ('a -> 'a) -> 'a -> 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
val filter : ('a -> bool) -> 'a t -> 'a t
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
val scan : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b t
val take : int -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val take_while : ('a -> bool) -> 'a t -> 'a t
val drop_while : ('a -> bool) -> 'a t -> 'a t
val group : ('a -> 'a -> bool) -> 'a t -> 'a t t
val memoize : 'a t -> 'a t
exception Forced_twice
val once : 'a t -> 'a t
val transpose : 'a t t -> 'a t t
val append : 'a t -> 'a t -> 'a t
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
val zip : 'a t -> 'b t -> ('a * 'b) t
val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
val interleave : 'a t -> 'a t -> 'a t
val sorted_merge : ('a -> 'a -> int) -> 'a t -> 'a t -> 'a t
val product : 'a t -> 'b t -> ('a * 'b) t
val map_product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t
val unzip : ('a * 'b) t -> 'a t * 'b t
val split : ('a * 'b) t -> 'a t * 'b t
val partition_map : ('a -> ('b, 'c) Stdlib.Either.t) -> 'a t -> 'b t * 'c t
val partition : ('a -> bool) -> 'a t -> 'a t * 'a t
val of_dispenser : (unit -> 'a option) -> 'a t
val to_dispenser : 'a t -> unit -> 'a option
val ints : int -> int t

Lwtreslib-specific extensions

val first : 'a t -> 'a option

first s is None if s is empty, it is Some x where x is the first element of s otherwise.

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 fold_left_e : ('a -> 'b -> ('a, 'trace) Stdlib.result) -> 'a -> 'b t -> ('a, 'trace) Stdlib.result

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_s : ('a -> 'b -> 'a Lwt.t) -> 'a -> 'b t -> 'a Lwt.t

Similar to fold_left but wraps the traversing in Lwt. Each step of the traversal is started after the previous one has resolved. The traversal is interrupted if one of the promise is rejected.

val fold_left_es : ('a -> 'b -> ('a, 'trace) Stdlib.result Lwt.t) -> 'a -> 'b t -> ('a, 'trace) Stdlib.result Lwt.t

Similar to fold_left but wraps the traversing in result Lwt.t. Each step of the traversal is started after the previous one resolved. The traversal is interrupted if one of the step is rejected or is fulfilled with Error _.

val iter_e : ('a -> (unit, 'trace) Stdlib.result) -> 'a t -> (unit, 'trace) Stdlib.result

Similar to iter but wraps the iteration in result. The iteration is interrupted if one of the step returns an Error _.

val iter_s : ('a -> unit Lwt.t) -> 'a t -> unit Lwt.t

Similar to iter but wraps the iteration in Lwt. Each step of the iteration is started after the previous one resolved. The iteration is interrupted if one of the promise is rejected.

val iter_es : ('a -> (unit, 'trace) Stdlib.result Lwt.t) -> 'a t -> (unit, 'trace) Stdlib.result 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_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.

Values which have made it to the Stdlib since then

This section is for forward compatibility: bringing you the features of more recent OCaml Stdlib than we compile against.

val concat : 'a t t -> 'a t

concat s is a sequence containing the elements of the elements of s.

val concat_map : ('a -> 'b t) -> 'a t -> 'b t

concat_map is an alias for flat_map

val iter_ep : ('a -> (unit, 'error Monad.trace) Stdlib.result Lwt.t) -> 'a t -> (unit, 'error Monad.trace) 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:

  • 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.
OCaml

Innovation. Community. Security.