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 011AF5D5 for ; Sat, 1 Jun 2019 01:01:09 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,536,1549926000"; d="scan'208";a="385502380" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 01 Jun 2019 03:01:08 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id A2798826E3; Sat, 1 Jun 2019 03:01:08 +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 C2A737ED69 for ; Sat, 1 Jun 2019 03:00:55 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=asai@is.ocha.ac.jp; spf=Pass smtp.mailfrom=asai@is.ocha.ac.jp; spf=None smtp.helo=postmaster@web.is.ocha.ac.jp IronPort-PHdr: =?us-ascii?q?9a23=3AwDf4LB3+bjJpsyYrsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?se0eK/ad9pjvdHbS+e9qxAeQG9mCsrQd0LCd7/qocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmSexbalvIBi4swnducYbjZV/Iast1xXFpWdFdf?= =?us-ascii?q?5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALM?= =?us-ascii?q?TRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljj?= =?us-ascii?q?oMOTwk/2HNksF+gqJVrgy8qRJ8zY7bb52aO+d8cazTZt4aWXZNU9xNWyBdGI6w?= =?us-ascii?q?cY0CBPcBM+ZCqIn9okMDox6gCgmqBePg1j9Ihn7r1qAmyOQuCwDG1xEnEt0Uq3?= =?us-ascii?q?TbttT1ObwTUeCu1qXIyinMb/NM1jvn8ofHbgotofOUXb9pd8fa1EchFwTAjlqK?= =?us-ascii?q?qIzlOSuY1uQRs2ie6+psT+Ovi3U/pwF+oziv2scsipTSiY4P1l/E8iB5zYAoLt?= =?us-ascii?q?O7UE52ecOoHZVeui2ANoZ7QtkuTmBntSog17EKpYa3cDUUxJkp3RLTdfKKf5SS?= =?us-ascii?q?7h7+UOucIC10iXB4dL+5mh2861KvyvfmWcmxyFtKrjRKkt3Ltn0V2R3c9NOIRu?= =?us-ascii?q?F8/ke6wzqP0Bzc6uFeLkwuj6XUN4QtwrwolpYLsETDGDH5mFnugaOLeEgp9PKk?= =?us-ascii?q?5uXnb7n8p5KROJV4hhziPqg2n8ywG+U4MgwAX2iB/uS80aXu8lfiQLpQj/07ia?= =?us-ascii?q?jZsIvAKcQcuqG5AxVa3pw55BmjFTum0swYkWEdLF1ZYBKHk5TpO1bWLf/kF/i/?= =?us-ascii?q?hlCsnC5vx/DHJb3hHo7ALmPDkbfkZbZy8VRQyAs1zdBF5pJbEKsNIPzpWhy5iN?= =?us-ascii?q?uNDgI2NETgw/voD5N9254MUHiDKqCcOaLW91SP47R8DfOLYdo2tTD8IPgkr9f1?= =?us-ascii?q?hH5xzVYGdKiB3IBRb3u4F7JvKAObeSy/0Z86DW4Ws19mH6TRg1qYXGsLPirgb+?= =?us-ascii?q?cH/jg+TbmeI8LbXIn03e6Ax2G8FZ1fIGlNTFKUQy+xJte0HswUYSfXGfdP1zkN?= =?us-ascii?q?VLyvUYgkjEz8tRS8zLFnJ6zd8WsarcC6jYUn16jojRg3sAdMIYGd3mWKFjAmgW?= =?us-ascii?q?4CAT4tmqd0oUU7w1zF07Aq2/E=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BlAACwzfFcWwpAQYVlGQEBAQEBAQEBA?= =?us-ascii?q?QEBAQcBAQEBAQGBZYIRJUSBBCiND4wZmlgBCAEDAQoBASUIAgEBg3pGAoMEGwc?= =?us-ascii?q?BBDQTAQMBAQQBAQIBAQMBBhoVIjEMgjoigm4BAQEBAgE6OQYFCwsYCSUPBSABB?= =?us-ascii?q?QEIGhODI4F7DgEPnno8jE+IQiGBVw0CA4Eii2+Bf4MlUC4+gmEChR2CJgSIeQe?= =?us-ascii?q?CJYkGlEcJgg+CF4QmjGUMG4MJiVKKDC2TVo8OAgQCBAUCBg8hgUWBeTMaCDA7g?= =?us-ascii?q?mwJhXaEIIZCMTKBAyYTjU0BAQ?= X-IPAS-Result: =?us-ascii?q?A0BlAACwzfFcWwpAQYVlGQEBAQEBAQEBAQEBAQcBAQEBAQG?= =?us-ascii?q?BZYIRJUSBBCiND4wZmlgBCAEDAQoBASUIAgEBg3pGAoMEGwcBBDQTAQMBAQQBA?= =?us-ascii?q?QIBAQMBBhoVIjEMgjoigm4BAQEBAgE6OQYFCwsYCSUPBSABBQEIGhODI4F7DgE?= =?us-ascii?q?Pnno8jE+IQiGBVw0CA4Eii2+Bf4MlUC4+gmEChR2CJgSIeQeCJYkGlEcJgg+CF?= =?us-ascii?q?4QmjGUMG4MJiVKKDC2TVo8OAgQCBAUCBg8hgUWBeTMaCDA7gmwJhXaEIIZCMTK?= =?us-ascii?q?BAyYTjU0BAQ?= X-IronPort-AV: E=Sophos;i="5.60,536,1549926000"; d="scan'208";a="307795616" X-MGA-submission: =?us-ascii?q?MDE0vi29yKFq+3fJzd3dXrNcu8l/htIyKVHBLZ?= =?us-ascii?q?IHJOxnv60Rh6NWcAvMr09c3CttTXcIqA9swtq418yVp8gtDic6NtSAkU?= =?us-ascii?q?NRCpMAxMH9JjQvO7HGYy17mENpxL7AT7BuhmcTUGZ/L/uu3eFGS2yDpA?= =?us-ascii?q?1kYmaFLgWReaAF2vWBY6XB5g=3D=3D?= Received: from web.is.ocha.ac.jp ([133.65.64.10]) by mail3-smtp-sop.national.inria.fr with ESMTP; 01 Jun 2019 03:00:53 +0200 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by web.is.ocha.ac.jp (Postfix) with ESMTP id CF96220093979 for ; Sat, 1 Jun 2019 10:00:50 +0900 (JST) Received: by mail-pl1-f197.google.com with SMTP id x20so1770003pln.6 for ; Fri, 31 May 2019 18:00:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4XB9I3I/YO27ikmRpE/8WH/G0SJeiUW942t8QhFnmb0=; b=Y4jUnsEdNHUNNtUUPZXXahyN0E7o7ayvL3PjjgNGdRBnYGWIxTgPsUmr1bhCxLpEaN Pi/v3LhyM0zPka5/ETfU+RHgObGA4GqjK87df5QbASo608hIOcgp4bgAoRobyWYN+xL6 XCGbiHK7/wvprXly2cQWB37TykPBxxugoRmbq9gWoCKN9/twCkDAaqwvgMZu32yE/ieF qRMMRsHhYxQ0E++2D6Z75J7x6s8iXkdEWETWScrfRcvgDAZVdI/kwTfJlqqFlUwsREKJ flRFHRJGdUHJAjUIaq8Leb9boMxKgeFa7ub2lRbEER/qiAyjhrYr0SaBpbK9F7Drid56 HlpQ== X-Gm-Message-State: APjAAAVzguF3meJjn5LSs+N42clq2HgrG3Puw8hzsFdmNf84ci1cNy/l nxrb2962GwmdhgBbQB4mtGR1CK/1cXHpbh+OZkLFjBOXm9qx30qZh2nkIysU6tboeRdaJFyuUeD gIRdJDEOD95Au X-Received: by 2002:a17:902:2883:: with SMTP id f3mr13133217plb.111.1559350850133; Fri, 31 May 2019 18:00:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsibQwj4LPoU+JUvc5+IsUe/yDfjS9F+XWHGMehtk4pJPLOo7PQOCTo6OwpP836rDEVG10HQ== X-Received: by 2002:a17:902:2883:: with SMTP id f3mr13133117plb.111.1559350848947; Fri, 31 May 2019 18:00:48 -0700 (PDT) Received: from localhost (123.230.196.71.er.eaccess.ne.jp. [123.230.196.71]) by smtp.gmail.com with ESMTPSA id a16sm6819391pfi.188.2019.05.31.18.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 18:00:47 -0700 (PDT) Date: Sat, 1 Jun 2019 10:00:31 +0900 From: Kenichi Asai To: hugo Cc: caml-list@inria.fr Message-ID: <20190601010031.GA673@pllab.is.ocha.ac.jp> References: <20190526062659.GA63981@pllab.is.ocha.ac.jp> <20190530141933.GA93967@pllab.is.ocha.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190530141933.GA93967@pllab.is.ocha.ac.jp> User-Agent: Mutt/1.7.2 (2016-11-26) Subject: Re: [Caml-list] How can I use a library in a toplevel created by js_of_ocaml? Reply-To: Kenichi Asai X-Loop: caml-list@inria.fr X-Sequence: 17597 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: I could. In addition to adding myFac to the argument of jsoo_listunits: > (action (run jsoo_listunits -o %{targets} stdlib myFac)) I inserted myFac as one of the libraries: (executables (names eval) (libraries myFac js_of_ocaml-compiler js_of_ocaml-toplevel) (link_flags (:standard -linkall)) (preprocess (pps js_of_ocaml-ppx))) and added the path to the cmi file of myFac library to the argument of js_of_ocaml. -I /home/asai/.opam/ocaml-base-compiler.4.04.0/lib/myFac/ (I wonder if I always have to write this path. Maybe it could be automatically searched (as it is an opam library) or there is a better way to write it rather than writing the absolute path.) > As a related question, is there a document I can study that describes: > - what jsoo_listunits does, and > - what the --export option (and other options) of js_of_ocaml does? I imagine that: - executables have to contain libraries to be used in the toplevel. - The --export option exports to the toplevel those modules that are required in the toplevel. - export.txt specifies which modules to be exported. Correct me if I am wrong. I still welcome any documents to study. Sincerely, -- Kenichi Asai On Thu, May 30, 2019 at 11:19:33PM +0900, Kenichi Asai wrote: > Thank you for the e-mail. It goes great. Going one step further, can > I do the same if I install fac as an opam library? Suppose I packaged > fac.ml as a library called myFac and installed fac.cma and fac.cmi via > opam. Using: > > (action (run jsoo_listunits -o %{targets} stdlib myFac)) > > I could compile it but I got the "Unbound module Fac" error when I > open index.html. Is listing myFac in the above line not enough? > > As a related question, is there a document I can study that describes: > - what jsoo_listunits does, and > - what the --export option (and other options) of js_of_ocaml does? > > -- > Kenichi Asai > > > On Tue, May 28, 2019 at 08:41:01AM +0800, > hugo wrote: > > > You need to tell js_of_ocaml the list of cmi that you want to export. > > [jsoo_listunits] can compute the list of cmi from a findlib library. > > Because fac is not installed, you'll need to be explicit. > > There might be some better wait to integrate with dune but the following > > should change should do what you want. > > > > (rule > > (targets export.txt) > > (deps eval.bc fac/fac.cma) > > (action (run jsoo_listunits -o %{targets} stdlib fac/.fac.objs/byte/fac.cmi))) > > > > H > > > > > > On Sun, May 26, 2019 at 2:27 PM Kenichi Asai wrote: > > > > > I want to create a web page where I can execute an OCaml expression > > > that mentions a prebuilt user-defined library. I find the following > > > example in the js_of_ocaml/toplevel repository: > > > > > > https://github.com/ocsigen/js_of_ocaml/tree/master/toplevel/examples/eval > > > > > > Can I extend this example so that the toplevel is compiled with a > > > user-defined library? The attached program contains the following > > > where the first three files are copied from the example in the > > > js_of_ocaml/toplevel repository. > > > > > > toplevel/ -- dune > > > -- eval.ml > > > -- index.html > > > -- fac/ -- dune > > > -- fac.ml > > > > > > I intend that fac.ml is compiled as a library and I want to use it in > > > the toplevel. I added "fac" in the libraries stanza of the toplevel > > > dune file (as in the attached file): > > > > > > (executables > > > (names eval) > > > (libraries > > > fac > > > js_of_ocaml-compiler > > > js_of_ocaml-toplevel) > > > (link_flags (:standard -linkall)) > > > (preprocess (pps js_of_ocaml-ppx))) > > > > > > Naturally, fac.ml is compiled and I can use it in the eval.ml, but it > > > is not visible from the toplevel. I included the following part in > > > the index.html (as in the attached file): > > > > > > > > >
> > > > > > but the output says: > > > > > > File "/dev/fake_stdin", line 2, characters 6-12: > > > Error: Unbound module Fac > > > > > > Thank you in advance. > > > > > > -- > > > Kenichi Asai