The Flow Book
  1. Why Flow

One week at the support desk

  1. A payment that timed out
  2. What the run was told
  3. Writing the payments library
  4. Waiting for the manager
  5. The next morning
  6. When the process dies mid-call
  7. Fixing a bug in a half-finished run
  8. Three carriers at once
  9. Answering calls from your own service

Projects

  1. What people build
  2. A research agent you can check

The language tour

  1. Values, functions and blocks
  2. Records, choices and match
  3. Modules, libraries and Python functions
  4. Result, ToolProblem and ?

Appendix

  1. The flow command
Language reference ↗

Modules, libraries and Python functions

A Flow file is a module, and use brings another module into a file: one of your own files, a module of the standard library, or a library of Tools. This page covers all three. The exact rules are in the Reference, under modules.

Your own files

Two files make the smallest example. Save a helper as shared/money.flow:

/// Dollars as text for a customer email.pub flow dollars(amount: Int) -> Text = "${amount} dollars"

and a program that uses it as main.flow:

use "std@v1/list"use "./shared/money"pub flow main(amounts: List<Int>) -> List<Text> = list.map(amounts, money.dollars)
flow run main.flow amounts='[40, 25]'run 0109d6f2509a["40 dollars", "25 dollars"]0109d6f2509a completednext: flow replay 0109d6f2509a

The path is relative to the importing file and has no .flow. The module's name is the last part of the path, so everything money.flow makes pub is written money.dollars. Flow has no way to import a single name: write dollars(amount) on its own and the checker says nothing in reach binds dollars. Prefixing every use with its module costs a few characters, and in return a reader can tell where any name comes from without opening another file.

When two imports would get the same name, give one of them another, written before the path: use store "../store/catalog". A rename is allowed only for that. Renaming an import that clashes with nothing is refused as needless-rename, so a module is called the same thing in every file that uses it.

The standard library

std@v1/... names a module of the standard library at the language's version: std@v1/list, std@v1/text, std@v1/task, std@v1/clock. A few things need no import at all, because the prelude brings them into every file: Result, Option, ToolProblem, and the basic types. One of the modules is a Tool library rather than plain Flow, clock: reading the time reaches outside the program, so it is a Tool call, recorded like any other (The next morning).

Libraries of Tools

A path to a directory with a flow.toml imports a library. use "./payments" reads the library's contract, payments/contract/lib.flow, which flow build writes from the library's code, and its declarations are written payments.refund and payments.Receipt like those of any module.

For a Python library, the Tools are the functions the toolkit's tool decorator marks, and the types are the dataclasses they use. You never write a Tool's Flow declaration yourself: the type hints are read once, into the contract, so the Python and the program can't disagree about a signature. Writing the payments library builds one, and the library guide covers Rust and MCP servers too.

An import only brings in declarations. A library's code runs only during a run: one in your own project starts when the run needs it, and one fetched from a repository only after you approve it with flow approve. Checking a program never starts it, and neither does replaying a run.