From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA19120; Mon, 26 Mar 2001 12:33:38 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA19116 for ; Mon, 26 Mar 2001 12:33:37 +0200 (MET DST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f2QAXaP04697 for ; Mon, 26 Mar 2001 12:33:36 +0200 (MET DST) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.11.1/jtpda-5.3.2) with ESMTP id f2QAXau07816 ; Mon, 26 Mar 2001 12:33:36 +0200 (MET DST) Received: by pc803.lri.fr (8.9.3/feuille) id MAA24500 ; Mon, 26 Mar 2001 12:33:37 +0200 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15039.6913.551837.700671@pc803> Date: Mon, 26 Mar 2001 12:33:37 +0200 (MEST) To: Jean-Baptiste Robertson Cc: caml-list@inria.fr Subject: Re: [Caml-list] question: "('a, 'b) Hashtbl.t" and type constraint In-Reply-To: <3ABCEB84.9D309E90@free.fr> References: <3ABCEB84.9D309E90@free.fr> X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, The type error comes from the fact that you build in line 13 a list containing the two hash tables, which have different types. Consequently you got a type mismatch. Since I do not know what you want to do with that list, I cannot help you furthermore, but you could (for instance) replace that two elements list but the tuple (string_hash, regexp_hash). Hope this helps, -- Jean-Christophe FILLIATRE mailto:Jean-Christophe.Filliatre@lri.fr http://www.lri.fr/~filliatr Jean-Baptiste Robertson writes: > Hello, > > OCaml 2.99 complains about the type of the following expression. After > browsing the manual, the FAQ and the like, and after trying every type > forcing I could think of, I am still unable to persuade it to accept the > following piece of code: > > 1 open Str;; > 2 > 3 let string_hash = Hashtbl.create 7 and > 4 regexp_hash = Hashtbl.create 7 and > 5 kind = "a" and > 6 avalue = "b" in > 7 begin > 8 if kind = "whatever" then > 9 Hashtbl.add string_hash "something" avalue > 10 else > 11 Hashtbl.add regexp_hash "something" (regexp avalue) > 12 end; > 13 [ string_hash ; regexp_hash ] ;; > > (see below for a cut-and-paste friendly version). > > I expected the compiler to bind `string_hash' and `regexp_hash' to > values of the `(string,string) Hashtbl' and `(string,Str.regexp) > Hashtbl' > types, resp., thanks to the 9th and 11th line. All I got is > > File "ex.ml", line 13, characters 16-27: > This expression has type (string, Str.regexp) Hashtbl.t > but is here used with type (string, string) Hashtbl.t > > Replacing the 4th line by > let regexp_hash = (Hashtbl.create 7 : (string, Str.regexp) Hashtbl.t );; > doesn't help. > > I may be missing the obvious. No idea. > > Any help is appreciated. > TIA > > jb > > > _____________________________ > open Str;; > > let string_hash = Hashtbl.create 7 and > regexp_hash = Hashtbl.create 7 and > kind = "a" and > avalue = "b" in > begin > if kind = "whatever" then > Hashtbl.add string_hash "something" avalue > else > Hashtbl.add regexp_hash "something" (regexp avalue) > end; > [ string_hash ; regexp_hash ] ;; > ------------------- > To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr