The Browser REPL
Write, check, and run Tyu in your browser — no install. The book's labs, preloaded.
Audience: anyone who wants to try Tyu right now. Purpose: use the browser REPL and find each book lab in it. Prerequisites: a browser tab. Nothing else — no toolchain, no account, no network after the page loads.
Open the REPL — or reach it any time from the site header.
# What it is
The REPL is the language running in your tab, shipped with this site and
served from /repl/. It is fully static and self-contained: every artifact
it loads is same-origin and SHA-256-pinned, and the page refuses to boot a
mismatched artifact. No servers, no post-boot network.
- Editor — CodeMirror 6 with a first-party Tyu grammar (syntax highlighting, bracket matching). Falls back to a plain textarea if the editor bundle fails its integrity check; the page never blanks.
- Two execution backends — the interpreter (default) and the
wasm32backend (the compiler’s own WebAssembly code generator). The active substrate is always visible in the header. - The checker, not a suggestion box — same diagnostics as
langc: red labs are rejected with their exact error codes. - A debug console — call frames, post-mortem backtrace with
click-to-source, an
--emit=irpane, and a per-submission transcript. - The book’s labs as one-click examples — 53 runnable and 24 native-only, classified from the labs’ own expected verdicts; a red lab teaches “the checker explains itself”, a green lab teaches “the checker accepts”.
Run submits the whole buffer (Ctrl+Enter); submit feeds the live session (Ctrl+Shift+Enter); step resumes a fuel-suspended phrase (Ctrl+.).
# The labs, chapter by chapter
Deep links open the REPL with the lab loaded:
/repl/#example=chNN/<lab-name>. The lab names match
docs/book/labs/
(and the mirror under /book/labs/
on this site).
Green labs compile clean in the browser session; red labs are rejected with
the documented error code. Labs marked native-only cannot run in the
browser — module submissions compile (imports are signature-only), so a
lab’s main cannot be invoked and run-time traps need the native
toolchain; the REPL says why for each such lab.
| Chapter | Try in the REPL |
|---|---|
| 1 — The Rigor Is the Engine | green-01-hello , green-02-promise-kept , red-01-main-no-exit |
| 2 — First Words | green-01-arithmetic-check , green-03-while-counter , red-01-underflow |
| 3 — Types | green-01-enums , red-02-bitcast-width |
| 4 — Contracts | green-02-ensures , red-01-flat-sandwich |
| 5 — Effects and Capabilities | green-01-alloc-effect , red-01-undeclared-effect |
| 6 — The Stack Has a Shape | green-01-stack-shapes , red-02-while-grows |
| 7 — Places, Borrowing, Ownership | labs ch07 — open in the REPL’s example list |
| 8 — Touching Hardware: MMIO | labs ch08 — native-only (MMIO) |
| 9 — Factoring | labs ch09 |
| 10 — Decomposition | labs ch10 — includes module labs |
| 11 — Shared State and Interrupts | labs ch11 — native-only (ISRs) |
| 12 — Tasks and Channels | labs ch12 |
| 13 — Field Updates on Untrusted Media | labs ch13 |
| 14 — Proving the Program | labs ch14 — the proof pipeline runs natively |
The REPL’s own example list (in the page) is the complete, classified corpus; this table is just the front door.
# Running it locally
The REPL is built from the repository, and this site vendors the built artifacts:
# from a tyu checkout — build the artifact set into web/
bash ci/wasm.sh build-web
cd web && python3 -m http.server 8080 # → http://localhost:8080This site’s copy lives at /repl/
and is refreshed from the
pinned upstream/tyu submodule with scripts/sync-web.sh — see the
repository README
for the toolchain
details (Node ≥ 20, wasm-bindgen-cli 0.2.108, brotli).