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.PlatformService
open Axial.ProcessSpecifications capture stdout and stderr by default. Process.toFlow preserves that policy and returns exact bytes and an encoding-aware text view:
Show page setup
// Setup for the checked examples on this page.
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Console
open Axial.FileSystem
open Axial.PlatformService
open Axial.Process
/// Fails the docs test when an example's result differs from the value shown.
let shouldEqual expected actual =
if actual <> expected then failwithf "Expected %A but got %A" expected actual// The examples on this page start real processes with the live service.
let host : ProcessHostEnvironment =
{ Process = Process.live Clock.live FileSystem.live Console.live
Console = Console.live }
let stdoutOf (workflow: Flow<ProcessHostEnvironment, ProcessError, ProcessResult>) : string =
match Flow.run host workflow with
| Exit.Success result -> result.StdOut
| Exit.Failure cause -> failwithf "%A" cause
host: ProcessHostEnvironmentAxial.Process.ProcessHostEnvironmentThe live environment used by <c>Process.run</c> at a command-line host boundary. Application workflows normally use their own environment record and <c>Process.runWith</c>.
Process: IProcessAxial.Process.ProcessModulelive: IClock -> IFileSystem -> IConsole -> IProcessCreates a live process service using an explicit clock for transcript timestamps and durations.
Axial.PlatformService.ClockHelpers for the clock service.
live: IClockCreates a live clock backed by and a monotonic timer.
Axial.FileSystem.FileSystemModulelive: IFileSystemCreates a live file-system service backed by , , and .
Axial.Console.ConsoleModulelive: IConsoleCreates a live console service backed by .
Console: IConsolestdoutOf: Flow<ProcessHostEnvironment,ProcessError,ProcessResult> -> stringworkflow: Flow<ProcessHostEnvironment,ProcessError,ProcessResult>Axial.Flow`3Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously. The type of the environment dependency. The type of the failure value. The type of the success value.
Axial.Process.ProcessErrorA recoverable process startup, timeout, stage, or I/O failure. Interrupting the workflow is not an error: it terminates the processes and surfaces as <c>Cause.Interrupt</c>.
Axial.Process.ProcessResultThe complete structured transcript returned by a process execution.
stringAn abbreviation for the CLI type . Basic Types
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
Axial.Exit`2Represents the final outcome of a workflow execution. The type of the success value. The type of the domain-specific failure value.
SuccessThe workflow completed successfully.
result: ProcessResultStdOut: stringFailureThe workflow failed due to a specific cause.
cause: Cause<ProcessError>failwithf: Printf.StringFormat<'T,'Result> -> 'TPrint to a string buffer and raise an exception with the given result. Helper printers must return strings. The formatter. The formatted result. See Printf.failwithf (link: ) for examples.
let inspect : Flow<ProcessHostEnvironment, ProcessError, string * int> =
flow {
let! result =
Process.command $"printf 'status: ok'"
|> Process.toFlow
let bytes = result.StdOutCapture.Bytes
return result.StdOut, bytes.Length
}
inspect: Flow<ProcessHostEnvironment,ProcessError,(string * int)>Axial.Flow`3Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously. The type of the environment dependency. The type of the failure value. The type of the success value.
Axial.Process.ProcessHostEnvironmentThe live environment used by <c>Process.run</c> at a command-line host boundary. Application workflows normally use their own environment record and <c>Process.runWith</c>.
Axial.Process.ProcessErrorA recoverable process startup, timeout, stage, or I/O failure. Interrupting the workflow is not an error: it terminates the processes and surfaces as <c>Cause.Interrupt</c>.
stringAn abbreviation for the CLI type . Basic Types
intAn abbreviation for the CLI type . Basic Types
flow: FlowBuilderThe universal flow { } computation expression.
result: ProcessResultAxial.Process.ProcessModulecommand: FormattableString -> ProcessSpecCreates a safely tokenized one-command process specification from an interpolated command template. Each interpolation hole is one native argument. Example: Process.command $"git show {revision}" |> Process.toFlow
(|>): '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
toFlow: ProcessSpec -> Flow<'env,ProcessError,ProcessResult>Converts a process specification into a lazy Flow in the current environment. Example: specification |> Process.toFlow
bytes: byte arrayBytes: byte arrayStdOutCapture: CapturedOutputStdOut: stringLength: intGets the total number of elements in all the dimensions of the . The total number of elements in all the dimensions of the ; zero if there are no elements in the array. The array is multidimensional and contains more than elements.
inspect |> Flow.run host |> shouldEqual (Exit.Success("status: ok", 10))
inspect: Flow<ProcessHostEnvironment,ProcessError,(string * int)>(|>): '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
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
host: ProcessHostEnvironmentshouldEqual: 'a -> 'a -> unitAxial.Exit`2Represents the final outcome of a workflow execution. The type of the success value. The type of the domain-specific failure value.
SuccessThe workflow completed successfully.
Configure output with Process.stdout and Process.stderr. Targets include complete capture, bounded tail capture, console forwarding, inherited handles, discard, files, sinks, callbacks, and tee composition.
let diagnose : Flow<ProcessHostEnvironment, ProcessError, ProcessResult> =
Process.command $"printf 'diagnostics'"
|> Process.stdout (OutputTarget.Tee [ OutputTarget.Console; OutputTarget.CaptureTail 65536 ])
|> Process.toFlow
diagnose: Flow<ProcessHostEnvironment,ProcessError,ProcessResult>Axial.Flow`3Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously. The type of the environment dependency. The type of the failure value. The type of the success value.
Axial.Process.ProcessHostEnvironmentThe live environment used by <c>Process.run</c> at a command-line host boundary. Application workflows normally use their own environment record and <c>Process.runWith</c>.
Axial.Process.ProcessErrorA recoverable process startup, timeout, stage, or I/O failure. Interrupting the workflow is not an error: it terminates the processes and surfaces as <c>Cause.Interrupt</c>.
Axial.Process.ProcessResultThe complete structured transcript returned by a process execution.
Axial.Process.ProcessModulecommand: FormattableString -> ProcessSpecCreates a safely tokenized one-command process specification from an interpolated command template. Each interpolation hole is one native argument. Example: Process.command $"git show {revision}" |> Process.toFlow
(|>): '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
stdout: OutputTarget -> ProcessSpec -> ProcessSpecConfigures final stdout handling. Example: specification |> Process.stdout OutputTarget.Console
Axial.Process.OutputTargetReceives bytes from a process topology. Capture limits are measured in bytes.
TeeConsoleCaptureTailtoFlow: ProcessSpec -> Flow<'env,ProcessError,ProcessResult>Converts a process specification into a lazy Flow in the current environment. Example: specification |> Process.toFlow
Use Process.stream when output must be handled before completion:
let events =
Process.command $"printf 'one\ntwo\n'"
|> Process.framing OutputFraming.Lines
|> Process.stream
let outputLines : Flow<ProcessHostEnvironment, ProcessError, string list> =
events
|> FlowStream.choose (function
| ProcessEvent.Output output -> Some output.Text
| ProcessEvent.Completed _ -> None)
|> FlowStream.runCollect
events: FlowStream<ProcessHostEnvironment,ProcessError,ProcessEvent>Axial.Process.ProcessModulecommand: FormattableString -> ProcessSpecCreates a safely tokenized one-command process specification from an interpolated command template. Each interpolation hole is one native argument. Example: Process.command $"git show {revision}" |> Process.toFlow
(|>): '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
framing: OutputFraming -> ProcessSpec -> ProcessSpecSelects chunk or line event framing. Example: specification |> Process.framing OutputFraming.Lines
Axial.Process.OutputFramingSelects arbitrary decoded chunks or complete decoded lines for streamed events.
Linesstream: ProcessSpec -> FlowStream<'env,ProcessError,ProcessEvent>Streams process events in the current Flow runtime. The last event is <c>Completed</c>.
outputLines: Flow<ProcessHostEnvironment,ProcessError,string list>Axial.Flow`3Represents a cold workflow that reads an environment, returns a typed result, and is executed explicitly through one of its execution members such as ToTask, ToAsync, or RunSynchronously. The type of the environment dependency. The type of the failure value. The type of the success value.
Axial.Process.ProcessHostEnvironmentThe live environment used by <c>Process.run</c> at a command-line host boundary. Application workflows normally use their own environment record and <c>Process.runWith</c>.
Axial.Process.ProcessErrorA recoverable process startup, timeout, stage, or I/O failure. Interrupting the workflow is not an error: it terminates the processes and surfaces as <c>Cause.Interrupt</c>.
stringAn abbreviation for the CLI type . Basic Types
listThe type of immutable singly-linked lists. See the module for further operations related to lists. Use the constructors [] and :: (infix) to create values of this type, or the notation [1; 2; 3]. Use the values in the List module to manipulate values of this type, or pattern match against the values directly. See also F# Language Guide - Lists.
Axial.FlowStreamModulechoose: ('a -> 'b option) -> FlowStream<'c,'d,'a> -> FlowStream<'c,'d,'b>Maps and filters values in one operation. stream |> FlowStream.choose id
Axial.Process.ProcessEventValues emitted by a native process FlowStream.
Outputoutput: ProcessOutputSomeThe representation of "Value of type 'T" The input value. An option representing the value.
Text: stringCompletedNoneThe representation of "No value"
runCollect: FlowStream<'a,'b,'c> -> Flow<'a,'b,'c list>Collects all emitted values into a list. stream |> FlowStream.runCollect
outputLines |> Flow.run host |> shouldEqual (Exit.Success [ "one"; "two" ])
outputLines: Flow<ProcessHostEnvironment,ProcessError,string list>(|>): '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
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
host: ProcessHostEnvironmentshouldEqual: 'a -> 'a -> unitAxial.Exit`2Represents the final outcome of a workflow execution. The type of the success value. The type of the domain-specific failure value.
SuccessThe workflow completed successfully.
The stream emits ProcessEvent.Output values followed by one ProcessEvent.Completed. Each output event identifies its stage, channel, text, and timestamp. Pulling provides bounded backpressure. Ending consumption early interrupts the producer fiber, which terminates the native process topology before the Flow scope closes.
OutputTarget.Inherit gives the child the host handle directly. Inherited output cannot be observed, captured, or combined in a tee because it bypasses Axial's redirected streams.

