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 2B64A5D5 for ; Thu, 26 Apr 2018 15:14:45 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.49,330,1520895600"; d="scan'208";a="324619433" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 26 Apr 2018 17:14:42 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 91AF982452; Thu, 26 Apr 2018 17:14:42 +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 EB00282416 for ; Thu, 26 Apr 2018 17:14:33 +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@vrout10.yaziba.net IronPort-PHdr: =?us-ascii?q?9a23=3AmtwD7xHMY45fvw9y3J/qAJ1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7yoc+wAkXT6L1XgUPTWs2DsrQY07GQ6/iocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmDSwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+?= =?us-ascii?q?NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjD?= =?us-ascii?q?QhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VC+85Kl3VhDnlC?= =?us-ascii?q?YHNyY48G7JjMxwkLlbqw+lqxBm3oLYfJ2ZOP94c6zaYN0aWHFBXt5PWCNdHoOy?= =?us-ascii?q?YYwPD+8bMuZZqYn2ul8CoBS6CAWpAu7k1z1GiWLs3aAi0eshHwHI0gIjEdwTrn?= =?us-ascii?q?rbsNr7ObwOUeCs1qTE0SnPY+9U1Dr79YPGcgohofaJXb9oacTRyFUgFwTBjlKS?= =?us-ascii?q?sozqJyqb1uYTvGeG9eVvTf+ijGs9qwpspTWvwMYshZXOhoIR0F/E7j91wIE3Jd?= =?us-ascii?q?KmVUF0e8SoH4BKuCGALIZ2Rt0tQm5puCY0y70Ko4K0fC8PyJk+wRPUdvKJc4+N?= =?us-ascii?q?4h35VeaRJy91hHNjeLKlhha961KsyuPmVsWs31ZKrzZFktnRtn8WzRDT68+HRu?= =?us-ascii?q?N9/0i72TaP0AfT5vtYLkAzkKrWLYMqzL0olpcLrEjOHS/7lF/2gaKXbEko5PSk?= =?us-ascii?q?5uv9brjouJOQL5F4hh36P6g0mcGyAf40PhYTU2Wb4+ix1KDv8EvkS7tQlPI2iL?= =?us-ascii?q?PWsJXCKMQbuKG5BwhV35496xalCDemzcgYkWQbIF5feBOIlYnoO1DVL//iF/u/?= =?us-ascii?q?hUqjkCtzy/DHOL3uHInNI2DenLrifbtx8U5RxQspwdxB+55ZBasNLfztVkPpsd?= =?us-ascii?q?zXFB45Mwi6w+b9D9V905sTWWSOAqCFN6PStUWH5vk1L+mLZo8apivyJOI/6/H1?= =?us-ascii?q?l3A5g0QQfa230poYaXC4EPVmL1+Fbnrrh9cNCX0KsRYmTOz2lF2CViZeaGqoUK?= =?us-ascii?q?I54jE3EYamDYbYRoCxm7GBxye6HphOZm9cEFyMEHHod5+FW/gWci6SLNVhniQB?= =?us-ascii?q?VbimVoAuywmjtBT/y7p7NurU/TAYtY6wnORyss/Ok1kT8ztpAozJ0XyLCWV9m2?= =?us-ascii?q?kEThc52al+pQp2zVLVgoZihPkNM91Y4PfASTAdN5PQxttQh8q6DgTAddCNQU3g?= =?us-ascii?q?RderDTh3RNsr69sDc0dzGpOpiRWVjHniOKMci7HeXM98yanbxXWkYpskkieU5O?= =?us-ascii?q?wal1AjB/B3Gyijj697+RLUAteTwUGUh6ekdOIX2yufrz7fn1rLh1lRVUtLaYuA?= =?us-ascii?q?RWoWPxGEqdnp503DCbSpDOZ/a1YT+Yu5MqJPL+bRoxBGSfPkYoyMfXi2hnvpXV?= =?us-ascii?q?CZz6GNZoOsfWgBjn3Q?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CwAABD7OFahyDMOLlbGgEBAQEBAgEBA?= =?us-ascii?q?QEIAQEBAYQkeigKg2GUeYF0E3yBQIUyjDWBZAsjhEkCgj4HGQwFLxQBAgEBAQE?= =?us-ascii?q?BAQEBARMBAQEKCwkIKCMMQg4BgWQkgkoBAgMjBEcLEAsLDQICCR0CAiEBEgEFA?= =?us-ascii?q?QoSBhMICoRlAxUEAQqcRjyLBYFpM4cNAwqBBiWCRYEJhwiCE4MbUS6CTzcLAgK?= =?us-ascii?q?BJgWDM4JUAoYOCHyQSywIhWOFaIJ9gXGKZIk9RYYqDwMegQICM4ECcXBQDQ0XB?= =?us-ascii?q?oIMCYIlGoIFgS+BPoEmgTyGNG0BhUGLagEB?= X-IPAS-Result: =?us-ascii?q?A0CwAABD7OFahyDMOLlbGgEBAQEBAgEBAQEIAQEBAYQkeig?= =?us-ascii?q?Kg2GUeYF0E3yBQIUyjDWBZAsjhEkCgj4HGQwFLxQBAgEBAQEBAQEBARMBAQEKC?= =?us-ascii?q?wkIKCMMQg4BgWQkgkoBAgMjBEcLEAsLDQICCR0CAiEBEgEFAQoSBhMICoRlAxU?= =?us-ascii?q?EAQqcRjyLBYFpM4cNAwqBBiWCRYEJhwiCE4MbUS6CTzcLAgKBJgWDM4JUAoYOC?= =?us-ascii?q?HyQSywIhWOFaIJ9gXGKZIk9RYYqDwMegQICM4ECcXBQDQ0XBoIMCYIlGoIFgS+?= =?us-ascii?q?BPoEmgTyGNG0BhUGLagEB?= X-IronPort-AV: E=Sophos;i="5.49,330,1520895600"; d="scan'208";a="263420473" Received: from vrout10.yaziba.net ([185.56.204.32]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Apr 2018 17:14:32 +0200 Received: from mtaout10.int.yaziba.net (mtaout10.int.yaziba.net [10.4.20.36]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id 3616A51F11 for ; Thu, 26 Apr 2018 17:14:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout10.int.yaziba.net (Postfix) with ESMTP id 336E916046F for ; Thu, 26 Apr 2018 17:14:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at Received: from mtaout10.int.yaziba.net ([127.0.0.1]) by localhost (mtaout10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 17A0eD-gw2xj for ; Thu, 26 Apr 2018 17:14:32 +0200 (CEST) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by mtaout10.int.yaziba.net (Postfix) with ESMTPSA id 0AE321602F6 for ; Thu, 26 Apr 2018 17:14:32 +0200 (CEST) Received: by mail-lf0-f51.google.com with SMTP id j16-v6so14058469lfb.7 for ; Thu, 26 Apr 2018 08:14:32 -0700 (PDT) X-Gm-Message-State: ALQs6tBjpCCZmONBeKniPofDLu+nCJhL7POBlls41tzc95/1vzBFANm5 zeOFPM2z6D/sinkUh9N5PhmXgAdJhZ/RICOleOk= X-Google-Smtp-Source: AIpwx485EKmY8Gxo27ZkYR2wH6OeXalwPr7vEGH3jHf9z668gEUaWVpj3r6ve7g286iiEaI8T/wA2u6kRPbDHBh9Vr4= X-Received: by 10.46.152.22 with SMTP id a22mr17797434ljj.27.1524755671447; Thu, 26 Apr 2018 08:14:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.0.66 with HTTP; Thu, 26 Apr 2018 08:14:10 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?Q?Nicol=C3=A1s_Ojeda_B=C3=A4r?= Date: Thu, 26 Apr 2018 17:14:10 +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: gggruggvucftvghtrhhoucdtuddrgedtgedrleefgdekkecutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegoufhushhpvggtthffohhmrghinhculdegledmnecujfgurhepjghfhfffkffuvfgtgfesthhqredttddtjeenucfhrhhomheppfhitgholhojshgpqfhjvggurggpueomrhcuoehnihgtohhlrghsrdhojhgvuggrrdgsrghrsehlvgigihhfihdrtghomheqnecuffhomhgrihhnpehinhhrihgrrdhfrhdpghhithhhuhgsrdhiohdphigrhhhoohdrtghomhenucfkphepvddtledrkeehrddvudehrdehudenucfrrghrrghmpehmohguvgepshhmthhpohhuth 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: 16856 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: Sorry, I forgot the last step in my email, which is to create a cma with all the compilation units: ocamlc -a sundials*.cmo -o sundials.cma and install sundials.cma and the public *.cmi's as needed. Best wishes, Nicol=C3=A1s On Thu, Apr 26, 2018 at 5:03 PM, Nicol=C3=A1s Ojeda B=C3=A4r wrote: > 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=