From 4fb0df50e9bc6ca83541a41dcbca7a8923ff1776 Mon Sep 17 00:00:00 2001 From: Master Builder Date: Thu, 3 Aug 2023 14:31:44 +0000 Subject: [PATCH 1/5] Add missing required dependency to build instructions in Contributing section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6df18daa5..d12b5a18a 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ to list authors based on the git commits. Assuming your are in a clone of the repository: 1. Some dependencies are required, you'll need - `opam install benchmark qcheck-core iter gen mdx uutf`. + `opam install benchmark qcheck-core iter gen mdx uutf yojson`. 2. run `make all` to enable everything (including tests). 3. make your changes, commit, push, and open a PR. 4. use `make test` without moderation! It must pass before a PR From 528b9030a4ea089d623d7cb49badb717e60ed661 Mon Sep 17 00:00:00 2001 From: Master Builder Date: Thu, 3 Aug 2023 14:51:13 +0000 Subject: [PATCH 2/5] fix(CCMultiMap): Rename functions find_left and find_right in the bidirectional multimap to find_left_iter and find_right_iter respectively to reflect their usage, and add new functions to replace the old find_left and find_right that return a list of values rather than an iterator, to make the signatures of CCMultiMap.S and CCMultiMap.BIDIR cohere. Additionally, change the return type of S.find_iter from `t -> key -> (value -> unit) -> unit` to `t -> key -> value iter`. These types are the same though, it's just for clarity since CCMultiMap already exposes an iter type --- src/data/CCMultiMap.ml | 37 ++++++++++++++++++++++++++----------- src/data/CCMultiMap.mli | 18 +++++++++++++----- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/data/CCMultiMap.ml b/src/data/CCMultiMap.ml index 2de2d9ff3..c6a2b6c97 100644 --- a/src/data/CCMultiMap.ml +++ b/src/data/CCMultiMap.ml @@ -30,7 +30,7 @@ module type S = sig val find : t -> key -> value list (** List of values for this key *) - val find_iter : t -> key -> (value -> unit) -> unit + val find_iter : t -> key -> value iter (** Iterate on bindings for this key *) val count : t -> key -> int @@ -224,11 +224,19 @@ module type BIDIR = sig val mem_right : t -> right -> bool (** Is the right key present in at least one pair? *) - val find_left : t -> left -> right iter - (** Find all bindings for this given left-key *) + val find_left : t -> left -> right list + (** List of values for this given left-key *) - val find_right : t -> right -> left iter - (** Find all bindings for this given right-key *) + val find_left_iter : t -> left -> right iter + (** Iterate on bindings for this given left-key + @since 3.12 *) + + val find_right : t -> right -> left list + (** List of values for this given right-key *) + + val find_right_iter : t -> right -> left iter + (** Iterate on bindings for this given left-key + @since 3.12 *) val find1_left : t -> left -> right option (** like {!find_left} but returns at most one value *) @@ -281,14 +289,21 @@ module MakeBidir (L : OrderedType) (R : OrderedType) = struct let cardinal_left m = MapL.size m.left let cardinal_right m = MapR.size m.right - let find_left m a = MapL.find_iter m.left a - let find_right m b = MapR.find_iter m.right b - let remove_left m a = _fold_iter (fun m b -> remove m a b) m (find_left m a) - let remove_right m b = _fold_iter (fun m a -> remove m a b) m (find_right m b) + let find_left m a = MapL.find m.left a + let find_left_iter m a = MapL.find_iter m.left a + let find_right m b = MapR.find m.right b + let find_right_iter m b = MapR.find_iter m.right b + + let remove_left m a = + _fold_iter (fun m b -> remove m a b) m (find_left_iter m a) + + let remove_right m b = + _fold_iter (fun m a -> remove m a b) m (find_right_iter m b) + let mem_left m a = MapL.mem m.left a let mem_right m b = MapR.mem m.right b - let find1_left m a = _head_iter (find_left m a) - let find1_right m b = _head_iter (find_right m b) + let find1_left m a = _head_iter (find_left_iter m a) + let find1_right m b = _head_iter (find_right_iter m b) let fold f acc m = MapL.fold m.left acc f let pairs m = MapL.to_iter m.left let add_pairs m seq = _fold_iter (fun m (a, b) -> add m a b) m seq diff --git a/src/data/CCMultiMap.mli b/src/data/CCMultiMap.mli index be1e835a0..570635831 100644 --- a/src/data/CCMultiMap.mli +++ b/src/data/CCMultiMap.mli @@ -30,7 +30,7 @@ module type S = sig val find : t -> key -> value list (** List of values for this key. *) - val find_iter : t -> key -> (value -> unit) -> unit + val find_iter : t -> key -> value iter (** Iterate on bindings for this key. *) val count : t -> key -> int @@ -119,11 +119,19 @@ module type BIDIR = sig val mem_right : t -> right -> bool (** Is the right key present in at least one pair? *) - val find_left : t -> left -> right iter - (** Find all bindings for this given left-key. *) + val find_left : t -> left -> right list + (** List of values for this given left-key. *) - val find_right : t -> right -> left iter - (** Find all bindings for this given right-key. *) + val find_left_iter : t -> left -> right iter + (** Iterate on bindings for this given left-key. + @since 3.12 *) + + val find_right : t -> right -> left list + (** List of values for this given right-key. *) + + val find_right_iter : t -> right -> left iter + (** Iterate on bindings for this given left-key. + @since 3.12 *) val find1_left : t -> left -> right option (** Like {!find_left} but returns at most one value. *) From e0fb678d1e2d84e6ebb257081b88779afb1a8298 Mon Sep 17 00:00:00 2001 From: Master Builder Date: Thu, 3 Aug 2023 15:40:12 +0000 Subject: [PATCH 3/5] fix(CCMultiMap): Correct @since tags --- src/data/CCMultiMap.ml | 4 ++-- src/data/CCMultiMap.mli | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/CCMultiMap.ml b/src/data/CCMultiMap.ml index c6a2b6c97..279b6e4d1 100644 --- a/src/data/CCMultiMap.ml +++ b/src/data/CCMultiMap.ml @@ -229,14 +229,14 @@ module type BIDIR = sig val find_left_iter : t -> left -> right iter (** Iterate on bindings for this given left-key - @since 3.12 *) + @since NEXT_RELEASE *) val find_right : t -> right -> left list (** List of values for this given right-key *) val find_right_iter : t -> right -> left iter (** Iterate on bindings for this given left-key - @since 3.12 *) + @since NEXT_RELEASE *) val find1_left : t -> left -> right option (** like {!find_left} but returns at most one value *) diff --git a/src/data/CCMultiMap.mli b/src/data/CCMultiMap.mli index 570635831..9f5365f14 100644 --- a/src/data/CCMultiMap.mli +++ b/src/data/CCMultiMap.mli @@ -124,14 +124,14 @@ module type BIDIR = sig val find_left_iter : t -> left -> right iter (** Iterate on bindings for this given left-key. - @since 3.12 *) + @since NEXT_RELEASE *) val find_right : t -> right -> left list (** List of values for this given right-key. *) val find_right_iter : t -> right -> left iter (** Iterate on bindings for this given left-key. - @since 3.12 *) + @since NEXT_RELEASE *) val find1_left : t -> left -> right option (** Like {!find_left} but returns at most one value. *) From 85cf52d5eeecdb6292f25e86ba3b7905db9b8bdf Mon Sep 17 00:00:00 2001 From: BridgeTheMasterBuilder <71600489+BridgeTheMasterBuilder@users.noreply.github.com> Date: Thu, 3 Aug 2023 21:39:18 +0000 Subject: [PATCH 4/5] fix(CCMultiMap): Integrate suggested changes to doc comment for find_left Co-authored-by: Simon Cruanes --- src/data/CCMultiMap.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/CCMultiMap.ml b/src/data/CCMultiMap.ml index 279b6e4d1..831dd2d90 100644 --- a/src/data/CCMultiMap.ml +++ b/src/data/CCMultiMap.ml @@ -225,7 +225,8 @@ module type BIDIR = sig (** Is the right key present in at least one pair? *) val find_left : t -> left -> right list - (** List of values for this given left-key *) + (** List of values for this given left-key. + This used to return an iter, but returns a list since NEXT_RELEASE. *) val find_left_iter : t -> left -> right iter (** Iterate on bindings for this given left-key From c97b9345425560b7f5c90e1e98d17e5fb0191679 Mon Sep 17 00:00:00 2001 From: BridgeTheMasterBuilder <71600489+BridgeTheMasterBuilder@users.noreply.github.com> Date: Thu, 3 Aug 2023 21:39:39 +0000 Subject: [PATCH 5/5] fix(CCMultiMap): Integrate suggested changes to doc comment for find_right Co-authored-by: Simon Cruanes --- src/data/CCMultiMap.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/CCMultiMap.ml b/src/data/CCMultiMap.ml index 831dd2d90..7a8407b11 100644 --- a/src/data/CCMultiMap.ml +++ b/src/data/CCMultiMap.ml @@ -233,7 +233,8 @@ module type BIDIR = sig @since NEXT_RELEASE *) val find_right : t -> right -> left list - (** List of values for this given right-key *) + (** List of values for this given right-key. + This used to return an iter, but returns a list since NEXT_RELEASE. *) val find_right_iter : t -> right -> left iter (** Iterate on bindings for this given left-key