Mere Wasm Playground

Note: these demos are Mere programs pre-compiled to Wasm via mere -w <file.mere>. The browser instantiates the Wasm module and runs main. A live compile-in-browser REPL (via js_of_ocaml) is a separate Phase.

Demos

For an interactive demo that wires DOM events back into Mere, see the counter page (Phase 48 C2 FFI).

Source (preview)

// Click a demo button above to view its source here.

Output

// Output appears here after the Wasm module runs.

How it works

Each demo goes through the same pipeline:

  1. mere -w demo.mere emits the WAT text format.
  2. wat2wasm assembles it into a binary .wasm.
  3. This page fetches the binary and runs WebAssembly.instantiate.
  4. The Wasm puts import is wired on the JS side to read a C-string from linear memory and append it to the output pane.

This brings the 4-backend feature parity (interp + C + LLVM + Wasm) straight into the browser: source → Wasm → live run.