Skip to content

Interactive Docs

dk's documentation and tests are themselves unified scripts (see the Unified Scripts guide). The .ml.u flavor embeds an OCaml REPL. The REPL works in the browser or on your computer; the cells below are the REPL running in a browser.

For dk you'll usually write Lua and value shell unified scripts (dk.u, dist-*/run.u) rather than .ml.u. This guide is for advanced users who want to build their own interactive documentation sites using dk-based tooling.

These cells run in your browser through an OCaml toplevel compiled to JavaScript with js_of_ocaml. Edit any block and press Run (or Ctrl/Cmd+Enter). The toplevel keeps state between blocks so later cells can use earlier definitions.

let _ = 2 + 4
let rec fact n = if n <= 1 then 1 else n * fact (n - 1)
fact 5
List.map (fun x -> x * x) [ 1; 2; 3; 4; 5 ]