caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: hugo <hugo.heuzard@gmail.com>
To: Kenichi Asai <asai@is.ocha.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] How can I use a library in a toplevel created by js_of_ocaml?
Date: Tue, 28 May 2019 08:41:01 +0800	[thread overview]
Message-ID: <CAEYcRDH==Ej9XKUVNudG8L+ON59TrPBS9NVQJ-arj5UcJMxd0g@mail.gmail.com> (raw)
In-Reply-To: <20190526062659.GA63981@pllab.is.ocha.ac.jp>

[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]

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 <asai@is.ocha.ac.jp> 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):
>
> <script type="text/ocaml" stdout="script3" stderr="script3">
>   Fac.go 3;;
> </script>
> <div id="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
>

[-- Attachment #2: Type: text/html, Size: 3205 bytes --]

  reply	other threads:[~2019-05-28  0:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-26  6:26 Kenichi Asai
2019-05-28  0:41 ` hugo [this message]
2019-05-30 14:19   ` Kenichi Asai
2019-06-01  1:00     ` Kenichi Asai
2019-06-06  1:05       ` hugo
2019-05-27 18:34 Quaker Quickoats
2019-05-29  0:39 ` Kenichi Asai
2019-05-29 20:27   ` Quaker Quickoats
2019-05-30  0:45     ` hugo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEYcRDH==Ej9XKUVNudG8L+ON59TrPBS9NVQJ-arj5UcJMxd0g@mail.gmail.com' \
    --to=hugo.heuzard@gmail.com \
    --cc=asai@is.ocha.ac.jp \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).