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 9FC9C5D5 for ; Thu, 6 Jun 2019 01:05:54 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,557,1549926000"; d="scan'208,217";a="386180753" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 06 Jun 2019 03:05:53 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 325FE826E4; Thu, 6 Jun 2019 03:05:53 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id F096F8247D for ; Thu, 6 Jun 2019 03:05:45 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=hugo.heuzard@gmail.com; spf=Pass smtp.mailfrom=hugo.heuzard@gmail.com; spf=None smtp.helo=postmaster@mail-vk1-f193.google.com IronPort-PHdr: =?us-ascii?q?9a23=3AvlBBzhfWnTmJneLgxZaOK+UhlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcS+ZB7h7PlgxGXEQZ/co6odzbaP6ua5BTdLvc7JmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6?= =?us-ascii?q?OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MQi6oR/MusQZj4ZuJak8xgfUqXZUZu?= =?us-ascii?q?pawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnF?= =?us-ascii?q?VguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hC?= =?us-ascii?q?oBKjU063/chNBug61HoRKhvx1/zJDSYIGJL/p1Y6fRccoH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?E4eWRAopR9d0+OcgJkN0GtGslBfGhnP4DLoclrjND5sxoPvR?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BbBAB/Zvhcf8HdVdFmDg8BAQUBBwUBg?= =?us-ascii?q?WWCe1EzKIQUgR2CXpEDikeQEgkBAwEMJQoBAYN6RgKCVhsHAQQ0EwEDAQEEAQE?= =?us-ascii?q?CAQEDARMBAQkLCwgnJQyCOikBgmYBAQEDASMdARsXBgEDAQsGAwILDSoCAiIBE?= =?us-ascii?q?QEFARwGE4MjgWkBAw4PD4p8kA48iyCBFAUBF4J6BYQ4ChknDWCBOgIHDQIDgSK?= =?us-ascii?q?LW4IWgyVQLj6CYQKCDoJdglgEizCHeoESlFQHAoIQgWgBhFmMeBuDDJNzLZNzj?= =?us-ascii?q?zcPIYFFgXlwUDGCOwmCBoNwhCCFeEg1MJAPAQE?= X-IPAS-Result: =?us-ascii?q?A0BbBAB/Zvhcf8HdVdFmDg8BAQUBBwUBgWWCe1EzKIQUgR2?= =?us-ascii?q?CXpEDikeQEgkBAwEMJQoBAYN6RgKCVhsHAQQ0EwEDAQEEAQECAQEDARMBAQkLC?= =?us-ascii?q?wgnJQyCOikBgmYBAQEDASMdARsXBgEDAQsGAwILDSoCAiIBEQEFARwGE4MjgWk?= =?us-ascii?q?BAw4PD4p8kA48iyCBFAUBF4J6BYQ4ChknDWCBOgIHDQIDgSKLW4IWgyVQLj6CY?= =?us-ascii?q?QKCDoJdglgEizCHeoESlFQHAoIQgWgBhFmMeBuDDJNzLZNzjzcPIYFFgXlwUDG?= =?us-ascii?q?COwmCBoNwhCCFeEg1MJAPAQE?= X-IronPort-AV: E=Sophos;i="5.60,557,1549926000"; d="scan'208,217";a="386180727" X-MGA-submission: =?us-ascii?q?MDGyNmT9lVZXGOIBHIeAonhkgSIeKQvmGZaY3n?= =?us-ascii?q?x0Mo/hRvs74jCwd+p8QykfbPIZ46/HBNXE4R8bDme0YhYV6FRSwEAPft?= =?us-ascii?q?gL0AYrKIcEvzMlEN+QsInNTx+pnzBea+DGNhs8dnS1MiM+jIBXIZ9AUh?= =?us-ascii?q?S7gh043TI7dShR531H8pbjsQ=3D=3D?= Received: from mail-vk1-f193.google.com ([209.85.221.193]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 06 Jun 2019 03:05:28 +0200 Received: by mail-vk1-f193.google.com with SMTP id b69so142711vkb.3 for ; Wed, 05 Jun 2019 18:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sItbMsNqi4zmx5uSFW/Vd2cNZlZbdjfMDq5GcJd1Zsk=; b=sQVqofZ3Ju7w8Jcue4OL0YgHUgWqEuUKG66Mke9eQJzzWXDyYcxqESvA0JZzX56ewC Q34+kAWe7AYKb8NR/kwaP/M9o67+EMxnJ6EgBvIymg5xQOutcshGkbGUFa21TBtQpeak XEHvO+CGkEX4KLJYITyts8Jv9qC1aeylZHHn9o1Xtx0kFC3TyMrQj18w61U/Sjt6ocyP kftBPTtcI2h3tXsxGRV0Aop/0lTfg3bLdV6NG/Lv90NP9rVWgmZuHlmZlQJqjqxs0k4M ieybosYWLTXXXzVtTGEPKVbNlaW1M9E75opXbQnyzsKvcl2N9mulHHale2uYJwePIS2I 8vBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sItbMsNqi4zmx5uSFW/Vd2cNZlZbdjfMDq5GcJd1Zsk=; b=Pm+fzSuditJFq6GerQA6UviE2ff9txw65gQFzB3+Mflvtu/971fVEcPIsFJF8zqrln kUozhA/ZO7sgSQvDpkVlUE5Qgv2/W3RMsGfeEl0QJrUJMjkSEoVKRncMLQPCS1arKlGf g1LePNy1MX2Yc3cQQsByhUOx9A03H0aaYU7aNqVALs7Q8My83/IKDqMufBaBqdmUwIy2 ZsH0UdhQGhhphaE4lwi2gqrLMOb/PQWUJrYMZYn2wqV9+r39S7W3okhxvsgWrU0/DDIR pUmql1xS/loaZ7nhbjiTiKozTsfckttsbL6+aXkaBpCiha309/X1IWrgqTdn3SVbHEfx 5cYQ== X-Gm-Message-State: APjAAAXU6a+TqlY1Ugp/PxGO9n1jbsj33Bbed/LT7onzj0zU8sBYz596 rKIfvgGPqkpSWxKkcUzI+DHwhIgrX2hzviTs660y3aaer1ZneA== X-Google-Smtp-Source: APXvYqx8eVBh/WyjEJTZkuhJ+gU1vPeUiEPnPoJZZ3MiQJ54VLuB4XaOsDlrCzHrYWxLZqN/Ypagcvc8CrCjLfi6Y4A= X-Received: by 2002:ac5:c254:: with SMTP id n20mr13766459vkk.89.1559783126932; Wed, 05 Jun 2019 18:05:26 -0700 (PDT) MIME-Version: 1.0 References: <20190526062659.GA63981@pllab.is.ocha.ac.jp> <20190530141933.GA93967@pllab.is.ocha.ac.jp> <20190601010031.GA673@pllab.is.ocha.ac.jp> In-Reply-To: <20190601010031.GA673@pllab.is.ocha.ac.jp> From: hugo Date: Thu, 6 Jun 2019 09:05:15 +0800 Message-ID: To: Kenichi Asai Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary="0000000000003522c9058a9d4f96" Subject: Re: [Caml-list] How can I use a library in a toplevel created by js_of_ocaml? Reply-To: hugo X-Loop: caml-list@inria.fr X-Sequence: 17604 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: --0000000000003522c9058a9d4f96 Content-Type: text/plain; charset="UTF-8" On Sat, Jun 1, 2019 at 9:00 AM Kenichi Asai wrote: > 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.) > I would expect the path to not be necessary when passing a library name to jsoo_listunits > > > 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. > The set of module one want to expose in a toplevel is different from the set of module needed to build the toplevel. `--export` is used to tell jsoo what module should be exported. Only module linked in the toplevel can be exported. jsoo_listunits is a small helper to build that list of module from library names. In short, what it does is: lookup {cma,cmo}s for the given libraries (using findlib) and build the list of module for theses libraries. I encourage you to open issues on github for theses questions. > 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 > --0000000000003522c9058a9d4f96 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Jun 1, 2019 at 9:00 AM Kenich= i Asai <asai@is.ocha.ac.jp>= wrote:
I could.= =C2=A0 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
=C2=A0 (names eval)
=C2=A0 (libraries
=C2=A0 =C2=A0 myFac
=C2=A0 =C2=A0 js_of_ocaml-compiler
=C2=A0 =C2=A0 js_of_ocaml-toplevel)
=C2=A0 (link_flags (:standard -linkall))
=C2=A0 (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/=C2=A0

(I wonder if I always have to write this path.=C2=A0 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.)

I would expect the path to not be necessary when pa= ssing a library name to jsoo_listunits
=C2=A0

> 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?=C2= =A0

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
=C2=A0 required in the toplevel.
- export.txt specifies which modules to be exported.

Correct me if I am wrong.=C2=A0 I still welcome any documents to study.
=

The set of module one want to expose in a = toplevel is different from the set of module needed to build the toplevel.<= /div>
`--export` is used to tell jsoo what module should be exported. O= nly module linked in the toplevel can be exported.

jsoo_listunits is a small helper to build that list of module from library= names.
In short, what it does is: lookup {cma,cmo}s for the give= n libraries (using findlib) and build the list of module for theses librari= es.

I encourage you to open issues on github=C2=A0for these= s questions.


Sincerely,

--
Kenichi Asai


On Thu, May 30, 2019 at 11:19:33PM +0900,
=C2=A0Kenichi Asai wrote:

> Thank you for the e-mail.=C2=A0 It goes great.=C2=A0 Going one step fu= rther, can
> I do the same if I install fac as an opam library?=C2=A0 Suppose I pac= kaged
> fac.ml<= /a> as a library called myFac and installed fac.cma and fac.cmi via
> opam.=C2=A0 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.=C2=A0 Is listing myFac in the above line not enough?<= br> >
> 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,
>=C2=A0 hugo wrote:
>
> > You need to tell js_of_ocaml the list of cmi that you want to exp= ort.
> > [jsoo_listunits] can compute the list of cmi from a findlib libra= ry.
> > Because fac is not installed, you'll need to be explicit.
> > There might be some better wait to integrate with dune but the fo= llowing
> > should change should do what you want.
> >
> > (rule
> >=C2=A0 (targets export.txt)
> >=C2=A0 (deps eval.bc fac/fac.cma)
> >=C2=A0 (action (run jsoo_listunits -o %{targets} stdlib fac/.fac.o= bjs/byte/fac.cmi)))
> >
> > H
> >
> >
> > On Sun, May 26, 2019 at 2:27 PM Kenichi Asai <
asai@is.ocha.ac.jp> wrote: > >
> > > I want to create a web page where I can execute an OCaml exp= ression
> > > that mentions a prebuilt user-defined library.=C2=A0 I find = the following
> > > example in the js_of_ocaml/toplevel repository:
> > >
> > > https://gith= ub.com/ocsigen/js_of_ocaml/tree/master/toplevel/examples/eval
> > >
> > > Can I extend this example so that the toplevel is compiled w= ith a
> > > user-defined library?=C2=A0 The attached program contains th= e following
> > > where the first three files are copied from the example in t= he
> > > js_of_ocaml/toplevel repository.
> > >
> > > toplevel/ -- dune
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- eval.ml
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- index.html
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-- fac/ -- dune
> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0-- fac.ml
> > >
> > > I intend that fac.ml is compiled as a library and I want to use it i= n
> > > the toplevel.=C2=A0 I added "fac" in the libraries= stanza of the toplevel
> > > dune file (as in the attached file):
> > >
> > > (executables
> > >=C2=A0 =C2=A0(names eval)
> > >=C2=A0 =C2=A0(libraries
> > >=C2=A0 =C2=A0 =C2=A0fac
> > >=C2=A0 =C2=A0 =C2=A0js_of_ocaml-compiler
> > >=C2=A0 =C2=A0 =C2=A0js_of_ocaml-toplevel)
> > >=C2=A0 =C2=A0(link_flags (:standard -linkall))
> > >=C2=A0 =C2=A0(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.=C2=A0 I included the follo= wing part in
> > > the index.html (as in the attached file):
> > >
> > > <script type=3D"text/ocaml" stdout=3D"scri= pt3" stderr=3D"script3">
> > >=C2=A0 =C2=A0Fac.go 3;;
> > > </script>
> > > <div id=3D"script3"> </div>
> > >
> > > but the output says:
> > >
> > > File "/dev/fake_stdin", line 2, characters 6-12: > > > Error: Unbound module Fac
> > >
> > > Thank you in advance.
> > >
> > > --
> > > Kenichi Asai
--0000000000003522c9058a9d4f96--