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 PAA29176; Thu, 12 Aug 2004 15:38:12 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA29676 for ; Thu, 12 Aug 2004 15:38:11 +0200 (MET DST) Received: from [128.93.8.158] (macaque.inria.fr [128.93.8.158]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7CDcAmL009186 for ; Thu, 12 Aug 2004 15:38:11 +0200 Mime-Version: 1.0 (Apple Message framework v619) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] getting the type of a polymorphic data ? Date: Thu, 12 Aug 2004 15:38:14 +0200 To: caml Caml X-Mailer: Apple Mail (2.619) X-Miltered: at nez-perce with ID 411B72C2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 pons:01 isomorphic:01 2004:99 hashtbl:01 hash:01 hash:01 hashtbl:01 fernandez:01 bool:01 bool:01 caml:01 0000:98 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Aug 12, 2004, at 14:09, Diego Olivier Fernandez Pons wrote: > It seems that Obj.is_int does exactly that (determining if a type is > isomorphic to a subset of integers). No, not exactly: Objective Caml version 3.09+dev0 (2004-07-13) # type x = A | B of int;; type x = A | B of int # Obj.is_int (Obj.repr A);; - : bool = true # Obj.is_int (Obj.repr (B 1));; - : bool = false All Obj.is_int tells you about the _type_ of its argument is that, if it returns true then at least one of the type's values is represented as an integer. > Is it reasonable to admit that if Obj.is_int is true for x and y then > Hashtbl.hash is injective ? > > hash x = hash y => x = y (for structural polymorphic equality) Not quite. # Hashtbl.hash 0x4000_0000;; - : int = 0 # Hashtbl.hash 0;; - : int = 0 -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners