Compiling Haskell to WebAssembly
summary
GHC’s WebAssembly backend compiles real Haskell apps into runnable .wasm modules, using wasmtime for CLI and a tiny npm shim for browser runs; post-link wasm-opt shrinks a raw 8.5 MB build to 3.6 MB (wasm-opt shrinks 8.5MB → 3.6MB). JavaScript FFI supports synchronous and async imports/exports, pinned byte arrays for zero-copy buffers, and foreign import javascript wrapper callbacks; a service worker SHA‑256 demo and benchmarks show serial fetch ~220 ms vs concurrent async ~133 ms (GHCI browser mode). Runtime threading and better observability are planned.
AI-written summary · about
chapters (19)
- 0:00Introduction & structure of the talk
- 1:15Lesson 1 – Don’t use frameworks
- 5:45WebAssembly basics & minimal runtime
- 10:40WASI vs JS FFI & standalone deployment
- 16:30Lesson 2 – Validate everything
- 18:32Structure of core expressions & output control
- 23:10Compilation pipeline & target representation
- 27:55Memory layout in Wasm
- 33:20Lesson 3 – Debug early
- 36:00Tools, backtraces & observability
- 40:30Lesson 4 – Avoid concurrency (for now)
- 45:20GHC runtime limitations & async model
- 49:10Haskell concurrency semantics in Wasm
- 53:00Live Demo 1 – Browser-based Haskell runtime
- 57:40Live Demo 2 – Service Worker & crypto
- 1:02:30Lesson 5 – Don’t be afraid of rewriting
- 1:06:15Benchmarks & performance notes
- 1:10:00Limitations & future directions
- 1:15:10Q&A and wrap-up








