Skip to content

docs: rewrite /collections in literate style - #129

Merged
vito merged 1 commit into
mainfrom
literate-page-rewrite
Jun 13, 2026
Merged

vito merged 1 commit into
mainfrom
literate-page-rewrite

Conversation

@vito

@vito vito commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Docs feedback

A reader asked: "What page would benefit most from being rewritten in literate programming style like blocks, control flow and errors? Do that one."

The pick: /collections

Surveying the docs, /collections was the standout candidate. It was the largest page with zero runnable examples, yet it's entirely about operations that produce concrete results — exactly what the live, shared-environment literate format (already on /blocks, /control-flow, /errors) is built to show. It's also cross-referenced as [#collections] from all three literate pages, so it now reads like its neighbors instead of a flat API dump.

/strings's Meta note explicitly says not to be exhaustive, and /nullability's flow-narrowing is a compile-time property that runtime results don't illustrate well — so neither fit as cleanly.

The change

  • Adds \literate-fences and converts the bullet-list API reference into prose alternating with runnable dang blocks.
  • The blocks share one environment: fruits, nums, and roles are bound once and reused notebook-style down the page.
  • Every result is baked in and build-verified. Three dang-failure blocks pin the constraints worth showing: a non-Int list index, a map's homogeneous value type, and a list with no common element type.
  • Coverage is preserved (construct / index / transform / iterate / predicates / slice / join for lists; build / lookup / derive / transform for maps; the nullability matrix and heterogeneous-element inference).
  • Both > Meta: notes are preserved verbatim.

Verified by replaying the exact block sequence through the docs build's own literateEval/literateFailEval path, and by a full ./docs/build.sh booklit render (collections.html builds clean with all values baked in). Snippets are dang fmt-clean.

🤖 Generated with Claude Code

The collections page was the strongest candidate for the literate
treatment already applied to /blocks, /control-flow, and /errors: it was
the largest page with zero runnable examples, yet every list and map
operation produces a concrete result that the live-environment format is
built to show. It is also cross-referenced as [#collections] from all
three literate pages, so it now reads like its neighbors.

Adds \literate-fences and converts the flat API bullet lists into prose
alternating with runnable dang blocks that share one environment — fruits,
nums, and roles are bound once and reused notebook-style. Each result is
baked in and build-verified, including three dang-failure blocks that
pin the constraints worth showing: a non-Int list index, a map's
homogeneous value type, and elements with no common type. Both Meta notes
are preserved verbatim.

Signed-off-by: Alex Suraci <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying dang with  Cloudflare Pages  Cloudflare Pages

Latest commit: 11d13ac
Status: ✅  Deploy successful!
Preview URL: https://70e89e61.dang-3kk.pages.dev
Branch Preview URL: https://literate-page-rewrite.dang-3kk.pages.dev

View logs

@vito
vito merged commit 529d283 into main Jun 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant