OCaml, FFI, and WASM

  1. I know it is possible to do OCaml <-> C FFI

  2. I know it is possible to run OCaml as a REPL in JS.

====

Question: is there any sample code which shows how to:

  • let libFoo be some FFI (C, C++, Rust) library with OCaml bindings

  • libFoo can be compiled to WASM32

  • I want us to have an OCaml REPL running inside the browser that can also interface with libFoo (compiled to WASM).

====

In theory, we can just “combine the two parts” and it should work. In practice, there are lots of unexpected emscriptsen/wasm32 issues, and I’m wondering if someone has a minimal working example for this.

Thanks!

1 Like