Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic hash tables
Date: Tue, 14 Apr 2015 14:12:45 +0200	[thread overview]
Message-ID: <20150414121245.GA16590@frosties> (raw)
In-Reply-To: <20150209142107.GA24464@pl-59055.rocqadm.inria.fr>

On Mon, Feb 09, 2015 at 03:21:07PM +0100, Sébastien Hinderer wrote:
> 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.

You have to use a functor there.

MfG
	Goswin

      reply	other threads:[~2015-04-14 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-09 14:21 Sébastien Hinderer
2015-04-14 12:12 ` Goswin von Brederlow [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150414121245.GA16590@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox