From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id B06055D5 for ; Fri, 27 Apr 2018 06:06:18 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.49,334,1520895600"; d="scan'208";a="324701236" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 27 Apr 2018 08:06:00 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 0B9BA8244E; Fri, 27 Apr 2018 08:06:00 +0200 (CEST) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 152B382416 for ; Fri, 27 Apr 2018 08:05:57 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@ms.math.nagoya-u.ac.jp IronPort-PHdr: =?us-ascii?q?9a23=3AND41jR2Ry3+m6z5ismDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?seMQLPad9pjvdHbS+e9qxAeQG9mDsLQc06L/iOPJYSQ4+5GPsXQPItRndiQuro?= =?us-ascii?q?EopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZv?= =?us-ascii?q?JuTyB4Xek9m72/q99pHPbQhEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+?= =?us-ascii?q?VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfM?= =?us-ascii?q?QA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7Vq4/Vyi84Kh3SR/okC?= =?us-ascii?q?YHOCA/8GHLkcx7kaZXrAu8qxBj34LYZYeYO/1jcKPAZtMaXXROUdpNVyJPBYO8?= =?us-ascii?q?apEAD+sHPe1Fq4XwqF8DoR64CAKxBu3g1yVIi2fq0qI1zuovEQPJ0gIvEdwNvn?= =?us-ascii?q?TastL7ObwOUeCsyanE0TXDY+9I1Tr79YPGcgohofaJXb9odcTe01UgFxrYjlqO?= =?us-ascii?q?sozuIjKb2f4Xs2iB7upgWv+vhHA6oAx2rTig3N0sipPIhoIa11DL6z50wIMvKt?= =?us-ascii?q?2kSE53e9ikH4FftyGdN4p5WNouQ3xytCkg1rIKo5y7fDATxZkh2hXRZfuHc42S?= =?us-ascii?q?7RLiUuacOTZ4hHR/eLK+nRm+60agyvfkWsm70VZKsipFksTXuXwX1hzT7dCLSv?= =?us-ascii?q?R8/ke92TaPyhvc5vtYLkAzkKrXM54gzaQwlpoUtkTPBDP5mELzjKKQa04q+fCo?= =?us-ascii?q?5vz6brjoqJKQLY55hhvjPqkghsCzG/k0PhUWU2Wb+umwzqDv8E36TblQk/E6jK?= =?us-ascii?q?rUvIrHKckbpKO0BRJe3Jw55BalFTim1cwVnXkZI1JBfxKKl43pO0rULPD9F/i/?= =?us-ascii?q?n1SsnC1tx//cMb3hBZXMIWLanLf8Z7py8VJTxBAxzdBH/55UC7cBL+zvWkLpqd?= =?us-ascii?q?DVABE0Pxa1zur9Fdlw2J8SVXiSDqOEKK/StEWH5uMrI+mCfo8VvzP9JuAq5/H0?= =?us-ascii?q?l385g14dfaa03ZQJc324G+5pI1mZYXb2hNcOC2gKvg0+TePwkVGCTCRfaGyuUK?= =?us-ascii?q?4m5DE7EJqqDZ3fSYC1nLyBwCC7E4VKaW9cD1CMFW7kd4GFW/cXdCKfOdRhkzwB?= =?us-ascii?q?Vbi5UYAtzxCutAngy7pmNOXY4CMYtYiwnORyss/Ok1kT8ztpAozJ0XyLCWV9m2?= =?us-ascii?q?kEThc52al+pQp2zVLVgoZihPkNN9VY/u5ESU8VPITGzuNnBpimVQvbZNaGVVuO?= =?us-ascii?q?R9y6AXc3R9020tZLfgB0EJOglkaQjGKRH7YJmunTV9QP+aXG0i20ep8kmiT2kZ?= =?us-ascii?q?I5hlxjefNhcGivh6px7Q/WXdeblkyFl+CsfKsbzSeI6SGKxiyMpBMACVIiYeD+?= =?us-ascii?q?RXkaI3Dug5Hh/EqYFu2rAKgndA1IxsmTI+5XLNTiy1deFq+6ZYbuJlmpkmL1Pi?= =?us-ascii?q?6mg7OBaI2wJzcYx2PYAVQE1QYa8nGXPE0jQC6q5WDGXmRj?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CYAAB1vOJafQuCBoVcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYQkA3cojEuNbyGBD4FAhTKMNYFkAQojhEkCgmUGBjQUAQIBAQEBAQE?= =?us-ascii?q?BAQETAQELFAhLDII1JIJKAQIDJxMGAQEsCwEPCxgNISEkEgYTEoRlAxQQp26CV?= =?us-ascii?q?jOCbwEBBYFigkADCisYaII9CIVthDeBMgyCLi6CTzcLAgKBGA44gzCCJIVhByg?= =?us-ascii?q?IfIR7YopuLAiFY4Vogn2BcYVdhQeFaoNTRVeDEIJSgSUzgXNNODsNDRABghgJN?= =?us-ascii?q?YFWNIM0gT6BJiKBGoZBYI57gjcBAQ?= X-IPAS-Result: =?us-ascii?q?A0CYAAB1vOJafQuCBoVcGgEBAQEBAgEBAQEIAQEBAYQkA3c?= =?us-ascii?q?ojEuNbyGBD4FAhTKMNYFkAQojhEkCgmUGBjQUAQIBAQEBAQEBAQETAQELFAhLD?= =?us-ascii?q?II1JIJKAQIDJxMGAQEsCwEPCxgNISEkEgYTEoRlAxQQp26CVjOCbwEBBYFigkA?= =?us-ascii?q?DCisYaII9CIVthDeBMgyCLi6CTzcLAgKBGA44gzCCJIVhBygIfIR7YopuLAiFY?= =?us-ascii?q?4Vogn2BcYVdhQeFaoNTRVeDEIJSgSUzgXNNODsNDRABghgJNYFWNIM0gT6BJiK?= =?us-ascii?q?BGoZBYI57gjcBAQ?= X-IronPort-AV: E=Sophos;i="5.49,334,1520895600"; d="scan'208";a="263484337" Received: from bsd20.math.nagoya-u.ac.jp (HELO ms.math.nagoya-u.ac.jp) ([133.6.130.11]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2018 08:05:54 +0200 Received: from [192.168.0.13] (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 68C8075AE59; Fri, 27 Apr 2018 15:05:51 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.nagoya-u.ac.jp; s=20160220; t=1524809151; bh=+zNPiVIPe60NSPq2KxSjYxwGBpP7hge3UL60ClcfsTQ=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=sPMxr0Fx6TSqIiCac0bVti7x7oIkuUc+g4b3TIGwJBwZxsMWg+WF8NYsqpXRABvrK cEGwRXe2RyAk048EXDK2Ybu4CVqlgA17dk+UMmA7BYdS/Y0c/FTh/t7KXziJYY6BC4 Ao1Q3gasgQ7rdeRdSpSD8C6bZ0sTIxdgBDW9z/nE= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) From: Jacques Garrigue In-Reply-To: Date: Fri, 27 Apr 2018 15:05:49 +0900 Cc: Mailing List OCaml Content-Transfer-Encoding: quoted-printable Message-Id: <30D1A366-BDE1-4D6A-9531-A21492C930CE@math.nagoya-u.ac.jp> References: To: Jun Inoue X-Mailer: Apple Mail (2.3445.6.18) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (ms.math.nagoya-u.ac.jp [0.0.0.0]); Fri, 27 Apr 2018 15:05:51 +0900 (JST) X-Virus-Scanned: clamav-milter 0.99.2 at bsdserver20 X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bsdserver20.math.nagoya-u.ac.jp Subject: Re: [Caml-list] Type That's Concrete From Within A Library Abstract From Without Reply-To: Jacques Garrigue X-Loop: caml-list@inria.fr X-Sequence: 16860 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: You can provide a mli for the -pack. Just compile it before. $ cat > a.ml type t =3D int let x : int =3D 3 $ cat > b.ml let x2 =3D A.x * A.x $ ocamlc -for-pack P a.ml b.ml $ cat > p.mli module A : sig type t val x : t end module B : sig val x2 : int end $ ocamlc -c p.mli=20 $ ocamlc -pack -o p.cmo a.cmo b.cmo Now, if you use your library with only p.cmo and p.cmi available, you will only be able to access it through the interface you provided. Also, the method using module aliases can work too: you just have to use longer file names for the internal modules, to reduce the risk of conflicts. But this is more involved than using -pack with a mli. Jacques Garrigue On 2018/04/27 14:48, Jun Inoue wrote: >=20 > Hi Ivan, >=20 > That's basically our current approach, but it doesn't solve the > namespace pollution problem. In your example, when someone installs a > file named b.cmi (whose interface is unrelated to your b.ml), the name > conflict prevents loading the std.cma file at all: >=20 > $ ocaml > OCaml version 4.04.0 >=20 > # #show B;; > module B : sig val foo : int end > # #load "std.cma";; > The files std.cma and b.cmi disagree over interface B >=20 > So the technique makes B inaccessible but doesn't remove it from the > namespace. This is why we want to -pack things, because our analogue > of b.ml is named matrix.ml, and there's no other sensible name for it. >=20 > This technique doesn't work with -pack because that option demands all > .cmi's, including b.cmi. I guess we could rename matrix.ml to > matrix_internal_dont_touch.ml, but we wanted to know if there's a > cleaner approach. I wish we could supply a .mli file to the product > of -pack, but that also doesn't work... >=20 > On Fri, Apr 27, 2018 at 12:06 AM, Ivan Gotovchits wrote: >> Hi Jun, >>=20 >> You can achieve this by implying an extra layer of indirection, i.e., by >> having two levels of interfaces. For example, >>=20 >> * A.ml - implementation of module A >> * A.mli - private interface of module A >> * B.ml - implementation of module B that may rely on anything in A.mli >> * Std.ml - a set of modules that you would like to import, e.g., `modu= le >> A =3D A`, `module B =3D B` >> * Std.mli - public interface specification >>=20 >>=20 >> Next, you deploy `std.cmxa` and `std.cmi` but keep `a.cmi` and `b.cmi` to >> yourself. This will prevent users from accessing your private modules A = and >> B directly. (In oasis you can use PrivateModules stanza for this) >>=20 >> Now you will have `Std.A` and `Std.B` that exposes as much as you want. = Not >> sure whether it will work with the `-pack`, but you can use this approach >> instead of it. This is how we address the same issue in [BAP][1] >>=20 >> Cheers, >> Ivan >>=20 >> [1]: https://github.com/BinaryAnalysisPlatform/bap >>=20 >>=20 >> On Thu, Apr 26, 2018 at 10:18 AM, Jun Inoue wrote: >>>=20 >>> Dear list, >>>=20 >>> Is there a way to make a type concrete inside a library, yet opaque to >>> library users, preferably in a way that works with -pack? This is a >>> nagging issue in our sundials package >>> (http://inria-parkas.github.io/sundialsml/). >>>=20 >>> Basically, we have a type declared in one module of the library that >>> is pattern-matched upon in other modules, like: >>>=20 >>> (* private.ml *) >>> type opaque_type =3D Foo | Bar >>>=20 >>> (* public.ml *) >>> let f : opaque_type -> int =3D function >>> | Foo -> 0 >>> | Bar -> 1 >>>=20 >>> There are a few constraints: >>> - We don't want users to be able to pattern-match on opaque_type. >>> - We need multiple modules in the library to pattern-match on >>> opaque-type (so moving opaque_typ e to public.ml is not an option). >>> - To avoid namespace pollution, we want to pack the whole library >>> (with ocamlc -pack) as a single Sundials module, so the user sees a >>> Sundials.Public module instead of just Public. >>>=20 >>> Is this possible? Right now, we just collect public.cmo and >>> private.cmo into sundials.cma and throw away private.cmi. But this >>> doesn't work with packing: >>>=20 >>> $ ocamlc -pack -o sundials.cmo private.cmo public.cmo >>>=20 >>> demands that there be a private.cmi. >>>=20 >>> -- >>> Jun Inoue >>>=20 >>> -- >>> Caml-list mailing list. Subscription management and archives: >>> https://sympa.inria.fr/sympa/arc/caml-list >>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>> Bug reports: http://caml.inria.fr/bin/caml-bugs --=20 Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs=