Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Polymorphic hash tables
@ 2015-02-09 14:21 Sébastien Hinderer
  2015-04-14 12:12 ` Goswin von Brederlow
  0 siblings, 1 reply; 2+ messages in thread
From: Sébastien Hinderer @ 2015-02-09 14:21 UTC (permalink / raw)
  To: caml-list

Hi,

Is there a way to just replace OCaml's standard hash function for some
tables?

Here is an example:

module MyHashedType : Hashtbl.HashedType = struct
  type t
  let my_n = 20
  let my_m = 30
  let equal = (=)
  let hash = Hashtbl.hash_param my_n my_m
end

module MyHashtbl = Hashtbl.Make(MyHashedType)

let (mytbl : int MyHashtbl.t) = MyHashtbl.create 100

With this example polymorphism seems to be lost and the compiler does
not accept something like
type t = 'a
to retrieve a generic type as for the standard hash tables.

Any suggestion?

Thanks a lot.
Sébastien.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-14 12:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09 14:21 [Caml-list] Polymorphic hash tables Sébastien Hinderer
2015-04-14 12:12 ` Goswin von Brederlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox