Contents · The Flow Book

Start here

The Flow Book1. Your first run2. Let the outside answer3. Keep the original answer

Build the decision

4. Give the program an input5. Name the work6. Give values a shape

Build the workflow

7. Decide what failure means8. Put the decision in its own file9. Put the pieces together

Go further

10. Work on several things11. Leave room for an answer12. Take Flow into an application

Build an application

13. Investigate a real question14. Challenge: diagnose and extend
Language reference ↗

Name the work

A decision becomes easier to discuss when it has a name. Move the comparison into needs_review. The entry now asks that function a question and returns its answer.

Try it · Name the decision
main.flow
flow needs_review(amount: Int) -> Bool = amount > 100

pub flow main(amount: Int) -> Bool = needs_review(amount)
Expected resultfalse

Follow the values

main receives an amount and passes it to needs_review. The helper returns a Bool: true or false.

A function's parameters and result give you a compact description of its job. Read needs_review(amount: Int) -> Bool as “give me an integer amount, and I will answer yes or no.” Names such as needs_review help a reader understand why a comparison exists.

Keep an intermediate value

You can expand the entry into a block:

pub flow main(amount: Int) -> Bool = {
    let answer = needs_review(amount)
    answer
}

A let gives a value a name. The final expression is the block's result. Values are immutable: to continue with a different value, compute and pass a new one. A later binding can reuse a name, but it does not change the earlier value.

A smaller test surface

The helper now owns the boundary. Change it to include 100, then check the exercise. The entry should not need its own copy of the comparison. When the rule changes again, one function is the place to explain and edit it.

Exact rules: values, bindings and functions.