Play around with Ormolu in the browser via the GHC WASM backend!
We use the Miso framework together with jsaddle-wasm. Most of the code is in src/Ormolu/Live.hs. The WASM module is run in a web worker to avoid UI stuttering when formatting larger code chunks.
Additionally, we depend on a few packages via npm for JS and CSS, see package.json.
Finally, everything is brought together in www/{index,worker}.js.
Make sure to be in the .#ormoluLive Nix shell when entering ./ormolu-live, e.g. conveniently via nix-direnv.
Install the npm dependencies:
npm installIf necessary, update the index state:
wasm32-wasi-cabal updateIf you only want to get fast feedback on compilation failures, use
ghcid -c 'wasm32-wasi-cabal repl'If you actually want to interact with the site in a browser, run sth like
watchexec -w src -w app -w ormolu-live.cabal ./build.shand serve the resulting build products via
miniserve distand view the site at http://127.0.0.1:8080/index.html.
npm ci
wasm32-wasi-cabal update
./build.sh prodThe self-contained site is now in dist.