From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 9DB50BB81 for ; Sat, 20 Nov 2004 05:14:48 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAK4EmAC032638 for ; Sat, 20 Nov 2004 05:14:48 +0100 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 FAA26236 for ; Sat, 20 Nov 2004 05:14:47 +0100 (MET) Received: from lakermmtao10.cox.net (lakermmtao10.cox.net [68.230.240.29]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAK4EkoW028828 for ; Sat, 20 Nov 2004 05:14:47 +0100 Received: from SPIKESHOMEPC ([68.228.151.51]) by lakermmtao10.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20041120041446.JDEC13256.lakermmtao10.cox.net@SPIKESHOMEPC> for ; Fri, 19 Nov 2004 23:14:46 -0500 From: "John F. Hughes" To: Subject: A second functor question Date: Fri, 19 Nov 2004 23:14:49 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcTOt3opjgjt01FGTiKnIYTICcpj9g== Message-Id: <20041120041446.JDEC13256.lakermmtao10.cox.net@SPIKESHOMEPC> X-Miltered: at nez-perce with ID 419EC4B8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 419EC4B6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; functor:01 sig:01 val:01 foo:01 val:01 struct:01 foo:01 struct:01 functor:01 sig:01 ...:98 ...:98 modules:01 modules:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: I'd like to write a signature like this: module type P = sig type t val foo : t -> t val z:int end;; And make two modules matching that signature: module P1 : P = struct type t = int let foo x:t = x let z = 1 end;; module P2 : P = struct type t = int let foo x:t = x let z = 2 end;; I now want to apply a functor to those two modules...but a functor wants a single module, so I make a signature for a "joined" type: module type COMBINE = sig module A : P module B : P end;; with A.t = B.t;; and create a module of that type: module C : COMBINE = struct module A = P1 module B = P2 end;; And now I can write a functor: module Fun = functor (Z : COMBINE) -> struct let f x:Z.A.t = Z.B.foo x end;; This will fail because Z.B.foo expects a B.t, but is being handed an A.t. I'd like it to work. In other words, I'd like a way to promise to the type system that A.t and B.t (within a COMBINE) are always the same. I tried module type COMBINE = sig module A : P module B : P end with A.t = B.t I tried telling it they were the same when I created the module C: module C : COMBINE = struct module A = P1 module B = P2 end with A.t = B.t;; Neither worked. Can someone suggest a way to make this work, or am I asking too much of the module system. (I used to be able to do this in ML, using the "sharing type" construct, but...) ---John