which Core packages are js_of_ocaml compatible

119 views
Skip to first unread message

Ashish Agarwal

unread,
Dec 10, 2016, 4:22:04 PM12/10/16
to ocaml...@googlegroups.com
I know Base is meant to be js_of_ocaml compatible, but I'm wondering what other packages also are? Sexplib seems to work fine, but ppx_sexp_conv gives me:

There are some missing primitives
Dummy implementations (raising 'Failure' exception) will be used if they are not available at runtime.
You can prevent the generation of dummy implementations with the commandline option '--disable genprim'
Missing primitives provided by +toplevel.js:
  caml_terminfo_setup

Is this intentional? It's unfortunate if we can use sexplib but not automatically derive the converters.

Yaron Minsky

unread,
Dec 10, 2016, 5:13:05 PM12/10/16
to ocaml...@googlegroups.com, Hugo Heuzard
core_kernel is intended to be js_of_ocaml compatible, so sexplib
should be too. I'm not sure what problem you're running into
specifically here. Maybe the right stubs aren't being included? I know
Hugo has been making some changes to how stubs are distributed.

Also, there's a new sexp-parser library called parsexp which will be
released soon that is less likely than the sexplib parser to blow the
stack.

Things labeled "_kernel" should generally run in Javascript, so
Core_kernel, Async_kernel, Async_rpc_kernel and Incremental_kernel are
all Javascript ready.

y
> --
> You received this message because you are subscribed to the Google Groups
> "ocaml-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ocaml-core+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Hugo Heuzard

unread,
Dec 11, 2016, 3:01:05 AM12/11/16
to Yaron Minsky, ocaml...@googlegroups.com
Here is a list of library [1] and ppx [2] that are marked as being compatible with JavaScript.
It's possible that a compatible version has not yet been released on github.

It seems that you're building an executable that embed ppx_sexp_conv (and transitively ocamlbytecomp).

Are you trying to build some kind of toplevel running in JavaScript ?
If yes, you need to provide additional flags to js_of_ocaml (+toplevel.js +dynlink.js)
If no, having ppx_sexp_conv linked in is probably an error.

HH

[1] 
async_js
async_kernel
async_rpc_kernel
base
bin_prot
core_kernel
fieldslib
incr_dom
incremental_kernel
incr_map
incr_select
parsexp
parsexp_io
sexplib
splay_tree
stdio
typerep_lib
variantslib
virtual_dom

[2]
ppx_assert
ppx_bench
ppx_core
ppx_driver
ppx_expect
ppx_hash
ppx_inline_test
ppx_optcomp
ppx_sexp_conv
ppx_type_conv


Ashish Agarwal

unread,
Dec 12, 2016, 10:18:23 AM12/12/16
to ocaml...@googlegroups.com, Yaron Minsky
A minimal example:

Create an empty file a.ml.

Compile it:
$ ocamlfind ocamlc -package ppx_sexp_conv -linkpkg -o a.byte a.ml

$ js_of_ocaml -o a.js a.byte
There are some missing primitives
Dummy implementations (raising 'Failure' exception) will be used if they are not available at runtime.
You can prevent the generation of dummy implementations with the commandline option '--disable genprim'
Missing primitives provided by +toplevel.js:
  caml_terminfo_setup
Missing primitives provided by +weak.js:
  caml_weak_create
  caml_weak_get
  caml_weak_set

If you load the js file in a web page anyway, you'll see corresponding JavaScript runtime errors.

If you remove ppx_sexp_conv, then there are no errors. Am I compiling wrong? Should I avoid -linkpkg, but I would need to link in packages I'm actually using.


Ashish Agarwal

unread,
Dec 12, 2016, 10:23:21 AM12/12/16
to ocaml...@googlegroups.com, Yaron Minsky
I think ocamlfind's `-dontlink <pkg>` option might be what I need. So I can pass `-linkpkg`, and then `-dontlink ppx_sexp_conv`.

Jeremie Dimino

