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 6D3185D5 for ; Thu, 26 Apr 2018 15:04:10 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.49,330,1520895600"; d="scan'208";a="324617103" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 26 Apr 2018 17:04:03 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id CF4CD82456; Thu, 26 Apr 2018 17:04:03 +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 D9CF282453 for ; Thu, 26 Apr 2018 17:03:51 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=SoftFail smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@vrout30.yaziba.net IronPort-PHdr: =?us-ascii?q?9a23=3A1y2L6hZVxC9DIFYP0espEtb/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZrsq5bnLW6fgltlLVR4KTs6sC17KN9fi4EUU7or+5+EgYd5JNUxJXwe?= =?us-ascii?q?43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRp?= =?us-ascii?q?OOv1BpTSj8Oq3Oyu5pHfeQpFiCazbL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+?= =?us-ascii?q?RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPC?= =?us-ascii?q?TQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjm58axlVAHnhz?= =?us-ascii?q?sGNz4h8WHYlMpwjL5AoBm8oxBz2pPYbJ2JOP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us-ascii?q?BNKkDD04CNg42fcKblZ8FdTkhRfGiXn5S4QJnqCGUcRnupnX2GL8coMgki+Xhp?= =?us-ascii?q?lktEEvR450DUPjg6d+8wbJAIuQyRedmrare6Va1ynIpjzakTi++XpAWQs1ap3r?= =?us-ascii?q?GGgFbxKM/9D09kLMTvmlDrF1alIcm/7HEbNDb5jStXsDRPrnP46GMXyrnHqsXk?= =?us-ascii?q?7O17qebYDjPWMQwHeFBQ=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CAAADi6eFahyHMOLlbGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYQkeigKg2GUeYF0E3yBQIUyjDWBZAsjhEkCgj0HGQwFLxQBAgEBAQE?= =?us-ascii?q?BAQEBARMBAQEKCwkIKCMMgjUkgkoBAgMjBEcLEAsLDQICCR0CAiEBEgEFAQoSB?= =?us-ascii?q?hMShGUDFQQBCpw+PIsFgWkzhw0DCoEGJYJFgQmHCIITgxtRLoJPNwsCAoEmgzi?= =?us-ascii?q?CVAKGDgh8kEssCIVjhWiCfYFximSJPUWGKg8DHoECAjOBc3BQDQ0XBoIMCYIlG?= =?us-ascii?q?oM0gT6BJoE8hjRtAZErAQE?= X-IPAS-Result: =?us-ascii?q?A0CAAADi6eFahyHMOLlbGgEBAQEBAgEBAQEIAQEBAYQkeig?= =?us-ascii?q?Kg2GUeYF0E3yBQIUyjDWBZAsjhEkCgj0HGQwFLxQBAgEBAQEBAQEBARMBAQEKC?= =?us-ascii?q?wkIKCMMgjUkgkoBAgMjBEcLEAsLDQICCR0CAiEBEgEFAQoSBhMShGUDFQQBCpw?= =?us-ascii?q?+PIsFgWkzhw0DCoEGJYJFgQmHCIITgxtRLoJPNwsCAoEmgziCVAKGDgh8kEssC?= =?us-ascii?q?IVjhWiCfYFximSJPUWGKg8DHoECAjOBc3BQDQ0XBoIMCYIlGoM0gT6BJoE8hjR?= =?us-ascii?q?tAZErAQE?= X-IronPort-AV: E=Sophos;i="5.49,330,1520895600"; d="scan'208";a="263418525" Received: from vrout30.yaziba.net ([185.56.204.33]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Apr 2018 17:03:50 +0200 Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id 537D1520F2 for ; Thu, 26 Apr 2018 17:03:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id 4A26016041E for ; Thu, 26 Apr 2018 17:03:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at mtaout20.int.yaziba.net Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AeRY44l8qVrj for ; Thu, 26 Apr 2018 17:03:50 +0200 (CEST) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 204C51602DB for ; Thu, 26 Apr 2018 17:03:50 +0200 (CEST) Received: by mail-lf0-f47.google.com with SMTP id h197-v6so3855780lfg.11 for ; Thu, 26 Apr 2018 08:03:50 -0700 (PDT) X-Gm-Message-State: ALQs6tD9VDBP4PB+bhUcGjPWXsHJXetd29rITfdz+ijsf48qhpR6AUYl Vw6G92qwmdt0x/kGpYOHPBlj+8KWuuuXCsB1+sM= X-Google-Smtp-Source: AB8JxZoeEAuo0xSlU1yeFpw8vEV7fS70NAnPFd7vqyRMF2aXZQ04YfBfYxQI8q47ei91OAPSFBeOLNbm9CK6Gnfinp0= X-Received: by 10.46.153.207 with SMTP id l15mr94476ljj.148.1524755029525; Thu, 26 Apr 2018 08:03:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.0.66 with HTTP; Thu, 26 Apr 2018 08:03:28 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Date: Thu, 26 Apr 2018 17:03:28 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Jun Inoue Cc: caml list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -51 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedtgedrleefgdekiecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegoufhushhpvggtthffohhmrghinhculdegledmnecujfgurhepjghfhfffkffuvfgtgfesthhqredttddtjeenucfhrhhomheppfhitgholhojshgpqfhjvggurggpueomrhcuoehnihgtohhlrghsrdhojhgvuggrrdgsrghrsehlvgigihhfihdrtghomheqnecuffhomhgrihhnpehinhhrihgrrdhfrhdpghhithhhuhgsrdhiohdphigrhhhoohdrtghomhenucfkphepvddtledrkeehrddvudehrdegjeenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] Type That's Concrete From Within A Library Abstract From Without Reply-To: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= X-Loop: caml-list@inria.fr X-Sequence: 16854 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: Dear Jun, This is a limitation of module packs. However, there is a much better alternative to module packs in the form of module aliases which will allow you to do what you want. You can head to https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec249 for a more lengthy explanation, but briefly, in your example: 1. rename private.ml to sundials__private.ml and public.ml to sundials__public.ml 2. create a file sundials.ml with contents: module Private =3D Sundials__private module Public =3D Sundials__public 3. compile sundials.ml with ocamlc -no-alias-deps -c sundials.ml (you may want to disable warning 49 when doing this) 4. compile the individual files in the library with ocamlc -no-alias-deps -open Sundials -c sundials__private.ml ocamlc -no-alias-deps -open Sundials -c sundials__public.ml 5. You can now delete (or not install) sundials__private.cmi and ship the other files sundials.cmo sundials.cmi sundials__public.cmo sundials__public.cmi sundials__private.cmo to hide the private module from "outside" library users. Note that if you use jbuilder/dune, then your library will be built like this (steps 1-4) by default. Hope it helps, Best wishes, Nicol=C3=A1s On Thu, Apr 26, 2018 at 4:18 PM, 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 =3D Foo | Bar > > (* public.ml *) > let f : opaque_type -> int =3D 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 --=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=