Skip to content

Define the functions the pipelines chapter pipes through - #625

Merged
godofecht merged 2 commits into
mainfrom
docs-book06-define
Aug 20, 2026
Merged

godofecht merged 2 commits into
mainfrom
docs-book06-define

Conversation

@godofecht

@godofecht godofecht commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

docs/book/06-pipelines-and-results.md had seven unverified blocks and now has none. unverified: 159 -> 153.

Defined rather than worked around, since the language leaves room to define all of it.

Three functions the chapter never showed

It pipes values through increment, double, add and clamp from 6.1 onward, and showed only clamp. A reader following along had nothing to type:

let result: i32 = 5 |> increment() |> double()

They are defined once now, where they are first needed:

function increment(x: i32) -> i32 { return x + 1 }
function double(x: i32) -> i32 { return x * 2 }
function add(x: i32, k: i32) -> i32 { return x + k }

A reading from nowhere

6.2 pipes raw through clamp and never introduces it. It is a fixed input, so const raw: i32 = 137 says what it is, and the "It compiles as" block below now reads that same value instead of a free name.

const rather than let, because a module-level binding must be one or let mut, and the reading does not change.

Two blocks stay notation

They cannot be anything else:

x |> f
x |> f()
x |> f(y)

That is the same statement written three ways over names standing for any function and any value, and f takes one argument on one line and two on the next. No definition satisfies both.

Verification

Check Result
check_doc_examples.py --check-ledger no new unverified, 159 → 153
pytest tests/unit/test_docs_blocks.py 56 passed

godofecht and others added 2 commits August 20, 2026 18:37
docs/book/06-pipelines-and-results.md had seven unverified blocks and now has
none.

The chapter pipes values through `increment`, `double`, `add` and `clamp`
from 6.1 onward and never showed three of them. A reader following along had
nothing to type. They are defined once now, where they are first needed,
which is a line the chapter wanted anyway:

    function increment(x: i32) -> i32 { return x + 1 }
    function double(x: i32) -> i32 { return x * 2 }
    function add(x: i32, k: i32) -> i32 { return x + k }

6.2 pipes a `raw` reading through clamp without introducing it. It is a fixed
input, so `const raw: i32 = 137` says what it is, and the desugared block
below reads the same value rather than a name from nowhere.

Two blocks stay notation, because they cannot be anything else: `x |> f`,
`x |> f()` and `x |> f(y)` show the same statement written three ways over
names standing for any function and any value, and `f` is one arity in one
line and another in the next.

unverified: 159 -> 153.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Keep the chapter-6 content fix, take #624's chapter-13 work and current ledger from main, and avoid a generated-ledger merge conflict.
@godofecht
godofecht merged commit e596150 into main Aug 20, 2026
21 checks passed
godofecht added a commit that referenced this pull request Aug 20, 2026
Take the focused, green chapter-6 fix from #625 and keep the remaining audit work on top of current main.
godofecht added a commit that referenced this pull request Sep 7, 2026
Take the focused, green chapter-6 fix from #625 and keep the remaining audit work on top of current main.
godofecht added a commit that referenced this pull request Sep 7, 2026
Take the focused, green chapter-6 fix from #625 and keep the remaining audit work on top of current main.
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