diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-04-19 10:15:28 +0000 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-04-19 10:15:28 +0000 |
commit | 1ba4d3486b7acab3f9f9f81e3ca4edafb6a4631b (patch) | |
tree | 8c77531a138907e8f45d72956574a87fdf0d7865 /stdlib | |
parent | 56f1f8a89dcfe68ca7cfde06580ee9dcf1056d85 (diff) |
[minor] improvement over the Hashtbl doc
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14646 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/hashtbl.mli | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/stdlib/hashtbl.mli b/stdlib/hashtbl.mli index 5b05cfffa..3ac5316b6 100644 --- a/stdlib/hashtbl.mli +++ b/stdlib/hashtbl.mli @@ -187,7 +187,7 @@ val stats : ('a, 'b) t -> statistics (** {6 Functorial interface} *) -(** The functorial interface allows to use specific comparison +(** The functorial interface allows the use of specific comparison and hash functions, either for performance/security concerns, or because keys are not hashable/comparable with the polymorphic builtins. @@ -203,11 +203,18 @@ val stats : ('a, 'b) t -> statistics module IntHashtbl = Hashtbl.Make(IntHash) let h = IntHashtbl.create 17 in - IntHashtbl.add h 12 "hello";; (* works *) + IntHashtbl.add h 12 "hello";; + ]} - let h' = IntHashtbl.create 17 in - IntHashtbl.add h false "world";; (* won't typecheck *) - ]} *) + This creates a new module [IntHashtbl], with a new type ['a + IntHashtbl.t] of tables from [int] to ['a]. In this example, [h] + contains [string] values so its type is [string IntHashtbl.t]. + + Note that the new type ['a IntHashtbl.t] is not compatible with + the type [('a,'b) Hashtbl.t] of the generic interface. For + example, [Hashtbl.length h] would not type-check, you must use + [IntHahstbl.length]. +*) module type HashedType = sig |