Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Layers
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.HttpClient
open Axial.PlatformService
open Axial.Process
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScript

The Flow CE

Use flow {} when later work depends on earlier success.

Suppose the block calls these functions:

let loadUser (id: UserId) : Flow<AppEnv, AppError, User> = ...
let auditUser (user: User) : Flow<AppEnv, AppError, unit> = ...
let greetUser (user: User) : Flow<AppEnv, AppError, string> = ...
`let!` binds a successful value to the name on its left. `do!` binds a step whose success value is `unit`. `return!` uses another complete Flow as the result of the block.
flow {
    let! user = loadUser userId
    do! auditUser user
    return! greetUser user
}
Here is the same block with the important left- and right-hand types shown:
flow {
    let! (user: User) =
        (loadUser userId: Flow<AppEnv, AppError, User>)

    do! (auditUser user: Flow<AppEnv, AppError, unit>)
    return! (greetUser user: Flow<AppEnv, AppError, string>)
}
// Flow<AppEnv, AppError, string>
`flow {}` also binds `Result`, `Option`, `ValueOption`, `Async`, and `ColdTask`. An outer `Result.Error` enters the Flow error channel. Raw `Task` and `ValueTask` values do not bind directly; use `ColdTask` for work that should start with the Flow or an explicit `Flow.awaitStarted*` function for work already running. The output remains one cold Flow description until an execution boundary runs it.

Normal F# if, match, for, and while expressions work inside the computation expression.

Go Further

  • Flow builder reference lists the values accepted by each computation-expression operation.
  • Bind covers bind-site error assignment and mapping when the source error does not already match the workflow.
  • Task and Async interop gives the detailed carrier and cancellation rules.