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 interactive demos that wire DOM events back into Mere, see the counter page (Phase 48 C2 FFI) and the 2048 game, playable with the arrow keys via dom_on_key. The ray tracer renders a scene to a canvas through the pixel FFI (dom_canvas_fill_rect), and the CHIP-8 emulator runs a real-time fetch-decode-execute loop, driving the canvas from a per-frame callback (dom_on_frame).

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.