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 ESMTP id 4DAA45D5 for ; Fri, 27 Apr 2018 05:49:40 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.49,334,1520895600"; d="scan'208";a="324696820" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 27 Apr 2018 07:49:37 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 9218182451; Fri, 27 Apr 2018 07:49:37 +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 0F27782416 for ; Fri, 27 Apr 2018 07:49:30 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jun.lambda@gmail.com; spf=Pass smtp.mailfrom=jun.lambda@gmail.com; spf=None smtp.helo=postmaster@mail-ua0-f175.google.com IronPort-PHdr: =?us-ascii?q?9a23=3AbT+PaxX7XZy1r5VFtvvPCRfVBnHV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYbBOOt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRo?= =?us-ascii?q?LerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf?= =?us-ascii?q?5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXM?= =?us-ascii?q?TRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlD?= =?us-ascii?q?kIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94VQndPXttKVyxZHI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Le1x0QozwgRXK3i7sCLgQxeTSWc4Et5nE1n20HP5TjnbL0K?= =?us-ascii?q?570QsjS8pLcHCv3utxrleOQYHOlEqdmuChcqFOhCM=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BwAQDxuOJah6/ZVdFcGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYNnPXooCoNhg22RD4F0AoENgUCRZ4FkCyOESQKCRQcZBwEENBQBAgE?= =?us-ascii?q?BAQEBAQEBARMBAQEIDQkIKCMMgjUkgkoBAgMjBBkBGxILAQMMBgULAwoCAgkdA?= =?us-ascii?q?gIhAQERAQUBChIGExKEZAEDFQ+dFjyLBYFpFgUBF4JwBYNaChkmAwpUV4I9AgY?= =?us-ascii?q?Sd4RkgiSCE4NsLoJPNwsCAoEYDoM4glQChg4IfIR7YopuLAiFY4Vogn2BcYpkh?= =?us-ascii?q?WqDU0VXhVMPAx6BBDOBc00jUA0NF4ISCYILGhqDNIE+gSaBPIZBMDCOe4I3AQE?= X-IPAS-Result: =?us-ascii?q?A0BwAQDxuOJah6/ZVdFcGgEBAQEBAgEBAQEIAQEBAYNnPXo?= =?us-ascii?q?oCoNhg22RD4F0AoENgUCRZ4FkCyOESQKCRQcZBwEENBQBAgEBAQEBAQEBARMBA?= =?us-ascii?q?QEIDQkIKCMMgjUkgkoBAgMjBBkBGxILAQMMBgULAwoCAgkdAgIhAQERAQUBChI?= =?us-ascii?q?GExKEZAEDFQ+dFjyLBYFpFgUBF4JwBYNaChkmAwpUV4I9AgYSd4RkgiSCE4NsL?= =?us-ascii?q?oJPNwsCAoEYDoM4glQChg4IfIR7YopuLAiFY4Vogn2BcYpkhWqDU0VXhVMPAx6?= =?us-ascii?q?BBDOBc00jUA0NF4ISCYILGhqDNIE+gSaBPIZBMDCOe4I3AQE?= X-IronPort-AV: E=Sophos;i="5.49,334,1520895600"; d="scan'208";a="263482342" Received: from mail-ua0-f175.google.com ([209.85.217.175]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 27 Apr 2018 07:49:28 +0200 Received: by mail-ua0-f175.google.com with SMTP id i3so443159uad.4 for ; Thu, 26 Apr 2018 22:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+2CCS6ZEvzsI7SPaTMfLNv1g3eGUstV27OEiJ7f0cdw=; b=jtmHHuRWfJVEOWLkYQyfn89RnYkX4rRAz+jmIvHARz1yWNehY9AO9YDzATtjXYeyXq r5aT39PwlQC2Hs8arUUvhOqB9OyZ8Q2blaReSoYgpjjkXHS3TfN0IH4COHMj7b5SJhp7 4AZfmnDAyjIre0eaLB5+nPUVqchk5idD9QTFhj75RI2MjLuOcsbYHu07y1AWOoeNdk/+ +WB15hRCl6vUzxJOb2W9RG2N47R0lfoNaC/+odummKl/61rxfZxwGnXpkCu+WqcuUrPn tqMJavpN4KtLHYYCmidvdb3bYfEODI6LeX1nJik8yyQHsFtcbADKfhNO0OoTZ1eQL3MK ahYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+2CCS6ZEvzsI7SPaTMfLNv1g3eGUstV27OEiJ7f0cdw=; b=gQYOERCwlhjRxe1AA+JWALipY/ENwKn+MkTUnrGCuMS9yPqWWo2FRb7qVLavTN4m8z k18hJwsGUGSxGSup7AMp0C5X4tkteP3XwZRPO6OQcAHs2ZVlWHS2pAxNQSSGPDisruX0 omcw5coAmEPijPwERNPSVp4UDB5uWst+cpl1S2LWZN6CvkzBrXl7oaUU3ux4xexNVigQ OA05pR18P/fJQsJSF+koIL6g7fV5xgalmjmHZks4XcHkcL14wPDoURMKHGIkjHtQV202 7cDAELCy5dihj5iUF5R+3/yV4Nx7YncDGNfipJ7m6s5c6GrXOtQwxhzOunPjk2srQY7Q CIwQ== X-Gm-Message-State: ALQs6tBMFN8W6FTiQWOznrfnandx/wkCQ6bX/RXuyBivMLC1VVDBFdlq RzN5Kga5JwsUpTk3THkSNFB5CnHKHUO3PPa+4quJQ2I9 X-Google-Smtp-Source: AB8JxZp3KgGdMCWXxCVoLVylsYmMA8aZMPzJ//cod3mYTXSeUThGG1+iWlhgLyT8png9U6l3QzlCgx2WNd13+CctEC4= X-Received: by 10.159.54.115 with SMTP id s48mr579895uad.19.1524808167210; Thu, 26 Apr 2018 22:49:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.25 with HTTP; Thu, 26 Apr 2018 22:48:56 -0700 (PDT) In-Reply-To: References: From: Jun Inoue Date: Fri, 27 Apr 2018 14:48:56 +0900 Message-ID: To: Ivan Gotovchits Cc: caml list Content-Type: text/plain; charset="UTF-8" Subject: Re: [Caml-list] Type That's Concrete From Within A Library Abstract From Without Reply-To: Jun Inoue X-Loop: caml-list@inria.fr X-Sequence: 16859 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: Hi Ivan, 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: $ ocaml OCaml version 4.04.0 # #show B;; module B : sig val foo : int end # #load "std.cma";; The files std.cma and b.cmi disagree over interface B 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. 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... On Fri, Apr 27, 2018 at 12:06 AM, Ivan Gotovchits wrote: > Hi Jun, > > You can achieve this by implying an extra layer of indirection, i.e., by > having two levels of interfaces. For example, > > * 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., `module > A = A`, `module B = B` > * Std.mli - public interface specification > > > 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) > > 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] > > Cheers, > Ivan > > [1]: https://github.com/BinaryAnalysisPlatform/bap > > > On Thu, Apr 26, 2018 at 10:18 AM, Jun Inoue wrote: >> >> Dear list, >> >> 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/). >> >> Basically, we have a type declared in one module of the library that >> is pattern-matched upon in other modules, like: >> >> (* private.ml *) >> type opaque_type = Foo | Bar >> >> (* public.ml *) >> let f : opaque_type -> int = function >> | Foo -> 0 >> | Bar -> 1 >> >> 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. >> >> 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: >> >> $ ocamlc -pack -o sundials.cmo private.cmo public.cmo >> >> demands that there be a private.cmi. >> >> -- >> Jun Inoue >> >> -- >> 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 > > -- Jun Inoue -- 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