From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 956F2BBAF for ; Fri, 21 May 2010 21:52:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtsDAAKB9ktKfVK2mGdsb2JhbACBP5txWggVAQEBAQEICQwHESKtcIIChSQuiE8BAQMFhQ0E X-IronPort-AV: E=Sophos;i="4.53,279,1272837600"; d="scan'208";a="63250377" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 May 2010 21:52:23 +0200 Received: by wye20 with SMTP id 20so1036455wye.27 for ; Fri, 21 May 2010 12:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=sgO93+FCpDxP0Rrz0lxKnjcSVMDxPYxuVBetfTaBoYc=; b=s8/YME9p3xcMDuwsjKze/xCHU9TN/2UxkJ+/Ewo7sMHXzQV/ShfWPRzZe10aZUFRf6 NDolG/4Pf4odObfgem64jPyuTtmxSk577SuIULkycVsba8Oj47w3IO1Nb6uYl7QMBn3I aCbcaV20pkFoYTudAkCzKJuoKw884pG/gFTKg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=w4prsg2bS+xz2/HfwCVsWUOLeQAB0rLGRKvFnU2tnT8xYZl6GaoEEqMC7Y9Qa+dR3z wC1xFBZHEHWFtTF67qCZnK8uEy2jpQqFeZEac2ftjnPxu5o7mORklIb28gSjRkBJvHny 1cIdZlcbxZYSBujUasW7/9mMRBeFtqlcKriy0= MIME-Version: 1.0 Received: by 10.216.87.4 with SMTP id x4mr1182560wee.86.1274471542111; Fri, 21 May 2010 12:52:22 -0700 (PDT) Received: by 10.216.181.65 with HTTP; Fri, 21 May 2010 12:52:21 -0700 (PDT) In-Reply-To: <87eih5rv0x.fsf@frosties.localdomain> References: <87eih5rv0x.fsf@frosties.localdomain> Date: Fri, 21 May 2010 21:52:21 +0200 Message-ID: Subject: Re: [Caml-list] Private modules in packages From: Julien Signoles To: Goswin von Brederlow Cc: Ashish Agarwal , Michael.Grunewald@laposte.net, caml-list@inria.fr Content-Type: multipart/alternative; boundary=0016e6d977228b40d20487200796 X-Spam: no; 0.00; signoles:01 signoles:01 mli:01 mli:01 foo:01 foo:01 ocaml:01 baz:01 sig:01 baz:01 ocaml:01 sig:01 1975:98 1975:98 z-index:98 --0016e6d977228b40d20487200796 Content-Type: text/plain; charset=ISO-8859-1 2010/5/21 Goswin von Brederlow > Julien Signoles writes: > > > Hello, > > > > 2010/5/21 Ashish Agarwal > > > > > write a script to generate the P.mli file > > > > Why do you need Bar.mli and Foo.mli at all? Just write the P.mli > only. > > > > > > If your pack is big, you may want to mask internals of Bar and Foo to > others > > modules of the pack. Actually, values exported in Bar/Foo but not in P > exactly > > are the module counterparts of "friend methods" in OO languages. > > But then, if you have methods in Bar and Foo visible inside the pack but > not from outside, you can't just cat Bar.mli and Foo.mli into > P.mli. You need to process it to remove the 'friends' functions. > You can do something like that (pure ocaml without any external script): === file baz.mli (outside the pack P) === module type Foo = sig ... (* my public values here *) end === file p.mli === module Foo: Baz.Foo === file foo.mli === include Baz.Foo ... (* my friend values *) === file foo.ml === ... (* all my internals: defining my public+friends+private values *) Hope this helps, Julien --0016e6d977228b40d20487200796 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2010/5/21 Goswin von Brederlow <goswin-v-b@web.de>=
Julien Signoles <julien.signoles@gmail.com> writes:

> Hello,
>
> 2010/5/21 Ashish Agarwal <= agarwal1975@gmail.com>
>
> =A0 =A0 > write a script to generate the P.mli file
>
> =A0 =A0 Why do you need Bar.mli and Foo.mli at all? Just write the P.m= li only.
>
>
> If your pack is big, you may want to mask internals of Bar and Foo to = others
> modules of the pack. Actually, values exported in Bar/Foo but not in P= exactly
> are the module counterparts of "friend methods" in OO langua= ges.

But then, if you have methods in Bar and Foo visible inside the= pack but
not from outside, you can't just cat Bar.mli and Foo.mli into
P.mli. You need to process it to remove the 'friends' functions.

You can do something like that (pure ocaml without a= ny external script):

=3D=3D=3D file baz.mli (outside the pack P) =3D= =3D=3D
module type Foo =3D sig ... (* my public values here *) end

=3D=3D= =3D file p.mli =3D=3D=3D
module Foo: Baz.Foo

=3D=3D=3D file foo.m= li =3D=3D=3D
include Baz.Foo
... (* my friend values *)

=3D=3D= =3D file foo.ml =3D=3D=3D
... (* all my internals: defining my public+friends+private values *)
Hope this helps,
Julien

--0016e6d977228b40d20487200796--