ProcessStreamUnion
Consuming process output
ProcessStream<'env, 'value> represents output that can be transformed as the process runs. Construct one with
streamStdoutLines or another
Process stream constructor.
Transforms such as map, filter, and take belong to this module. Terminals such as runCollect, runFold, and
runForEachFlow return a Flow; they do not start execution. Run that Flow at a script boundary, or bind it in the
application Flow. Terminals that retain completion return it alongside the consumed value:
ProcessCompletion.Completed resultmeans the process completed and includes itsProcessResult.ProcessCompletion.StoppedEarlymeans a stream operator stopped consumption and Axial cleaned up the process.
toFlowStream adapts values to FlowStream for composition with application streams, but intentionally drops
successful process completion. Keep the ProcessStream terminal when completion matters.
See Streaming output for examples, including effectful consumers and early stopping.
Specification
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Transform streams | ||
| map | ProcessStream.map mapping source | Transforms values while preserving process completion. |
| filter | ProcessStream.filter predicate source | Selects values without losing process completion or skipping drainage of other channels. |
| take | ProcessStream.take count source | Stops the owned process after a prefix. |
| takeWhile | ProcessStream.takeWhile predicate source | Stops before the first nonmatching value, awaits owned cleanup, and reports StoppedEarly. |
| Consume a stream | ||
| runFold | ProcessStream.runFold folder initial source | Folds selected values and returns the state together with completion; capture policy is independent. |
| runCollect | ProcessStream.runCollect source | Collects every selected value plus completion. |
| runDrain | ProcessStream.runDrain source | Consumes selected output without accumulating values and returns completion. |
| runForEach | ProcessStream.runForEach action source | Synchronous callback; use runForEachFlow for explicit service operations. |
| runForEachFlow | ProcessStream.runForEachFlow action source | Runs each callback in the application environment; preserves consumer errors separately. |
| runFoldFlow | ProcessStream.runFoldFlow folder initial source | Folds with application workflows; typed consumer failures use ConsumerFailed. |
| Adapt to FlowStream | ||
| toFlowStream | ProcessStream.toFlowStream (ProcessStream factory) | Converts to ordinary FlowStream, discarding successful process completion. |
Transform streams
Filter, map, or stop consumption after a prefix.
Consume a stream
Collect, fold, drain, or handle each output value.
Parameters
| Name | Type | Description |
|---|---|---|
| folder | 'a -> 'b -> Flow<'c, 'd, 'a> | |
| initial | 'a | |
| source | ProcessStream<'c, 'b> |
Returns
Adapt to FlowStream
Convert process output for composition with application streams.

