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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id C1551BBAF for ; Fri, 21 May 2010 10:54:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlACAH/n9UtKfVK2mGdsb2JhbACeGAgVAQEBAQEICQwHESKsaIIBhSAuiE4BAQMFhQ0E X-IronPort-AV: E=Sophos;i="4.53,277,1272837600"; d="scan'208";a="50999118" Received: from mail-wy0-f182.google.com ([74.125.82.182]) by mail3-smtp-sop.national.inria.fr with ESMTP; 21 May 2010 10:53:54 +0200 Received: by wye20 with SMTP id 20so520476wye.27 for ; Fri, 21 May 2010 01:53:54 -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=VfUfYxtqgzcV5GLfTw/VGqhzQtn/DL2D4FG6M1Y1ExE=; b=mPEEKI5Fm/KBEfgcmNOpjnPCPhOTZ9XlrMvMnwbSip4iPyL0yYJBPV4eKS8INB9TUS tzf0lemmsCqvGZX7ax86owoibSb7sfO8t8CY7sU2WWTn4Dv+EwZyoxodZNe1bhUgrgU3 zLK5BiPKVY/Wd6eDDgcHaPsdKYdTac3LJls84= 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=Vy2syWGKeAcWwbKkVChfhK+TZKPdjcCG9u/hRfnNh09dc3RyqqRtwXphf44vX6s2JK YWcUh04rJT7FlE35n2J/bl+y/juJRTUJ3MVS8PBTkOZpwlqeO/JE5kdEnYqI+CZ0XVuu rRcd77HA/imaolflTG0TMvpmtSQi2R8Tz3k8g= MIME-Version: 1.0 Received: by 10.216.164.20 with SMTP id b20mr627173wel.101.1274432033913; Fri, 21 May 2010 01:53:53 -0700 (PDT) Received: by 10.216.181.65 with HTTP; Fri, 21 May 2010 01:53:53 -0700 (PDT) In-Reply-To: References: Date: Fri, 21 May 2010 10:53:53 +0200 Message-ID: Subject: Re: [Caml-list] Private modules in packages From: Julien Signoles To: Hans Ole Rafaelsen Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=0016e64c1f48abfc5b048716d445 X-Spam: no; 0.00; signoles:01 signoles:01 rafaelsen:01 -pack:01 foo:01 foo:01 mli:01 mli:01 compilation:01 cmi:01 plug-ins:01 makefiles:01 compilation:01 rafaelsen:01 -pack:01 --0016e64c1f48abfc5b048716d445 Content-Type: text/plain; charset=ISO-8859-1 Hello, 2010/5/21 Hans Ole Rafaelsen > When packing a set of modules into a top module using -pack, is there a way > to have some of the modules private to the package? > > If I have the modules Helper, Foo and Bar. Helper provides helper functions > used by Foo and Bar. When I'm packing them into a top mudule P, I do not > want to expose the functions of Helper to users of P. > > Is there some way to achieve this? If not, do anyone know of other ways > for packing libraries and keeping some of the modules private to the > library? > Just write yourself a file p.mli without your private modules: === p.mli === module Foo : ... module Bar : ... ========== Of course, you can not refer to signatures of modules Foo and Bar in p.mli. Thus you have to duplicate them or, better, to write them somewhere outside the package. >>From a compilation point of view, be sure to generate p.cmi by using p.mli before generating the pack files p.cm[ox]. We use such a trick in the Frama-C tool (http://frama-c.com) for providing (usually empty) interfaces of its plug-ins. But I do not recommend you to read the Frama-C Makefiles for looking at the corresponding compilation lines (except if you are **very** motivated). Hope this helps, Julien --0016e64c1f48abfc5b048716d445 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

2010/5/21 Hans Ole Rafaelsen <hrafaelsen@gmail.c= om>
When packing a set of modules into a top module using -pack, is there a way= to have some of the modules private to the package?

If I have the m= odules Helper, Foo and Bar. Helper provides helper functions used by Foo an= d Bar. When I'm packing them into a top mudule P, I do not want to expo= se the functions of Helper to users of P.

Is there some way to achieve this?=A0 If not, do anyone know of other w= ays for packing libraries and keeping some of the modules private to the li= brary?

Just write yourself a file p.mli without yo= ur private modules:
=3D=3D=3D p.mli =3D=3D=3D
module Foo : ...
module Bar : ...
=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D
Of course, you can not refer to signatures of m= odules Foo and Bar in p.mli. Thus you have to duplicate them or, better, to= write them somewhere outside the package.

From a compilation point of view, be sure to generate p.cmi by using p.= mli before generating the pack files p.cm[ox].<= br>
We use such a trick in the Frama-C tool (http://frama-c.com) for providing (usually empty) interfaces of its= plug-ins. But I do not recommend you to read the Frama-C Makefiles for loo= king at the corresponding compilation lines (except if you are **very** mot= ivated).

Hope this helps,
Julien
--0016e64c1f48abfc5b048716d445--