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.PlatformService
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScriptComposing Streams
Composition builds a larger stream without starting any source.
Append
FlowStream.append consumes the left stream before the right stream:
> (FlowStream.fromSeq [ 1; 2 ] : FlowStream<int>)
- |> FlowStream.append (FlowStream.fromSeq [ 3; 4 ])
- |> FlowStream.runCollect
- |> Flow.run ();;val it: Exit<int list,Never> = Success [1; 2; 3; 4]Axial.FlowStreamModulefromSeq: 'value seq -> FlowStream<'env,'error,'value>Creates a stream from a synchronous sequence of values. The sequence of values to be emitted by the stream. A that yields each value from the sequence. FlowStream.fromSeq [1..10] |> FlowStream.runCollect |> Flow.run ()
FlowStreamA stream with no environment requirement and no typed failure.
intAn abbreviation for the CLI type . Basic Types
(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
append: FlowStream<'a,'b,'c> -> FlowStream<'a,'b,'c> -> FlowStream<'a,'b,'c>Concatenates two streams, evaluating the second only after the first ends. first |> FlowStream.append second
runCollect: FlowStream<'a,'b,'c> -> Flow<'a,'b,'c list>Collects all emitted values into a list. stream |> FlowStream.runCollect
Axial.Flowrun: 'env -> Flow<'env,'error,'value> -> Exit<'value,'error>Runs the workflow and blocks until the final exit is available. The environment used by the workflow. The workflow to run. The final workflow exit. let exit = workflow |> Flow.run environment
The right side is not pulled while the left side still has values.
Map and flatten
FlowStream.collect maps each value to an inner stream and flattens those streams in order. This is the stream equivalent of
flatMap or monadic bind:
> (FlowStream.fromSeq [ 1; 2; 3 ] : FlowStream<int>)
- |> FlowStream.collect (fun value ->
- FlowStream.fromSeq [ value; value * 10 ])
- |> FlowStream.runCollect
- |> Flow.run ();;val it: Exit<int list,Never> = Success [1; 10; 2; 20; 3; 30]Axial.FlowStreamModulefromSeq: 'value seq -> FlowStream<'env,'error,'value>Creates a stream from a synchronous sequence of values. The sequence of values to be emitted by the stream. A that yields each value from the sequence. FlowStream.fromSeq [1..10] |> FlowStream.runCollect |> Flow.run ()
FlowStreamA stream with no environment requirement and no typed failure.
intAn abbreviation for the CLI type . Basic Types
(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
collect: ('a -> FlowStream<'b,'c,'d>) -> FlowStream<'b,'c,'a> -> FlowStream<'b,'c,'d>Maps each value to a stream and concatenates the resulting streams. stream |> FlowStream.collect FlowStream.fromSeq
value: int(*): ^T1 -> ^T2 -> ^T3Overloaded multiplication operator The first parameter. The second parameter. The result of the operation. 8 * 6 // Evaluates to 48
runCollect: FlowStream<'a,'b,'c> -> Flow<'a,'b,'c list>Collects all emitted values into a list. stream |> FlowStream.runCollect
Axial.Flowrun: 'env -> Flow<'env,'error,'value> -> Exit<'value,'error>Runs the workflow and blocks until the final exit is available. The environment used by the workflow. The workflow to run. The final workflow exit. let exit = workflow |> Flow.run environment
Each inner stream completes before the next outer value is expanded.
Zip
FlowStream.zip pulls one value from each side and stops when either side completes:
> (FlowStream.fromSeq [ 1; 2; 3 ] : FlowStream<int>)
- |> FlowStream.zip (FlowStream.fromSeq [ "a"; "b" ])
- |> FlowStream.runCollect
- |> Flow.run ();;val it: Exit<Tuple<int,string> list,Never> = Success [(1, "a"); (2, "b")]Axial.FlowStreamModulefromSeq: 'value seq -> FlowStream<'env,'error,'value>Creates a stream from a synchronous sequence of values. The sequence of values to be emitted by the stream. A that yields each value from the sequence. FlowStream.fromSeq [1..10] |> FlowStream.runCollect |> Flow.run ()
FlowStreamA stream with no environment requirement and no typed failure.
intAn abbreviation for the CLI type . Basic Types
(|>): 'T1 -> ('T1 -> 'U) -> 'UApply a function to a value, the value being on the left, the function on the right The argument. The function. The function result. let doubleIt x = x * 2 3 |> doubleIt // Evaluates to 6
zip: FlowStream<'a,'b,'c> -> FlowStream<'a,'b,'d> -> FlowStream<'a,'b,('d * 'c)>Pairs values from two streams until either stream ends. left |> FlowStream.zip right
runCollect: FlowStream<'a,'b,'c> -> Flow<'a,'b,'c list>Collects all emitted values into a list. stream |> FlowStream.runCollect
Axial.Flowrun: 'env -> Flow<'env,'error,'value> -> Exit<'value,'error>Runs the workflow and blocks until the final exit is available. The environment used by the workflow. The workflow to run. The final workflow exit. let exit = workflow |> Flow.run environment
The result contains two pairs. The remaining value from the longer side is not emitted.
Lifetimes inside composition
A composed stream may own several upstream resources. Natural completion closes a source when it finishes, while the terminal consumer's child scope is the final safety boundary for failure, interruption, and early termination. See Scopes for the ownership model.

