From a20b96144a616812820b1732c76012189227bd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 14 Sep 2022 15:46:19 +0200 Subject: [PATCH] Env-v7: add missing list functions --- src/lib_protocol_environment/sigs/v7.ml | 14 ++++++++++++++ src/lib_protocol_environment/sigs/v7/list.mli | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/lib_protocol_environment/sigs/v7.ml b/src/lib_protocol_environment/sigs/v7.ml index 69f09c0323ac..62a0b16a4875 100644 --- a/src/lib_protocol_environment/sigs/v7.ml +++ b/src/lib_protocol_environment/sigs/v7.ml @@ -6249,6 +6249,9 @@ val nil_es : ('a list, 'trace) result Lwt.t (** [cons x xs] is [x :: xs] *) val cons : 'a -> 'a list -> 'a list +(** [is_empty xs] is [true] iff [xs] is [[]] *) +val is_empty : 'a list -> bool + (** {3 Safe wrappers} This part of the module simply shadows some functions from {!Stdlib.List} @@ -7045,6 +7048,7 @@ val filter_map_es : (** [filter_map_p] is a variant of {!filter_map_s} where the promises are evaluated concurrently. *) val filter_map_p : ('a -> 'b option Lwt.t) -> 'a list -> 'b list Lwt.t +(** [concat_map f xs] is [concat (map f xs)] but more efficient. *) val concat_map : ('a -> 'b list) -> 'a list -> 'b list (** [concat_map_s] is an Lwt-aware variant of {!concat_map}. *) @@ -7368,6 +7372,16 @@ val combine_drop : 'a list -> 'b list -> ('a * 'b) list val combine_with_leftovers : 'a list -> 'b list -> ('a * 'b) list * ('a list, 'b list) Either.t option +(** {3 Product} *) + +(** [product xs ys] is the cartesian product of [xs] and [ys]. + + In other words [product xs ys] is a list containing all the pairs [(x, y)] + where [x] is an element of [xs] and [y] is an element of [ys]. + + The order of the elements in the returned list is unspecified. *) +val product : 'a list -> 'b list -> ('a * 'b) list + (** {3 Comparison and equality} The comparison and equality functions are those of the OCaml [Stdlib]. *) diff --git a/src/lib_protocol_environment/sigs/v7/list.mli b/src/lib_protocol_environment/sigs/v7/list.mli index ff71d0bb52b9..63298a2f4ba1 100644 --- a/src/lib_protocol_environment/sigs/v7/list.mli +++ b/src/lib_protocol_environment/sigs/v7/list.mli @@ -103,6 +103,9 @@ val nil_es : ('a list, 'trace) result Lwt.t (** [cons x xs] is [x :: xs] *) val cons : 'a -> 'a list -> 'a list +(** [is_empty xs] is [true] iff [xs] is [[]] *) +val is_empty : 'a list -> bool + (** {3 Safe wrappers} This part of the module simply shadows some functions from {!Stdlib.List} @@ -899,6 +902,7 @@ val filter_map_es : (** [filter_map_p] is a variant of {!filter_map_s} where the promises are evaluated concurrently. *) val filter_map_p : ('a -> 'b option Lwt.t) -> 'a list -> 'b list Lwt.t +(** [concat_map f xs] is [concat (map f xs)] but more efficient. *) val concat_map : ('a -> 'b list) -> 'a list -> 'b list (** [concat_map_s] is an Lwt-aware variant of {!concat_map}. *) @@ -1222,6 +1226,16 @@ val combine_drop : 'a list -> 'b list -> ('a * 'b) list val combine_with_leftovers : 'a list -> 'b list -> ('a * 'b) list * ('a list, 'b list) Either.t option +(** {3 Product} *) + +(** [product xs ys] is the cartesian product of [xs] and [ys]. + + In other words [product xs ys] is a list containing all the pairs [(x, y)] + where [x] is an element of [xs] and [y] is an element of [ys]. + + The order of the elements in the returned list is unspecified. *) +val product : 'a list -> 'b list -> ('a * 'b) list + (** {3 Comparison and equality} The comparison and equality functions are those of the OCaml [Stdlib]. *) -- GitLab