Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Jean-Baptiste Robertson <jbrobertson@free.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] question: "('a, 'b) Hashtbl.t" and type constraint
Date: Mon, 26 Mar 2001 12:33:37 +0200 (MEST)	[thread overview]
Message-ID: <15039.6913.551837.700671@pc803> (raw)
In-Reply-To: <3ABCEB84.9D309E90@free.fr>


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


      reply	other threads:[~2001-03-26 10:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-24 18:46 Jean-Baptiste Robertson
2001-03-26 10:33 ` Jean-Christophe Filliatre [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=15039.6913.551837.700671@pc803 \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=jbrobertson@free.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