Examples
This page tracks the examples this implementation targets. The compatibility goal is that every example on <https://elm-lang.org/examples> works across the applicable backends; beyond that catalogue, the project ships its own larger apps and command-line/server demos (listed at the bottom). Slugs are the path under /examples/<slug>. The "Needs" column tracks the runtime capability each example requires, which drives implementation order.
Status: ✅ = working & tested headlessly (interpreter/bytecode), ⏳ = not yet.
| # | Category | Title | Slug | Status | Needs |
|---|---|---|---|---|---|
| 1 | HTML | Hello | hello | ✅ | Html.text only (static) |
| 2 | HTML | Groceries | groceries | ✅ | Html elements (static) |
| 3 | HTML | Shapes | shapes | ✅ | Svg (static) |
| 4 | User Input | Buttons | buttons | ✅ | Browser.sandbox, onClick, update |
| 5 | User Input | Text Fields | text-fields | ✅ | Browser.sandbox, onInput, String fns |
| 6 | User Input | Forms | forms | ✅ | Browser.sandbox, multiple fields, styles |
| 7 | Random | Numbers | numbers | ✅ | Browser.element, Cmd, Random |
| 8 | Random | Cards | cards | ✅ | Random, custom types |
| 9 | Random | Positions | positions | ✅ | Random.map2, Svg |
| 10 | HTTP | Book | book | ✅ | Browser.element, Http.get, text (stubbed response) |
| 11 | HTTP | Quotes | quotes | ✅ | Http, Json.Decode (map4/field/int/string) |
| 12 | Time | Time | time | ✅ | Browser.element, Time, subscriptions, Task |
| 13 | Time | Clock | clock | ✅ | Time, Svg, subscriptions |
| 14 | Files | Upload | upload | ✅ | File input + decoder; driven with stub files |
| 15 | Files | Drag-and-Drop | drag-and-drop | ✅ | File.Select + hover state; stub files |
| 16 | Files | Image Previews | image-previews | ✅ | File.toUrl + Task.sequence → data URLs |
| 17 | WebGL | Triangle | triangle | ✅* | runs; builds mesh/matrices, emits <canvas> |
| 18 | WebGL | Cube | cube | ✅* | webgl, Mat4 transforms |
| 19 | WebGL | Crate | crate | ✅* | webgl + stub texture (Task.attempt) |
| 20 | WebGL | Thwomp | thwomp | ✅* | webgl, two textures, viewport |
| 21 | WebGL | First Person | first-person | ✅* | webgl, keyboard, toHtmlWith |
| 22 | Playground | Picture | picture | ✅ | real evancz/elm-playground loaded via module system, rendered to SVG |
| 23 | Playground | Animation | animation | ✅ | elm-playground; renders initial frame (octagons + bar) |
| 24 | Playground | Mouse | mouse | ✅ | elm-playground game; initial frame |
| 25 | Playground | Keyboard | keyboard | ✅ | elm-playground game; initial frame |
| 26 | Playground | Turtle | turtle | ✅ | elm-playground game + image |
| 27 | Playground | Mario | mario | ✅ | elm-playground game + sprite image |
✅* = the program runs and produces the scene (meshes, matrices, entities) and a <canvas> element, verified headlessly. Actual rasterized pixels require a real GPU/WebGL context, which a headless JVM cannot provide.
Gallery (compiled JavaScript)
The static gallery at <https://tunguski.github.io/elm-lang/> presents the JS-compiled output of each example, generated by SiteGenerator and published by the Pages workflow. 20 of the 27 run as live compiled JavaScript in the browser; the multi-module Playground games (22–27) and the keyboard-driven First Person (21) currently fall back to an interpreter-rendered initial frame.
Beyond the catalogue
The gallery also showcases larger, hand-written apps that exercise the backends end to end:
- RTS Mini — a small but functional real-time strategy game (its own project+repo: github.com/tunguski/elm-rts, checked out under
projects/elm-rts): build buildings, train units, gather resources (a worker walks a BFS path around water/rock to a mine, hauls loads back to base and deposits them) and uncover the whole map to win. It's cleanly split intoRTS.Model/RTS.Logic/RTS.View/RTS.Main, with an optionalRTS.BackendHTTP handler that shares the model. The page is the JS-compiled game running entirely in your browser — no server needed. - TodoMVC — the flagship TEA app.
- Elm-in-Elm editor — an Elm interpreter written in Elm, with live evaluation and syntax highlighting. Its own project+repo (github.com/tunguski/elm-editor, checked out under
projects/elm-editor); the gallery builds it from there when present.
Backends
- JIT interpreter — Truffle language (
TruffleLanguage, self-specializing AST nodes). On GraalVM the Graal compiler partial-evaluates hot nodes, giving a real JIT. - Compiler to JavaScript — textual JS codegen plus a small kernel runtime, mirroring the approach of the official Elm compiler. This is the path that can realistically run the browser/WebGL/Playground examples.
- Compiler to bytecode — Truffle Bytecode DSL interpreter (GraalVM bytecode generator).
Notes on feasibility
- Examples 1–16 are achievable headless: pure rendering and The Elm Architecture (TEA) with Cmd/Sub/Http/Time/File effects, verified by driving update/view and inspecting the resulting virtual DOM (interpreter/bytecode) or generated JS run under Node with a DOM shim.
- Examples 17–21 (WebGL) and 22–27 (Playground) depend on external Elm packages (
elm-explorations/webgl,evancz/elm-playground) and a real rendering surface; these are tackled last and primarily via the JS backend.
Beyond elm-lang.org
The browser examples above are the compatibility target, but this implementation also runs Elm *outside* the browser. These bundled demos exercise the non-browser backends and have their own guides:
| Demo | Run with | Demonstrates | Guide |
|---|---|---|---|
WordCount | elm script WordCount <files…> | A wc-style CLI script (stdin/files/args/exit code). | scripting.md |
FolderReport | elm script FolderReport <dir> | Recursively walks a directory and summarises it (counts, total size, largest files, by extension) using the structured Bash/Posix find. | scripting.md |
BigFiles | elm script BigFiles [threshold] [dir] | Lists files over a line threshold (default 1000), largest first — find + wc over a directory. | scripting.md |
AwkSum | elm script AwkSum <col> <file> | Composes an awk program with the Awk builder (sum a column). | scripting.md |
CsvReport | elm script CsvReport <file.csv> | Parses CSV with the Csv library and renders it to an HTML table via Site. | scripting.md |
M4Expand | elm script M4Expand <name> | Generates an m4 macro program with the M4 builder. | scripting.md |
SimpleServerShowcase | elm server SimpleServerShowcase | A stateless HTTP app: routing on path/query, text/html/json. | server.md |
LiveDashboard | elm server LiveDashboard | A stateful server: in-memory time series, a timer-driven random walk, and a self-updating SVG chart polled by the client. | server.md |
| editor | open editor.html in the gallery | An in-browser, multi-file Elm playground with a from-scratch Elm interpreter and a time-travel debugger. | — |
A bundled demo name (e.g. WordCount, LiveDashboard) resolves to the shipped resource; you can also pass a path to your own .elm file.