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.

#CategoryTitleSlugStatusNeeds
1HTMLHellohelloHtml.text only (static)
2HTMLGroceriesgroceriesHtml elements (static)
3HTMLShapesshapesSvg (static)
4User InputButtonsbuttonsBrowser.sandbox, onClick, update
5User InputText Fieldstext-fieldsBrowser.sandbox, onInput, String fns
6User InputFormsformsBrowser.sandbox, multiple fields, styles
7RandomNumbersnumbersBrowser.element, Cmd, Random
8RandomCardscardsRandom, custom types
9RandomPositionspositionsRandom.map2, Svg
10HTTPBookbookBrowser.element, Http.get, text (stubbed response)
11HTTPQuotesquotesHttp, Json.Decode (map4/field/int/string)
12TimeTimetimeBrowser.element, Time, subscriptions, Task
13TimeClockclockTime, Svg, subscriptions
14FilesUploaduploadFile input + decoder; driven with stub files
15FilesDrag-and-Dropdrag-and-dropFile.Select + hover state; stub files
16FilesImage Previewsimage-previewsFile.toUrl + Task.sequence → data URLs
17WebGLTriangletriangle✅*runs; builds mesh/matrices, emits <canvas>
18WebGLCubecube✅*webgl, Mat4 transforms
19WebGLCratecrate✅*webgl + stub texture (Task.attempt)
20WebGLThwompthwomp✅*webgl, two textures, viewport
21WebGLFirst Personfirst-person✅*webgl, keyboard, toHtmlWith
22PlaygroundPicturepicturereal evancz/elm-playground loaded via module system, rendered to SVG
23PlaygroundAnimationanimationelm-playground; renders initial frame (octagons + bar)
24PlaygroundMousemouseelm-playground game; initial frame
25PlaygroundKeyboardkeyboardelm-playground game; initial frame
26PlaygroundTurtleturtleelm-playground game + image
27PlaygroundMariomarioelm-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:

Backends

  1. JIT interpreter — Truffle language (TruffleLanguage, self-specializing AST nodes). On GraalVM the Graal compiler partial-evaluates hot nodes, giving a real JIT.
  2. 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.
  3. Compiler to bytecode — Truffle Bytecode DSL interpreter (GraalVM bytecode generator).

Notes on feasibility

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:

DemoRun withDemonstratesGuide
WordCountelm script WordCount <files…>A wc-style CLI script (stdin/files/args/exit code).scripting.md
FolderReportelm 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
BigFileselm script BigFiles [threshold] [dir]Lists files over a line threshold (default 1000), largest first — find + wc over a directory.scripting.md
AwkSumelm script AwkSum <col> <file>Composes an awk program with the Awk builder (sum a column).scripting.md
CsvReportelm script CsvReport <file.csv>Parses CSV with the Csv library and renders it to an HTML table via Site.scripting.md
M4Expandelm script M4Expand <name>Generates an m4 macro program with the M4 builder.scripting.md
SimpleServerShowcaseelm server SimpleServerShowcaseA stateless HTTP app: routing on path/query, text/html/json.server.md
LiveDashboardelm server LiveDashboardA stateful server: in-memory time series, a timer-driven random walk, and a self-updating SVG chart polled by the client.server.md
editoropen editor.html in the galleryAn 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.