diff --git a/src/lib_stdlib/tag.ml b/src/lib_stdlib/tag.ml index c2a11195c..0b59af6b5 100644 --- a/src/lib_stdlib/tag.ml +++ b/src/lib_stdlib/tag.ml @@ -130,9 +130,12 @@ let max_binding_opt s = option_map snd @@ TagSet.max_binding_opt s let choose s = snd @@ TagSet.choose s let choose_opt s = option_map snd @@ TagSet.choose_opt s let split tag s = (fun (l,m,r) -> (l,unveil tag m,r)) @@ TagSet.split (Key.V tag) s -(* XXX find should be different from find_opt but Logs has find_opt called find *) +(* In order to match the usual interface for maps, `find` should be different from + `find_opt` but `Logs` has `find_opt` called `find` so we favor that. *) let find tag s = option_bind (reveal tag) @@ TagSet.find_opt (Key.V tag) s let find_opt tag s = option_bind (reveal tag) @@ TagSet.find_opt (Key.V tag) s +(* This would usually be called `find` but `Logs` has it with this name. We can't + have it at both named because `Logs` has `find_opt` as `find`. *) let get tag s = find_opt tag s |> function | None -> invalid_arg (Format.asprintf "tag named %s not found in set" (name tag)) | Some v -> v diff --git a/src/lib_stdlib/tag.mli b/src/lib_stdlib/tag.mli index 114f09d43..415b6ef94 100644 --- a/src/lib_stdlib/tag.mli +++ b/src/lib_stdlib/tag.mli @@ -77,6 +77,7 @@ val max_binding_opt : set -> t option val choose : set -> t val choose_opt : set -> t option val split : 'a def -> set -> set * 'a option * set +val find_opt : 'a def -> set -> 'a option val find : 'a def -> set -> 'a option val get : 'a def -> set -> 'a val find_first : (Key.t -> bool) -> set -> t