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.ProcessProcessCommand, ProcessSpec, ProcessStream, ProcessResult, ProcessError, the DSL, and IProcess are target-neutral. A browser cannot start an operating-system process, so Process.live and native stream adapters are available only on .NET.
Fable applications can construct specifications and run them against an IProcess implementation that delegates execution to a worker or another host:
open Axial.Process.DSL
type AppEnvironment =
{ Process: IProcess }
interface IHasProcess with member this.Process = this.Process
let workflow =
cmd $"device-tool inspect"
|> toFlowAn interpreter implements IProcess.Execute and IProcess.Launch. Execute returns a lazy
Flow<unit, ProcessError, ProcessResult> and awaits the supplied observer serially with backpressure. It must not start work while constructing the Flow.
Streaming constructors need no clock member in the environment: the supervised producer reads the runtime clock.
workflow above is construction-only: it builds a specification and a Flow that asks for IProcess when run, and
nothing executes until then. Supply an interpreter that delegates execution to a worker or another host, for example:
open Axial
/// A minimal interpreter that delegates to a worker and returns its result locally.
type WorkerProcess(execute: ProcessSpec -> Async<ProcessResult>) =
interface IProcess with
member _.Execute(specification, observe) =
Flow.fromAsync (execute specification)
// A worker has no desktop to hand a detached launch to.
member _.Launch(_) =
ProcessError.StartFailed { Command = "launch"; Message = "Not available in a worker." }
|> Flow.failFlow.fromAsync treats a worker exception as a defect; use Flow.attemptAsync and map the exception into
ProcessError when the worker reports typed failures.

