From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B35EABB81 for ; Sat, 20 Nov 2004 08:45:46 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAK7jkJp018318 for ; Sat, 20 Nov 2004 08:45:46 +0100 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 IAA01071 for ; Sat, 20 Nov 2004 08:45:46 +0100 (MET) Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAK7jj5k018932 for ; Sat, 20 Nov 2004 08:45:45 +0100 Received: from [192.168.0.3] (rkeller-6-82-229-183-156.fbx.proxad.net [82.229.183.156]) by postfix3-2.free.fr (Postfix) with ESMTP id 8158AC04B; Sat, 20 Nov 2004 08:45:45 +0100 (CET) Message-ID: <419EF624.30201@inria.fr> Date: Sat, 20 Nov 2004 08:45:40 +0100 From: Alain Frisch User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "John F. Hughes" Cc: caml-list@inria.fr Subject: Re: [Caml-list] A second functor question References: <20041120041446.JDEC13256.lakermmtao10.cox.net@SPIKESHOMEPC> In-Reply-To: <20041120041446.JDEC13256.lakermmtao10.cox.net@SPIKESHOMEPC> X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 419EF62A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 419EF629.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; frisch:01 frisch:01 caml-list:01 functor:01 wrote:01 sig:01 struct:01 struct:01 annotation:01 foo:01 functor:01 foo:01 ...:98 ...:98 structures: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: John F. Hughes wrote: > 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. module type COMBINE = sig module A : P module B : P with type t = A.t end;; You need to keep the P1.t and P2.t fields public, otherwise the constraint cannot be checked: module P1 = struct ... end;; module P2 = struct ... end;; or: module P1 : P with type t = int = ... module P2 : P with type t = int = ... Btw, maybe you did it on purpose, but the type annotation in: let f x:Z.A.t = Z.B.foo x is upon the result type of f, not its argument (in your case, it's the same). Note also you don't need to combine the two structures in a single module, you can just define a functor with several arguments: module Fun(A : P)(B : P with type t = A.t) = struct let f x = B.foo x end -- Alain