unread,
Dec 12, 2016, 11:38:35 AM12/12/16
to ocaml...@googlegroups.com, Yaron Minsky
The META for ppx_sexp_conv should be setup so that ppx_sexp_conv.cma
is not linked in unless you pass [-predicates ppx_driver]. So I'm not
sure what's going on.

It's a bit unfortunate that we specify normal packages and ppx
packages side by side, it makes everything so much more complicated...
>>>> > email to ocaml-core+...@googlegroups.com.
>>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "ocaml-core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to ocaml-core+...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ocaml-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ocaml-core+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Jeremie

hheu...@janestreet.com

unread,
Dec 12, 2016, 11:29:24 PM12/12/16
to ocaml-core, ymi...@janestreet.com
The issue seems to be with "ppx_core.for_ppx_deriving"
removing "compiler-libs.common" from "requires" fixes the issue for me. 

Jeremie Dimino

unread,
Dec 13, 2016, 4:19:09 AM12/13/16
to ocaml...@googlegroups.com, Yaron Minsky
Ok, these .for_ppx_deriving things where a terrible hack anyway. They
have all been removed since ppx_deriving learned how to load findlib
packages.

Jeremie Dimino

unread,
Dec 14, 2016, 1:07:31 PM12/14/16
to ocaml...@googlegroups.com, Yaron Minsky
I think I found the problem, the META for ppx_sexp_conv should say:

requires(ppx_driver) = "..."

instead of:

requires = "..."

Could you try to edit ppx_sexp_conv's META file to check that it fixes
the issue?
--
Jeremie

Ashish Agarwal

unread,
Dec 14, 2016, 3:28:01 PM12/14/16
to ocaml...@googlegroups.com, Yaron Minsky
Seems my META file is different. I have ppx_sexp_conv 113.33.01+4.03, and the META file looks like this:

version = "113.33.01+4.03"
description = "Generation of S-expression conversion functions from type definitions"
requires(-ppx_driver) = "ppx_core.for_ppx_deriving ppx_sexp_conv.expander.for_ppx_deriving ppx_type_conv.for_ppx_deriving sexplib"
requires(ppx_driver) = "ppx_core ppx_sexp_conv.expander ppx_type_conv"
archive(ppx_driver, byte          ) = "ppx_sexp_conv.cma"
archive(ppx_driver, native        ) = "ppx_sexp_conv.cmxa"
archive(ppx_driver, native, plugin) = "ppx_sexp_conv.cmxs"
exists_if = "ppx_sexp_conv.cma"
ppxopt(-ppx_driver) = "ppx_deriving,./ppx_sexp_conv.cma"

package "expander" (
...
)



>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Jeremie



--
Jeremie

--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+unsubscribe@googlegroups.com.

Ashish Agarwal

unread,
Dec 14, 2016, 3:32:26 PM12/14/16
to ocaml...@googlegroups.com, Yaron Minsky
Maybe you meant for the sub-packages that I elided. Both .expander and .expander.for_ppx_deriving do have a line like `requires = "..."`. I added (ppx_driver) in both places, and in each one at a time. Same behavior in all cases.

Jeremie Dimino

unread,
Dec 15, 2016, 4:48:07 AM12/15/16
to ocaml...@googlegroups.com, Yaron Minsky
This META style was from when ppx_deriving didn't support loading
findlib packages. The +4.03 packages haven't been updated to the new
method.

Looking at these packages, the problem should be this line in
ppx_core.for_ppx_deriving:

requires = "compiler-libs.common ppx_deriving"

removing the compiler-libs.common should fix the problem

Ashish Agarwal

unread,
Dec 15, 2016, 10:17:15 AM12/15/16
to ocaml...@googlegroups.com, Yaron Minsky
My META file for 113.33.01+4.03 doesn't mention compiler-libs.common.


>>> >> For more options, visit https://groups.google.com/d/optout.
>>> >
>>> >
>>> >
>>> > --
>>> > Jeremie
>>>
>>>
>>>
>>> --
>>> Jeremie
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "ocaml-core" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an

>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ocaml-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.



--
Jeremie

--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages