Skip to content

Expand effects and capabilities documentation - #557

Merged
godofecht merged 5 commits into
mainfrom
agent/effects-capabilities-examples
Aug 18, 2026
Merged

godofecht merged 5 commits into
mainfrom
agent/effects-capabilities-examples

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

What changed

Expands the effects documentation into a practical cookbook and makes it much easier to discover from the main wiki.

  • turns docs/effects-showcase.md into the canonical effects/capabilities cookbook with 24 concrete patterns
  • adds direct coverage for handler swaps, nested dynamic scope, multi-effect capabilities, composed handlers, hybrid production/test stacks, effect rows, strict effects, dependency injection, configuration, explicit-state policies, timeout, retry, and async
  • keeps the cookbook grounded in the existing runnable programs under examples/effects/
  • adds a prominent Effects & Capabilities CTA and jump table to docs/wiki-home.md
  • corrects docs/tutorials/effects-basics.md, removing the stale pseudo syntax using perform, inline handlers, and resume() and replacing it with the compiler's current Effect.op(...), named capability, and handle ... with ... syntax

Why

Effects are one of Flow's headline language features, but the examples were fragmented and the main wiki only exposed a single checkout showcase. The new structure gives readers a small-to-large path and makes common use cases directly findable from the wiki homepage.

Validation

The branch is docs-only and is based directly on current main. All code snippets use syntax already present in the repository's current effect examples and documentation. Existing runnable examples remain the source of truth for executable demonstrations.

godofecht and others added 5 commits August 18, 2026 21:12
…re shape

The doc-examples gate failed this branch with 22 unverified blocks. Fixing
them turned up two real errors in the new documentation and one gap in the
checker.

Documentation errors:

  - Section 17 hands `handle Config with EnvConfig` and `with TestConfig`,
    and the page declares neither capability. The section's whole point is
    that one function runs against either, which cannot be shown without
    them, so both are now declared.
  - Section 18 was written in the tutorial's vocabulary: a handler for
    `effect Logger`, which this page never introduces, calling `create_user`,
    which does not exist here. It now uses the page's own `Log` effect and
    `place_order`.

Checker gap: a block that declares something and then uses it fit no rung.
`handle` is not legal at top level, so the standalone attempt failed; a
`capability` is not legal inside a function, so wrapping the whole block in a
main failed too. That shape is the commonest one in this documentation. The
new `split-wrap` rung cuts the block at the first top-level line that does
not open a declaration, keeps the declarations where they are, and wraps only
the trailing statements. It verifies 13 blocks across the corpus, 3 of them
here, and the effects pages needed 20 preamble tags before it and need 1
after.

Where a preamble is still needed there are three tiers per page, narrowest
first, because most blocks declare their own handlers and the fuller tiers
would collide with them. They are generated from the page's own declarations,
preferring the fullest version of any name declared twice: effects-showcase
introduces `effect Log` with `info`, then re-introduces it with `info` and
`warn`.

One thing worth recording for whoever tags blocks next: verify() stops after
codegen, because clang runs as a separate batched stage. Choosing a preamble
tier on verify() alone picked tiers that satisfied the front end and then
failed to build, with errors like `use of undeclared identifier
'_FrozenClock_Clock_vtable'`. The tier has to be chosen against a real clang
run.

Effects pages: 39 of 39 verified. Corpus: verified 470 to 476.

Unit 1515 passed, links, coverage, nav and ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht marked this pull request as ready for review August 18, 2026 21:35
@godofecht
godofecht merged commit 6daecfa into main Aug 18, 2026
21 checks passed
@godofecht
godofecht deleted the agent/effects-capabilities-examples branch August 18, 2026 21:48
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