20 short lessons. Each one explains a concept, then asks you to write real OCaml and checks it against a real compiler — not a string match.
Try it → ocamllearn.vercel.app — nothing to install, runs in your browser.
Two implementations, same lesson content:
web/— React SPA. OCaml runs entirely in your browser (a js_of_ocaml toplevel), no backend, no signup. Deep-linkable lessons, works on mobile.ocamllearn/— Textual TUI. Runs your code through a localopam/ocamlinstall.
Lesson content lives once, in lessons/ (Markdown + TOML), and
is shared by both.
Web:
cd web
npm install
npm run devTerminal:
opam init -y # once, if you don't have an OCaml switch yet
uv run ocamllearnValues, functions, pattern matching, lists, recursion, higher-order
functions, options, results/exceptions, records, variants, polymorphism,
labeled arguments, mutability, loops/arrays, Printf, modules.
Each exercise pairs your code with a hidden test snippet that calls it and
prints PASS/FAIL per assertion. Both implementations compile and run
that combined snippet with the real OCaml toolchain, then parse the output
— so a wrong answer gets a real type error or a real failing assertion,
not a canned response.
Add a lessons/NN-slug/lesson.md + exercises.toml pair (see any existing
lesson for the format), then run scripts/export_lessons.py to regenerate
web/src/lessons.json.
