From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 8284DBC69 for ; Fri, 24 Aug 2007 06:31:09 +0200 (CEST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.188]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7O4V8j0003359 for ; Fri, 24 Aug 2007 06:31:08 +0200 Received: by fk-out-0910.google.com with SMTP id z22so688239fkz for ; Thu, 23 Aug 2007 21:31:08 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:cc:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=s1O0ULZXIBBscZBVZuoCmCrCbGlVy+q3Dg5cZ9tF5R/tDEVMhUX+DOCYPeWBbSX/7i7+7PYJa18K7BVVqZ0C1JD5/o7i5xdI4NKuxlZ/kaOzcJkOSkMgj/QK716FRfl3TzYAXa+e849uQgnQzDMJr1A/fUv1zTUaNihm9dxMaDk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:cc:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=dQwvqWrUedSEtmV4ocssMyLOVwP30aKlKFpA6g01fUWfiweUuLmPosLwK59Ec/Ydej+Mb00HYQN3mk3Su3HmMPzqsvzwEvFpVIqi1YEj7Fmns10Jak5V5rN4h995vLhS3iaFNg4vOPSbVy8H+mpSVGzzrvcIX6H1IEgpRAUM9RA= Received: by 10.82.162.14 with SMTP id k14mr5764104bue.1187929868098; Thu, 23 Aug 2007 21:31:08 -0700 (PDT) Received: from localhost ( [82.122.238.197]) by mx.google.com with ESMTPS id 7sm2533669nfv.2007.08.23.21.31.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Aug 2007 21:31:05 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Fri, 24 Aug 2007 06:31:03 +0200 Date: Fri, 24 Aug 2007 06:31:03 +0200 To: Brian Hurt Cc: caml-list@inria.fr Subject: Re: [Caml-list] Stupid question re:modules Message-ID: <20070824043102.GA3299@jiyu.gnu> Mail-Followup-To: Julien Moutinho , Brian Hurt , caml-list@inria.fr References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-11) From: Julien Moutinho X-j-chkmail-Score: MSGID : 46CE5F0C.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46CE5F0C.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; foo:01 sig:01 val:01 foo:01 sig:01 val:01 baz:01 baz:01 functor:01 functor:01 struct:01 mli:01 23,:98 wrote:01 signatures:01 On Thu, Aug 23, 2007 at 08:32:22PM -0400, Brian Hurt wrote: > > I should just know this. So let's say I have two module types defined: > > module type Foo = sig > type 'a t > val foo : 'a -> 'a t > end;; > > module type Bar = sig > type 'a t > val bar : 'a -> 'a t > end;; > > Now, I want to define a module that is both a Foo and a Bar without cutting > and pasting the module definitions around. I've been trying to do: > > module Baz : sig > type 'a baz > include Foo with type 'a t = 'a baz > include Bar with type 'a t = 'a baz > end;; > > but this blows up on the Bar line (multiple definitions of 'a t). > > There is a solution to this, I'm just being stupid and forgetting what it > is. Hints would be appreciated. > > Brian I might haven't got exactly what you want, but, with control over Foo and Bar, and starting from the structure, I would have written : module type Foo = functor (T: T) -> sig val foo : 'a -> 'a T.t end module type Bar = functor (T: T) -> sig val bar : 'a -> 'a T.t end module Baz = functor (T: T) -> functor (Foo: Foo) -> functor (Bar: Bar) -> struct include T type 'a baz = 'a t module Foo = Foo(T) module Bar = Bar(T) include Foo include Bar end Then I would have generated the signature automatically with -i. But if you really want a short .mli without redundancy, I see no solution, even for the above functorized code. Because : 1/ unable to override or delete elements from a signature 2/ unable to get the signature of a structure from a functor in a signature. I mean, given this : module type T = sig end module type F = functor (T: T) -> sig end This signature does not work : module B : functor (T: T) -> functor (F: F) -> sig module M : F(T) end nor this : module B : functor (T: T) -> functor (M: F(T)) -> sig end nor this : module B : functor (T: T) -> functor (F: F) -> sig include F(T) end nor this : module B : functor (T: T) -> functor (F: F) -> sig open F(T) end Despite the fact that the structured version of the first two signatures work. And that I do not understand why they all do not work, since it's a kind of substitution, isn't it? Anyway, hope you'll find a way to _avoid_ your problem.