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 ↗

Give the program an input

We have seen an outside amount. Before combining it with a Tool, write the decision by itself: an amount above 100 needs review. Keeping this part pure makes it easy to explore.

Try it · An input, a decision
main.flow
pub flow main(amount: Int) -> Text = if amount > 100 { "Review" } else { "Proceed" }
Expected result"Proceed"

Source and input are different things

The parameter amount: Int names a value the caller supplies. The input field passes it as {"amount":42}. Change that field to {"amount":150} and run. The source stays the same; the result changes from "Proceed" to "Review".

An if is an expression. Each branch supplies a value, and both values here are text. The function's declared result is also Text, so the pieces agree.

Try the boundary

What should happen at exactly 100? The source currently says >, which excludes equality. Our exercise changes the requirement to “100 or more.” Predict the result at 99, 100 and 101 before editing.

Check exercise runs those cases. A solution that returns "Review" for every amount passes one example but fails the task. This is why the exercise check is separate from Run.

Let the types help

Try an input of {"amount":"large"}. The word is text, while the entry expects an integer. The host must decode an input that matches the entry type before evaluation can start. Restore a number when you finish exploring.

Exact rules: evaluation, entry and input.