From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id TAA20582 for caml-redistribution; Wed, 3 Apr 1996 19:29:17 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id LAA07859 for ; Wed, 3 Apr 1996 11:59:05 +0200 Received: from animal.cs.chalmers.se (root@animal.cs.chalmers.se [129.16.225.30]) by concorde.inria.fr (8.7.1/8.7.1) with ESMTP id LAA04426 for ; Wed, 3 Apr 1996 11:58:33 +0200 (MET DST) Received: from lips.cs.chalmers.se (raffalli@lips-be0.cs.chalmers.se [129.16.233.25]) by animal.cs.chalmers.se (8.7.5/8.7.3) with ESMTP id LAA02609 for ; Wed, 3 Apr 1996 11:58:54 +0200 (MET DST) Received: (from raffalli@localhost) by lips.cs.chalmers.se (8.7.1/8.7.1) id LAA25846; Wed, 3 Apr 1996 11:59:24 +0200 (MET DST) Date: Wed, 3 Apr 1996 11:59:24 +0200 (MET DST) Message-Id: <199604030959.LAA25846@lips.cs.chalmers.se> From: Christophe Raffalli To: caml-list@pauillac.inria.fr Subject: Relation between functors and polymorphism MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis Hi, I have a question that arise in the following circonstances: I modified the Hashtbl library to make it a function taking a "key structure" containing a type "key" a function "hash : key -> int" and a function "eq : key -> key -> bool". Then I wondered how I could use the polymorphic hash and equality functions to recover the original polymorphic Hashtbl structure. You can generalize the question to: What is the relation between a functor that only depends on one type (or more) like module A (B : sig type t end) = struct type u = Some of B.t | None let read = function Some x -> x | None -> raise Not_found end and a polymorphic structure like module A' = struct type 'a u = Some of 'a | None let read = function Some x -> x | None -> raise Not_found end They look isomorphic ? --- You can easely go from A' to A (This is quite verbose but you don't have to rewrite the types or functions definitions): module A (B : sig type t end) = struct type u = B.t A'.u let read = (A'.read : u -> B.t) end But how can you reconstruct A' from A without rewriting the type or function definitions. Is this impossible ? ---- Christophe Raffalli Dept. of Computer Sciences Chalmers University of Technology URL: http://www.logique.jussieu.fr/www.raffalli