From 2a93d6e31cec12105e4cf12e1efe55a0cd7f17ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Tue, 14 Jul 2020 14:36:32 +0200 Subject: [PATCH 1/6] Base: export string-specialised Hashtbl from TzPervasives --- src/lib_base/tzPervasives.ml | 8 ++ src/lib_base/tzPervasives.mli | 3 + src/lib_lwt_result_stdlib/functors/hashtbl.ml | 41 ++++++++++ .../functors/hashtbl.mli | 14 +++- src/lib_lwt_result_stdlib/lib/hashtbl.mli | 12 +++ src/lib_lwt_result_stdlib/sigs/hashtbl.ml | 80 ++++++++++++++++++- 6 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index 7918f92bce6e..0d6a29706879 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -44,6 +44,14 @@ end module String = struct include String include Tezos_stdlib.TzString + + module Hashtbl = Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.Make (struct + type t = string + + let equal = String.equal + + let hash = Hashtbl.hash + end) end module Time = Time diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index 8c7b02313caa..ce5d2e2c31dc 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -55,6 +55,9 @@ module String : sig include module type of String include module type of Tezos_stdlib.TzString + + module Hashtbl : + Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.S with type key = t end module Time = Time diff --git a/src/lib_lwt_result_stdlib/functors/hashtbl.ml b/src/lib_lwt_result_stdlib/functors/hashtbl.ml index 4b827e24bbf2..356acdebc73d 100644 --- a/src/lib_lwt_result_stdlib/functors/hashtbl.ml +++ b/src/lib_lwt_result_stdlib/functors/hashtbl.ml @@ -26,8 +26,17 @@ module Make (Seq : Sigs.Seq.S) = struct let hash = Stdlib.Hashtbl.hash + let seeded_hash = Stdlib.Hashtbl.seeded_hash + + let hash_param = Stdlib.Hashtbl.hash_param + + let seeded_hash_param = Stdlib.Hashtbl.seeded_hash_param + module type S = Sigs.Hashtbl.S with type error := Seq.Monad.out_error + module type SeededS = + Sigs.Hashtbl.SeededS with type error := Seq.Monad.out_error + module Make (H : Stdlib.Hashtbl.HashedType) : S with type key = H.t = struct open Seq include Stdlib.Hashtbl.Make (H) @@ -59,6 +68,38 @@ module Make (Seq : Sigs.Seq.S) = struct t end + module MakeSeeded (H : Stdlib.Hashtbl.SeededHashedType) : + SeededS with type key = H.t = struct + open Seq + include Stdlib.Hashtbl.MakeSeeded (H) + + let iter_e f t = iter_e (fun (k, v) -> f k v) (to_seq t) + + let iter_s f t = iter_s (fun (k, v) -> f k v) (to_seq t) + + let iter_es f t = iter_es (fun (k, v) -> f k v) (to_seq t) + + let iter_p f t = iter_p (fun (k, v) -> f k v) (to_seq t) + + let iter_ep f t = iter_ep (fun (k, v) -> f k v) (to_seq t) + + let fold_e f t init = + fold_left_e (fun acc (k, v) -> f k v acc) init (to_seq t) + + let fold_s f t init = + fold_left_s (fun acc (k, v) -> f k v acc) init (to_seq t) + + let fold_es f t init = + fold_left_es (fun acc (k, v) -> f k v acc) init (to_seq t) + + let find = find_opt + + let try_map_inplace f t = + filter_map_inplace + (fun k v -> match f k v with Error _ -> None | Ok r -> Some r) + t + end + module type S_LWT = Sigs.Hashtbl.S_LWT with type error := Seq.Monad.out_error module Make_Lwt (H : Stdlib.Hashtbl.HashedType) : S_LWT with type key = H.t = diff --git a/src/lib_lwt_result_stdlib/functors/hashtbl.mli b/src/lib_lwt_result_stdlib/functors/hashtbl.mli index 2e6642684d59..9af9b3efb759 100644 --- a/src/lib_lwt_result_stdlib/functors/hashtbl.mli +++ b/src/lib_lwt_result_stdlib/functors/hashtbl.mli @@ -24,13 +24,25 @@ (*****************************************************************************) module Make (Seq : Sigs.Seq.S) : sig - (** [Stdlib.Hashtbl.hash] reexported to allow shadowing *) + (** Polymorphic hashing re-exported *) val hash : 'a -> int + val seeded_hash : int -> 'a -> int + + val hash_param : int -> int -> 'a -> int + + val seeded_hash_param : int -> int -> int -> 'a -> int + module type S = Sigs.Hashtbl.S with type error := Seq.Monad.out_error + module type SeededS = + Sigs.Hashtbl.SeededS with type error := Seq.Monad.out_error + module Make (H : Stdlib.Hashtbl.HashedType) : S with type key = H.t + module MakeSeeded (H : Stdlib.Hashtbl.SeededHashedType) : + SeededS with type key = H.t + module type S_LWT = Sigs.Hashtbl.S_LWT with type error := Seq.Monad.out_error module Make_Lwt (H : Stdlib.Hashtbl.HashedType) : S_LWT with type key = H.t diff --git a/src/lib_lwt_result_stdlib/lib/hashtbl.mli b/src/lib_lwt_result_stdlib/lib/hashtbl.mli index 42704721ab9d..1fb1fe48d85a 100644 --- a/src/lib_lwt_result_stdlib/lib/hashtbl.mli +++ b/src/lib_lwt_result_stdlib/lib/hashtbl.mli @@ -25,10 +25,22 @@ val hash : 'a -> int +val seeded_hash : int -> 'a -> int + +val hash_param : int -> int -> 'a -> int + +val seeded_hash_param : int -> int -> int -> 'a -> int + module type S = Sigs.Hashtbl.S with type error := Error_monad.error list +module type SeededS = + Sigs.Hashtbl.SeededS with type error := Error_monad.error list + module Make (H : Stdlib.Hashtbl.HashedType) : S with type key = H.t +module MakeSeeded (H : Stdlib.Hashtbl.SeededHashedType) : + SeededS with type key = H.t + module type S_LWT = Sigs.Hashtbl.S_LWT with type error := Error_monad.error list diff --git a/src/lib_lwt_result_stdlib/sigs/hashtbl.ml b/src/lib_lwt_result_stdlib/sigs/hashtbl.ml index e5e725f92822..5463affc28e1 100644 --- a/src/lib_lwt_result_stdlib/sigs/hashtbl.ml +++ b/src/lib_lwt_result_stdlib/sigs/hashtbl.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -(** Modules with the signature [S] are safe (e.g., [find] uses [option] rather +(** Hashtbls with the signature [S] are safe (e.g., [find] uses [option] rather than raising [Not_found]) extensions of [Hashtbl.S] with some Lwt- and Error-aware traversal functions. *) module type S = sig @@ -104,6 +104,84 @@ module type S = sig val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t end +module type SeededS = sig + type error + + type key + + type 'a t + + val create : ?random:bool -> int -> 'a t + + val clear : 'a t -> unit + + val reset : 'a t -> unit + + val add : 'a t -> key -> 'a -> unit + + val remove : 'a t -> key -> unit + + val find : 'a t -> key -> 'a option + + val find_all : 'a t -> key -> 'a list + + val replace : 'a t -> key -> 'a -> unit + + val mem : 'a t -> key -> bool + + val iter : (key -> 'a -> unit) -> 'a t -> unit + + val iter_s : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t + + val iter_p : (key -> 'a -> unit Lwt.t) -> 'a t -> unit Lwt.t + + val iter_e : + (key -> 'a -> (unit, error) result) -> 'a t -> (unit, error) result + + val iter_es : + (key -> 'a -> (unit, error) result Lwt.t) -> + 'a t -> + (unit, error) result Lwt.t + + val iter_ep : + (key -> 'a -> (unit, error) result Lwt.t) -> + 'a t -> + (unit, error) result Lwt.t + + val filter_map_inplace : (key -> 'a -> 'a option) -> 'a t -> unit + + val try_map_inplace : (key -> 'a -> ('a, error) result) -> 'a t -> unit + + val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + + val fold_s : (key -> 'a -> 'b -> 'b Lwt.t) -> 'a t -> 'b -> 'b Lwt.t + + val fold_e : + (key -> 'a -> 'b -> ('b, error) result) -> 'a t -> 'b -> ('b, error) result + + val fold_es : + (key -> 'a -> 'b -> ('b, error) result Lwt.t) -> + 'a t -> + 'b -> + ('b, error) result Lwt.t + + val length : 'a t -> int + + val stats : 'a t -> Stdlib.Hashtbl.statistics + + val to_seq : 'a t -> (key * 'a) Stdlib.Seq.t + + val to_seq_keys : _ t -> key Stdlib.Seq.t + + val to_seq_values : 'a t -> 'a Stdlib.Seq.t + + val add_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit + + val replace_seq : 'a t -> (key * 'a) Stdlib.Seq.t -> unit + + val of_seq : (key * 'a) Stdlib.Seq.t -> 'a t +end + (** Modules with the signature [S_LWT] are Hashtbl-like with the following differences: -- GitLab From 36871bf8239697e230342db43f3b2165f4b4e5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 17 Jul 2020 10:31:00 +0200 Subject: [PATCH 2/6] Everywhere: prefer string-specialised Hashtbl Prefer specialised table to avoid relying on polymorphic equality. --- src/lib_client_base/client_keys.ml | 8 ++++---- src/lib_shell/test/test_state.ml | 14 +++++++------- src/lib_shell/test/test_state_checkpoint.ml | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 85f4276af751..b96d0fa4ba27 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -203,21 +203,21 @@ module type SIGNER = sig val supports_deterministic_nonces : sk_uri -> bool tzresult Lwt.t end -let signers_table : (string, (module SIGNER)) Hashtbl.t = Hashtbl.create 13 +let signers_table : (module SIGNER) String.Hashtbl.t = String.Hashtbl.create 13 let register_signer signer = let module Signer = (val signer : SIGNER) in - Hashtbl.replace signers_table Signer.scheme signer + String.Hashtbl.replace signers_table Signer.scheme signer let find_signer_for_key ~scheme = - match Hashtbl.find_opt signers_table scheme with + match String.Hashtbl.find signers_table scheme with | None -> fail (Unregistered_key_scheme scheme) | Some signer -> return signer let registered_signers () : (string * (module SIGNER)) list = - Hashtbl.fold (fun k v acc -> (k, v) :: acc) signers_table [] + String.Hashtbl.fold (fun k v acc -> (k, v) :: acc) signers_table [] type error += Signature_mismatch of sk_uri diff --git a/src/lib_shell/test/test_state.ml b/src/lib_shell/test/test_state.ml index a167b805f01a..2137dbb154d3 100644 --- a/src/lib_shell/test/test_state.ml +++ b/src/lib_shell/test/test_state.ml @@ -142,7 +142,7 @@ let build_valid_chain state vtbl pred names = >>=? fun _vblock -> State.Block.read state hash >>=? fun vblock -> - Hashtbl.add vtbl name vblock ; + String.Hashtbl.add vtbl name vblock ; return vblock) >>= function | Ok v -> @@ -171,17 +171,17 @@ let build_valid_chain state vtbl pred names = >>= fun _ -> Lwt.return_unit type state = { - vblock : (string, State.Block.t) Hashtbl.t; + vblock : State.Block.t String.Hashtbl.t; state : State.t; chain : State.Chain.t; } -let vblock s = Hashtbl.find s.vblock +let vblock s k = Option.get @@ String.Hashtbl.find s.vblock k exception Found of string let vblocks s = - Hashtbl.fold (fun k v acc -> (k, v) :: acc) s.vblock [] + String.Hashtbl.fold (fun k v acc -> (k, v) :: acc) s.vblock [] |> List.sort Stdlib.compare (*******************************************************) @@ -193,14 +193,14 @@ let vblocks s = *) let build_example_tree chain = - let vtbl = Hashtbl.create 23 in + let vtbl = String.Hashtbl.create 23 in Chain.genesis chain >>= fun genesis -> - Hashtbl.add vtbl "Genesis" genesis ; + String.Hashtbl.add vtbl "Genesis" genesis ; let c = ["A1"; "A2"; "A3"; "A4"; "A5"; "A6"; "A7"; "A8"] in build_valid_chain chain vtbl genesis c >>= fun () -> - let a3 = Hashtbl.find vtbl "A3" in + let a3 = Option.get @@ String.Hashtbl.find vtbl "A3" in let c = ["B1"; "B2"; "B3"; "B4"; "B5"; "B6"; "B7"; "B8"] in build_valid_chain chain vtbl a3 c >>= fun () -> Lwt.return vtbl diff --git a/src/lib_shell/test/test_state_checkpoint.ml b/src/lib_shell/test/test_state_checkpoint.ml index 1f546c7dffa0..5076ae249a4d 100644 --- a/src/lib_shell/test/test_state_checkpoint.ml +++ b/src/lib_shell/test/test_state_checkpoint.ml @@ -166,7 +166,7 @@ let build_valid_chain state vtbl pred names = >>=? fun _vblock -> State.Block.read state hash >>=? fun vblock -> - Hashtbl.add vtbl name vblock ; + String.Hashtbl.add vtbl name vblock ; return vblock) >>= function | Ok v -> @@ -195,17 +195,17 @@ let build_valid_chain state vtbl pred names = >>= fun _ -> Lwt.return_unit type state = { - vblock : (string, State.Block.t) Hashtbl.t; + vblock : State.Block.t String.Hashtbl.t; state : State.t; chain : State.Chain.t; } -let vblock s = Hashtbl.find s.vblock +let vblock s k = Option.get @@ String.Hashtbl.find s.vblock k exception Found of string let vblocks s = - Hashtbl.fold (fun k v acc -> (k, v) :: acc) s.vblock [] + String.Hashtbl.fold (fun k v acc -> (k, v) :: acc) s.vblock [] |> List.sort Stdlib.compare (*******************************************************) @@ -217,14 +217,14 @@ let vblocks s = *) let build_example_tree chain = - let vtbl = Hashtbl.create 23 in + let vtbl = String.Hashtbl.create 23 in Chain.genesis chain >>= fun genesis -> - Hashtbl.add vtbl "Genesis" genesis ; + String.Hashtbl.add vtbl "Genesis" genesis ; let c = ["A1"; "A2"; "A3"; "A4"; "A5"] in build_valid_chain chain vtbl genesis c >>= fun () -> - let a2 = Hashtbl.find vtbl "A2" in + let a2 = Option.get @@ String.Hashtbl.find vtbl "A2" in let c = ["B1"; "B2"; "B3"; "B4"; "B5"] in build_valid_chain chain vtbl a2 c >>= fun () -> Lwt.return vtbl -- GitLab From 8eadef866422405555e834afffd64ff6e8cc69d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 17 Jul 2020 11:06:50 +0200 Subject: [PATCH 3/6] Signer_backend: specialise pk_uri hashtbl --- src/lib_client_base/client_keys.ml | 8 ++++++++ src/lib_client_base/client_keys.mli | 2 ++ src/lib_signer_backends/unix/with_ledger.ml | 11 ++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index b96d0fa4ba27..29b86287d71c 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -81,6 +81,14 @@ let uri_encoding = type pk_uri = Uri.t +module Pk_uri_hashtbl = Hashtbl.Make (struct + type t = pk_uri + + let equal = Uri.equal + + let hash = Hashtbl.hash +end) + let make_pk_uri (x : Uri.t) : pk_uri tzresult Lwt.t = match Uri.scheme x with | None -> diff --git a/src/lib_client_base/client_keys.mli b/src/lib_client_base/client_keys.mli index 25d92513e6b3..4c951473150d 100644 --- a/src/lib_client_base/client_keys.mli +++ b/src/lib_client_base/client_keys.mli @@ -27,6 +27,8 @@ type pk_uri = private Uri.t +module Pk_uri_hashtbl : Hashtbl.S with type key = pk_uri + type sk_uri = private Uri.t val pk_uri_parameter : unit -> (pk_uri, 'a) Clic.parameter diff --git a/src/lib_signer_backends/unix/with_ledger.ml b/src/lib_signer_backends/unix/with_ledger.ml index 1e1344ebcf1e..143b28374262 100644 --- a/src/lib_signer_backends/unix/with_ledger.ml +++ b/src/lib_signer_backends/unix/with_ledger.ml @@ -676,13 +676,14 @@ module Global_cache : sig val get : pk_uri -> (Signature.public_key_hash * Signature.public_key) option end = struct let _cache : - (pk_uri, Signature.Public_key_hash.t * Signature.Public_key.t) Hashtbl.t - = - Hashtbl.create 13 + (Signature.Public_key_hash.t * Signature.Public_key.t) + Client_keys.Pk_uri_hashtbl.t = + Client_keys.Pk_uri_hashtbl.create 13 - let record pk_uri ~pk ~pkh = Hashtbl.replace _cache pk_uri (pkh, pk) + let record pk_uri ~pk ~pkh = + Client_keys.Pk_uri_hashtbl.replace _cache pk_uri (pkh, pk) - let get pk_uri = Hashtbl.find_opt _cache pk_uri + let get pk_uri = Client_keys.Pk_uri_hashtbl.find_opt _cache pk_uri end (** The implementation of the “signer-plugin.” *) -- GitLab From be0067b12038a1cc645214254573aa3998f59fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 17 Jul 2020 11:07:55 +0200 Subject: [PATCH 4/6] Protocol_compiler: specialise hashtbl --- src/lib_protocol_compiler/compiler.ml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib_protocol_compiler/compiler.ml b/src/lib_protocol_compiler/compiler.ml index 2ea522d379a4..b97bc825579f 100644 --- a/src/lib_protocol_compiler/compiler.ml +++ b/src/lib_protocol_compiler/compiler.ml @@ -33,20 +33,17 @@ let () = Clflags.unsafe_string := false with a lookup in locally defined hashtable. *) -let preloaded_cmis : (string, Persistent_env.Persistent_signature.t) Hashtbl.t - = - Hashtbl.create ~random:true 42 +let preloaded_cmis : Persistent_env.Persistent_signature.t String.Hashtbl.t = + String.Hashtbl.create ~random:true 42 (* Set hook *) let () = Persistent_env.Persistent_signature.load := fun ~unit_name -> - try - Some (Hashtbl.find preloaded_cmis (String.capitalize_ascii unit_name)) - with Not_found -> None + String.Hashtbl.find preloaded_cmis (String.capitalize_ascii unit_name) let load_cmi_from_file file = - Hashtbl.add + String.Hashtbl.add preloaded_cmis (String.capitalize_ascii Filename.(basename (chop_extension file))) {filename = file; cmi = Cmi_format.read_cmi file} @@ -67,7 +64,7 @@ let load_embedded_cmi (unit_name, content) = (* Read cmi_flags *) let cmi_flags = Marshal.from_bytes content pos in (* TODO check crcrs... *) - Hashtbl.add + String.Hashtbl.add preloaded_cmis (String.capitalize_ascii unit_name) { -- GitLab From dc8023b9016fb5031f143bc37c2e7f93af901f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 17 Jul 2020 16:05:43 +0200 Subject: [PATCH 5/6] Base: TzPervasives.String.Table is now a SeededS --- src/lib_base/tzPervasives.ml | 4 ++-- src/lib_base/tzPervasives.mli | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index 0d6a29706879..6cf5b252857c 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -45,12 +45,12 @@ module String = struct include String include Tezos_stdlib.TzString - module Hashtbl = Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.Make (struct + module Hashtbl = Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.MakeSeeded (struct type t = string let equal = String.equal - let hash = Hashtbl.hash + let hash = Hashtbl.seeded_hash end) end diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index ce5d2e2c31dc..e090a42e24a4 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -57,7 +57,7 @@ module String : sig include module type of Tezos_stdlib.TzString module Hashtbl : - Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.S with type key = t + Tezos_lwt_result_stdlib.Lwtreslib.Hashtbl.SeededS with type key = t end module Time = Time -- GitLab From fc2d5c5003398e65506d30cd39365e731205f82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 3 Aug 2020 10:50:03 +0200 Subject: [PATCH 6/6] Lwtreslib: document polymorphic hash functions --- src/lib_lwt_result_stdlib/functors/hashtbl.ml | 6 ++++-- src/lib_lwt_result_stdlib/functors/hashtbl.mli | 8 +++++--- src/lib_lwt_result_stdlib/lib/hashtbl.mli | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib_lwt_result_stdlib/functors/hashtbl.ml b/src/lib_lwt_result_stdlib/functors/hashtbl.ml index 356acdebc73d..bcddc5a5621f 100644 --- a/src/lib_lwt_result_stdlib/functors/hashtbl.ml +++ b/src/lib_lwt_result_stdlib/functors/hashtbl.ml @@ -28,9 +28,11 @@ module Make (Seq : Sigs.Seq.S) = struct let seeded_hash = Stdlib.Hashtbl.seeded_hash - let hash_param = Stdlib.Hashtbl.hash_param + let hash_param ~meaningful ~total v = + Stdlib.Hashtbl.hash_param meaningful total v - let seeded_hash_param = Stdlib.Hashtbl.seeded_hash_param + let seeded_hash_param ~meaningful ~total seed v = + Stdlib.Hashtbl.seeded_hash_param meaningful total seed v module type S = Sigs.Hashtbl.S with type error := Seq.Monad.out_error diff --git a/src/lib_lwt_result_stdlib/functors/hashtbl.mli b/src/lib_lwt_result_stdlib/functors/hashtbl.mli index 9af9b3efb759..043f019007e1 100644 --- a/src/lib_lwt_result_stdlib/functors/hashtbl.mli +++ b/src/lib_lwt_result_stdlib/functors/hashtbl.mli @@ -24,14 +24,16 @@ (*****************************************************************************) module Make (Seq : Sigs.Seq.S) : sig - (** Polymorphic hashing re-exported *) + (** Polymorphic hashing re-exported. These functions are meant to be passed to + the [Make] and [MakeSeeded] functors (below). Check {!Stdlib.Hashtbl} for + documentation. *) val hash : 'a -> int val seeded_hash : int -> 'a -> int - val hash_param : int -> int -> 'a -> int + val hash_param : meaningful:int -> total:int -> 'a -> int - val seeded_hash_param : int -> int -> int -> 'a -> int + val seeded_hash_param : meaningful:int -> total:int -> int -> 'a -> int module type S = Sigs.Hashtbl.S with type error := Seq.Monad.out_error diff --git a/src/lib_lwt_result_stdlib/lib/hashtbl.mli b/src/lib_lwt_result_stdlib/lib/hashtbl.mli index 1fb1fe48d85a..4cf52134175a 100644 --- a/src/lib_lwt_result_stdlib/lib/hashtbl.mli +++ b/src/lib_lwt_result_stdlib/lib/hashtbl.mli @@ -27,9 +27,9 @@ val hash : 'a -> int val seeded_hash : int -> 'a -> int -val hash_param : int -> int -> 'a -> int +val hash_param : meaningful:int -> total:int -> 'a -> int -val seeded_hash_param : int -> int -> int -> 'a -> int +val seeded_hash_param : meaningful:int -> total:int -> int -> 'a -> int module type S = Sigs.Hashtbl.S with type error := Error_monad.error list -- GitLab