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

Streams

A Flow produces one result. A FlowStream produces values over time without first loading all of them into memory. Use it when the input may be large, slow, or unbounded: paginated APIs, message subscriptions, and incremental file or network adapters.

Verified
> (FlowStream.fromSeq [ 1..6 ] : FlowStream<int>)
- |> FlowStream.filter (fun number -> number % 2 = 0)
- |> FlowStream.map (fun number -> number * 10)
- |> FlowStream.runCollect
- |> Flow.run ();;
val it: Exit<int list,Never> = Success [20; 40; 60]

The stream is cold: constructing it starts nothing. It is pull-based: downstream asks for each next value, and operators pull upstream only as far ahead as their buffers allow, so backpressure is bounded. mapFlowPar and the timed/switchMapFlow operators read ahead by a fixed number of values, and fromCallback drops values when its fixed-size buffer is full rather than blocking the producer. It shares Flow's environment, typed failures, cancellation, scopes, and structured fibers.

Getting started builds one complete stream.

Guides

  1. Getting started: construct, transform, and consume one stream.
  2. Constructing streams: existing values, one Flow, and effectful unfolding.
  3. Transforming values: pure and effectful operators.
  4. Batching and parallelism: strict batches versus continuously replenished work.
  5. Composing streams: append, flatten, and zip.
  6. Consuming streams: folds, incremental effects, collection, and resource cleanup.
  7. Platform boundary: portable stream mechanics and host-specific adapters.
  8. Time and latest: throttling, debouncing, and switching to the latest input.
  9. Resources and results: resource-backed streams and partial-result terminals.
  10. Crawler recipe: a concurrent link crawler from unfoldFlow, mapFlowPar, and collect.

For one OS integration example, see the Process guide's Streaming output page. It explains how Axial.Process exposes stdout and stderr as a FlowStream; process handling is not part of the stream model.

The FlowStream API lists every operator.