Repository navigation
Expand effects and capabilities documentation - #557
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Expands the effects documentation into a practical cookbook and makes it much easier to discover from the main wiki.
docs/effects-showcase.mdinto the canonical effects/capabilities cookbook with 24 concrete patternsexamples/effects/docs/wiki-home.mddocs/tutorials/effects-basics.md, removing the stale pseudo syntax usingperform, inline handlers, andresume()and replacing it with the compiler's currentEffect.op(...), namedcapability, andhandle ... with ...syntaxWhy
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.