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 ESMTPS id AE24E5D5 for ; Tue, 28 May 2019 00:41:23 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,520,1549926000"; d="scan'208,217";a="384952767" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 28 May 2019 02:41:22 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 9906F826E4; Tue, 28 May 2019 02:41:22 +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 A996F7ED69 for ; Tue, 28 May 2019 02:41:15 +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-vs1-f68.google.com IronPort-PHdr: =?us-ascii?q?9a23=3AreA59BYDY04XLG8HI9ETcFH/LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZr82ybnLW6fgltlLVR4KTs6sC17OP9fm6BSdbv96oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVr?= =?us-ascii?q?O+/7BpDdj9it1+C15pbffxhEiCCybL9vMRm6txjdutcZjIdtJKs8ywbCr2dVde?= =?us-ascii?q?hR2W5mP0+YkQzm5se38p5j8iBQtOwk+sVdT6j0fLk2QKJBAjg+PG87+MPktR/Y?= =?us-ascii?q?TQuS/XQcSXkZkgBJAwfe8h73WIr6vzbguep83CmaOtD2TawxVD+/4apnVAPkhS?= =?us-ascii?q?EaPDMi7mrZltJ/g75aoBK5phxw3YjUYJ2ONPFjeq/RZM4WSXZdUspUUSFKH4Gy?= =?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ronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BjAQCLguxcf0TZVdFlDhABBgcGgVQGC?= =?us-ascii?q?wGCNwFBUTMohBOBHYJejxOCDYpGiBWHeQkBAwEMJQoBAYN6RgKCVhsHAQQzBg4?= =?us-ascii?q?BAwEBBAEBAgEBAwETAQEJCwsIJyUMgjopAYJnAQQBIx0BGx0BAwELBgMCCzcCA?= =?us-ascii?q?iIBEQEFARwGE4MjgWkBAw4PD4wdkA48iyCBEgUBF4J6BYQyChknDWCBOgIHDQI?= =?us-ascii?q?DgSKLU4IWg3UuPoJhAoIOgl2CWASLH4h8hnWNQwcCgg+BZAGET4xhG4MGk0Mtk?= =?us-ascii?q?0OPDw8hgUSBeXBQMYI7CYIGg3CEIIV4SDUwjxYBAQ?= X-IPAS-Result: =?us-ascii?q?A0BjAQCLguxcf0TZVdFlDhABBgcGgVQGCwGCNwFBUTMohBO?= =?us-ascii?q?BHYJejxOCDYpGiBWHeQkBAwEMJQoBAYN6RgKCVhsHAQQzBg4BAwEBBAEBAgEBA?= =?us-ascii?q?wETAQEJCwsIJyUMgjopAYJnAQQBIx0BGx0BAwELBgMCCzcCAiIBEQEFARwGE4M?= =?us-ascii?q?jgWkBAw4PD4wdkA48iyCBEgUBF4J6BYQyChknDWCBOgIHDQIDgSKLU4IWg3UuP?= =?us-ascii?q?oJhAoIOgl2CWASLH4h8hnWNQwcCgg+BZAGET4xhG4MGk0Mtk0OPDw8hgUSBeXB?= =?us-ascii?q?QMYI7CYIGg3CEIIV4SDUwjxYBAQ?= X-IronPort-AV: E=Sophos;i="5.60,520,1549926000"; d="scan'208,217";a="384952751" X-MGA-submission: =?us-ascii?q?MDEuYzXnb3knCVFm3uGiGhHANEfvRn4ezWKsUK?= =?us-ascii?q?g2xGRaZArcBZOKhGB9vKcnhpazjDkKAuaYtMUSWRsoCRY8drAykh943W?= =?us-ascii?q?pBW0IE0/FHDx9hKLWx3/Vm5sWja6lqiczUdi+Vpb62VAZp992s6loKK/?= =?us-ascii?q?U3OP+V7v8vzzKys/IUXWTStw=3D=3D?= Received: from mail-vs1-f68.google.com ([209.85.217.68]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 28 May 2019 02:41:14 +0200 Received: by mail-vs1-f68.google.com with SMTP id q13so11690459vso.2 for ; Mon, 27 May 2019 17:41:14 -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=vByK4LqEe9QwVkgRZn25NUXOpRjuK28wR+u04++9/6Q=; b=LTFWl1xxIvnWrGZL56OHTkSUacVtoqs6pkqaoGGcA3w07MM5tK5KBS+zVinhXHV0fa Syor2sIJbvrIoq0UYvkKopHAgMzpdzdDuR1vTArg9Kbo9rsWxfG5jvxmSCf/94gVODRG YavBaKRoKVFBHlY9s1uLfWRVyy6MomQrHahng9iLg5XEoAAFgVlhL4GuK9/TlHxa+Pdo XmZ4gXZlE5hciQjdHXJsyMlnh8Doc+m3IpP9URiN5c01q/sucQM2vspnEk5aRMM+TfLF iOtI6BU+Bu0NHSJWNsDdzQDrst3jArf7lgZW+CgqLYfTniKscRtmq/SwfYi2PK/NHzZy uwrQ== 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=vByK4LqEe9QwVkgRZn25NUXOpRjuK28wR+u04++9/6Q=; b=uiMHUD8f5KSkzvrGmLmw3mWBANsz4WqeElc8pNjLBxNKNbJBxTbo6y/c1swm/v8WJu q+I+e04HecXcMIeX88eXHMw2BC0fffngt4hRCejhsuyRdSRPsk76vcjaPrXoOzAdUpje FJlgo4Hd8ORXmbHiD8WRncNhbzJ3hZB3Ge5fOgBQr2U+zbk/3ZsDG+BoKvpCb4D2k5Ok fcJB50W/YR53Yt26S1U067UfNupkNLrhbnenLiaJx7HW/2J1xF9YSFaT3XdxjJcf0/ZO xDpmhDv0u28upAiDDXvL4onr0WjwGOBEm8HTmNtOv52pfG0ngivNXTOxf7w8lwa3E4y1 CIeg== X-Gm-Message-State: APjAAAXpJBMHuqZ6G0ApnFCcxbtSxIZcbSk3Xk0xDAfVAhV4YftLCfir /Mc7GdlcIztJtTaGswCkyNH1cWktCQvwmufwX7d9lM9Hlwi1sQ== X-Google-Smtp-Source: APXvYqxybhc5t/sffli4TGmpdAad1x0n8ZuFXVDB1DKuTySYSUePr1Na1IjwSr0vq3Zvm9N/yqcRpvmr8vQbYxaYu8Q= X-Received: by 2002:a67:6c47:: with SMTP id h68mr58579399vsc.123.1559004072944; Mon, 27 May 2019 17:41:12 -0700 (PDT) MIME-Version: 1.0 References: <20190526062659.GA63981@pllab.is.ocha.ac.jp> In-Reply-To: <20190526062659.GA63981@pllab.is.ocha.ac.jp> From: hugo Date: Tue, 28 May 2019 08:41:01 +0800 Message-ID: To: Kenichi Asai Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary="000000000000f8eed20589e7eb84" 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: 17578 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: --000000000000f8eed20589e7eb84 Content-Type: text/plain; charset="UTF-8" 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 > --000000000000f8eed20589e7eb84 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You need to tell js_of_ocaml the list of = cmi that you want to export.
[jsoo_listunits] can com= pute the list of cmi from a findlib library.
Because fac is n= ot 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
=C2=A0(targets export.txt)
=C2=A0(deps eval.bc = fac/fac.cma)
=C2=A0(action (run jsoo_listunits -o %{target= s} stdlib fac/.fac.objs/byte/fac.cmi)))

H


On Sun, May 26, 2019 at 2:27 PM Kenichi Asai= <asai@is.ocha.ac.jp> wrote= :
I want to crea= te a web page where I can execute an OCaml expression
that mentions a prebuilt user-defined library.=C2=A0 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?=C2=A0 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
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- eval.ml
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- index.html
=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 -- fac.ml

I intend that fac.ml is compiled as a library and I want to use it in
the toplevel.=C2=A0 I added "fac" in the libraries stanza of the = toplevel
dune file (as in the attached file):

(executables
=C2=A0 (names eval)
=C2=A0 (libraries
=C2=A0 =C2=A0 fac
=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)))

Naturally, f= ac.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 following part in the index.html (as in the attached file):

<script type=3D"text/ocaml" stdout=3D"script3" stder= r=3D"script3">
=C2=A0 Fac.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
--000000000000f8eed20589e7eb84--