Repository navigation
add Solve It the Flow Way problem gallery - #581
Conversation
#582) PR #581 hit this: examples/flow_way/README.md inlined the program from swappable_telemetry.flow and renamed a variable to `test`, which is a keyword. The file kept the name that parses, the copy did not, and CI caught it only because the copy stopped compiling. A rename that still compiled would have gone unnoticed. 42 blocks sit next to a link to a .flow file. 34 of them no longer appear in the file they link. Eight are still verbatim copies, and those are now tagged `from=`, so the checker asserts the block appears in the named file and fails with which page and which file disagree. `from=` was listed in docs_blocks as designed but not implemented, alongside a test asserting it must not parse while it does nothing. That test now asserts the opposite, which is the point of having written it that way. Verified by breaking it on purpose: renaming main in examples/book/01_hello.flow fails the gate with "block no longer appears in examples/book/01_hello.flow". The remaining 34 are a content job, not a mechanism job: each needs a human to decide whether the page or the file is the wrong one. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…eachable
The gallery was in the repository and not on the site. 48 pages under docs/
link to ../../examples/, and every one of those 404'd:
https://flooooooooooow.github.io/flow/examples/flow_way/README.md 404
https://flooooooooooow.github.io/flow/examples/README.md 404
The deploy copied docs/ alone. wiki.js was already written for this: it sends
every non-.md file under examples/, lib/, src/ and the rest to GitHub, and
keeps .md as a site page, with a comment saying "a .md under one of these is
still documentation the site may carry". The site just never carried it.
build_wiki.py now copies the 1082 markdown files under examples/ into the
build, and the gallery has a Galleries sidebar entry. Sources still go to
GitHub rather than being served, which is what a reader wants: highlighted
and in context.
check_wiki_links.py needed the same rule the client already had. A copied
page links to its siblings by bare name, so `competitive_lv.flow` from
examples/evoleco/README.md resolves against the repository rather than the
built site. Without that, publishing these pages reported 165 broken links
that are not broken.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
4670a6a to
432cecf
Compare
|
Rebased onto main and made the gallery actually reachable. It was published nowhereThe page existed in the repository but not on the site: The wiki deploy copies
What changed
Verification
The |
|
The gallery now runs in the browser. Why it did not beforeIn-browser execution was gated to if (path.startsWith('tutorials/')) {
initTutorialRunners(content, { autoMain: true });
}Every other page's examples were listings. Enabled for Effects in the browser interpreterMost of this gallery is about effects, and the interpreter refused them. It now handles effect declarations, capability declarations in both spellings ( Output matches
The three that still cannot run now say whyThey used to fail as raw parse errors, which tells a reader nothing: Now: The interpreter's stated rule is that it never guesses and names what it cannot run. Verification
Making the other three run means pipeline forks, enums and a JS ODE solver in the interpreter. Each is its own piece of work rather than something to bolt on here. |
Two of the five ran. The other three needed features the browser interpreter did not have, and the gallery teaches idioms, so a reader pressing Run on one and being told to go and install a compiler is the wrong answer. Restored first: the effects work from #581 was written but not merged. The merge took the gallery and the wiki publishing and left site/flow-compile.js and site/wiki.js behind, so effect declarations, capabilities, handle blocks and Effect.op dispatch were absent from main. Recovered from the dangling commit rather than rewritten. Then three features: Pipeline forks. `n |> Stats { doubled = twice, plus_ten = add(_, 10) }` runs each named function over the piped value and collects the results. The `_` placeholder logic already existed for ordinary stages and is now shared. Enums and choose. `enum Mode { Double, Triple }` becomes a struct holding a tag plus one constant per variant, which is what the native compiler lowers it to, so `Mode { tag: Mode_Double }` and `m.tag` mean the same thing in both. `|> choose m.tag { Mode_Double => double }` selects which function the value flows through. Flow blocks. `flow Thermostat { state ... param ... solver ... evolves as ... every 100 ms { ... } }` lowers to a struct plus Name_new, Name_default_dt and Name_step, so the existing struct, pointer and call machinery runs it instead of a second evaluator living beside the first. Explicit Euler; a method that is not euler says which one it was asked for. Checked against the native compiler rather than against a tolerance. 20000 steps of the thermostat with its every-block firing 200 times prints temp=20.414 heater=1.0 from both. Top-level constants were parsed and never installed as globals, so every reference to one was an undefined variable. Enum variants are constants, which is how that surfaced. verify_browser_interp.py: 240 snippets, unsupported 13 -> 12, no new disagreement. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
What changed
Adds the first problem-first Flow idiom gallery under
examples/flow_way/and surfaces it from the existing Galleries page.The first executable slice contains sensor calibration expressed as a pipeline with the
_placeholder, plus swappable telemetry expressed with an effect row, capabilities, and scoped handlers. The gallery then points into existing canonical programs for typed forks,choose, hybrid thermostat dynamics, RT safety, channels, and the full effects showcase rather than duplicating those implementations.A runtime regression test under
tests/runtime/test_flow_way_examples.flowpins the two new executable patterns and deliberately causes the strict Tier-2 corpus to run for this PR.Why
Flow should be demonstrated with problems where its highest-level abstractions change the shape of the solution, rather than only by translating ordinary imperative algorithms. Each gallery entry names the high-level Flow form and the low-level shortcut that should be considered the wrong solution.
Validation
On the latest head, the wiki build, documentation links, documentation coverage, version consistency, and the documentation Flow-snippet compiler are green. Every new fenced
flowblock in the gallery compiles without ledger exemptions. Strict Tier-2 transpile+clang is also triggered by this PR and is currently in its toolchain-install step.