package tezos-lwt-result-stdlib

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

Module Bare_structs.Seq_sSource

include Bare_sigs.Seq_s.S
Sourcetype +'a node =
  1. | Nil
  2. | Cons of 'a * 'a t

This is similar to S.t but the suspended node is a promise.

Sourceand 'a t = unit -> 'a node Lwt.t
Sourceval empty : 'a t

empty is a sequence with no elements.

Sourceval return : 'a -> 'a t

return x is a sequence with the single element x.

Sourceval return_s : 'a Lwt.t -> 'a t

return_s p is a sequence with the value the promise p resolves to as its single element.

Sourceval cons : 'a -> 'a t -> 'a t

cons x s is the sequence containing x followed by s. It is a whole sequence if s is.

Sourceval cons_s : 'a Lwt.t -> 'a t -> 'a t

cons_s p s is the sequence containing the value the promise p resolves to, followed by s.

Sourceval append : 'a t -> 'a t -> 'a t

append s1 s2 is a sequence s containing the elements of s1 followed by the elements of s2.

Sourceval first : 'a t -> 'a option Lwt.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'.

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

Sourceval fold_left_e : ('a -> 'b -> ('a, 'trace) Stdlib.result) -> 'a -> 'b t -> ('a, 'trace) Stdlib.result Lwt.t

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

Sourceval fold_left_s : ('a -> 'b -> 'a Lwt.t) -> 'a -> 'b t -> 'a Lwt.t

Similar to fold_left but the folder is within Lwt.

Sourceval 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 the folder is within result-Lwt. Traversal is interrupted if one of the step resolves to an Error _.

Sourceval iter : ('a -> unit) -> 'a t -> unit Lwt.t

iter f s applies f to each element of s.

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

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

Sourceval 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 is resolved.

Sourceval 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 _.

Sourceval 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. 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.
Sourceval iter_p : ('a -> unit Lwt.t) -> 'a t -> unit 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.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t
Sourceval map_s : ('a -> 'b Lwt.t) -> 'a t -> 'b t
Sourceval filter : ('a -> bool) -> 'a t -> 'a t
Sourceval filter_s : ('a -> bool Lwt.t) -> '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.

Sourceval filter_map : ('a -> 'b option) -> 'a t -> 'b t
Sourceval filter_map_s : ('a -> 'b option Lwt.t) -> 'a t -> 'b t

Similar to filter_map but within Lwt.t. Not lazy and not tail-recursive.

Sourceval unfold : ('b -> ('a * 'b) option) -> 'b -> 'a t
Sourceval unfold_s : ('b -> ('a * 'b) option Lwt.t) -> 'b -> 'a t
Sourceval of_seq : 'a Stdlib.Seq.t -> 'a t
Sourceval of_seq_s : 'a Lwt.t Stdlib.Seq.t -> 'a t
OCaml

Innovation. Community. Security.