FlowStreamModule
PackageAxial
Summary
| Name | Signature | Synopsis |
|---|---|---|
| unfoldFlow | FlowStream.unfoldFlow step initialState | Creates a cold stream by repeatedly running an effectful state transition. |
| fromSeq | FlowStream.fromSeq values | Creates a stream from a synchronous sequence of values. |
| empty | FlowStream.empty | Creates an empty stream. |
| singleton | FlowStream.singleton value | Creates a stream containing one value. |
| fromFlow | FlowStream.fromFlow flow | Creates a one-element stream from an effectful value. |
| runForEach | FlowStream.runForEach action (FlowStream op) | Executes the stream and performs a synchronous action for each successful value. |
| map | FlowStream.map f (FlowStream op) | Transforms the successful values of a stream using the provided function. |
| mapError | FlowStream.mapError mapper (FlowStream op) | Transforms the typed error channel of a stream. |
| filter | FlowStream.filter predicate (FlowStream op) | Keeps values that satisfy a predicate. |
| choose | FlowStream.choose chooser (FlowStream op) | Maps and filters values in one operation. |
| tapFlow | FlowStream.tapFlow action (FlowStream op) | Runs an effect for each value before emitting the original value. |
| mapFlow | FlowStream.mapFlow mapper (FlowStream op) | Transforms every value with a Flow effect. |
| take | FlowStream.take count (FlowStream op) | Emits at most count values. |
| skip | FlowStream.skip count (FlowStream op) | Skips the first count values. |
| takeWhile | FlowStream.takeWhile predicate (FlowStream op) | Emits values while a predicate remains true. |
| skipWhile | FlowStream.skipWhile predicate (FlowStream op) | Skips values while a predicate remains true. |
| indexed | FlowStream.indexed (FlowStream op) | Emits each value paired with its zero-based index. |
| scan | FlowStream.scan folder initial (FlowStream op) | Emits successive accumulator states. |
| distinctUntilChangedBy | FlowStream.distinctUntilChangedBy projection (FlowStream op) | Suppresses consecutive duplicate values according to a projection. |
| append | FlowStream.append (FlowStream right) (FlowStream left) | Concatenates two streams, evaluating the second only after the first ends. |
| collect | FlowStream.collect mapper (FlowStream outer) | Maps each value to a stream and concatenates the resulting streams. |
| zip | FlowStream.zip (FlowStream right) (FlowStream left) | Pairs values from two streams until either stream ends. |
| runFold | FlowStream.runFold folder initial (FlowStream op) | Folds a stream into one value inside Flow. |
| runCollect | FlowStream.runCollect stream | Collects all emitted values into a list. |
| runDrain | FlowStream.runDrain stream | Consumes a stream and ignores its values. |
| runForEachFlow | FlowStream.runForEachFlow action (FlowStream op) | Runs an effectful action for every stream value. |
Creates a cold stream by repeatedly running an effectful state transition.
Parameters
| Name | Type | Description |
|---|---|---|
| step | 'state -> Flow<'env, 'error, ('value * 'state) option> | Returns Some(value, nextState) or None when the stream is complete. |
| initialState | 'state | The state used for the first pull. |
Returns
FlowStream<'env, 'error, 'value>
Verification Examples
FlowStream.unfoldFlow (fun n -> Flow.ok (if n < 3 then Some(n, n + 1) else None)) 0Creates a stream from a synchronous sequence of values.
Parameters
| Name | Type | Description |
|---|---|---|
| values | 'value seq | The sequence of values to be emitted by the stream. |
Returns
FlowStream<'env, 'error, 'value>
Verification Examples
FlowStream.fromSeq [1..10]
|> FlowStream.runCollect
|> Flow.run ()Creates an empty stream.
Returns
FlowStream<'env, 'error, 'value>
Verification Examples
FlowStream.empty<unit, string, int>Creates a stream containing one value.
Parameters
| Name | Type | Description |
|---|---|---|
| value | 'value |
Returns
FlowStream<'env, 'error, 'value>
Verification Examples
FlowStream.singleton 42Creates a one-element stream from an effectful value.
Parameters
| Name | Type | Description |
|---|---|---|
| flow | Flow<'env, 'error, 'value> |
Returns
FlowStream<'env, 'error, 'value>
Verification Examples
FlowStream.fromFlow (Flow.ok 42)Executes the stream and performs a synchronous action for each successful value.
Parameters
| Name | Type | Description |
|---|---|---|
| action | 'value -> unit | The function to execute for each value emitted by the stream. |
| FlowStream op | FlowStream<'env, 'error, 'value> |
Returns
Flow<'env, 'error, unit>
Verification Examples
FlowStream.fromSeq ["a"; "b"; "c"]
|> FlowStream.runForEach (printfn "%s")
|> Flow.run ()Transforms the successful values of a stream using the provided function.
Parameters
| Name | Type | Description |
|---|---|---|
| f | 'v -> 'w | The function to transform each value. |
| FlowStream op | FlowStream<'env, 'error, 'v> |
Returns
FlowStream<'env, 'error, 'w>
Verification Examples
let stream = FlowStream.fromSeq [1; 2; 3] |> FlowStream.map (fun n -> n * 2)Transforms the typed error channel of a stream.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'error -> 'nextError | |
| FlowStream op | FlowStream<'env, 'error, 'value> |
Returns
FlowStream<'env, 'nextError, 'value>
Verification Examples
stream |> FlowStream.mapError DomainErrorKeeps values that satisfy a predicate.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'a -> bool | |
| FlowStream op | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'a>
Verification Examples
stream |> FlowStream.filter (fun value -> value > 0)Maps and filters values in one operation.
Parameters
| Name | Type | Description |
|---|---|---|
| chooser | 'a -> 'b option | |
| FlowStream op | FlowStream<'c, 'd, 'a> |
Returns
FlowStream<'c, 'd, 'b>
Verification Examples
stream |> FlowStream.choose idRuns an effect for each value before emitting the original value.
Parameters
| Name | Type | Description |
|---|---|---|
| action | 'a -> Flow<'b, 'c, unit> | |
| FlowStream op | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'a>
Verification Examples
stream |> FlowStream.tapFlow logValueTransforms every value with a Flow effect.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'a -> Flow<'b, 'c, 'd> | |
| FlowStream op | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'd>
Verification Examples
ids |> FlowStream.mapFlow loadEmits at most
count values.Parameters
| Name | Type | Description |
|---|---|---|
| count | int | |
| FlowStream op | FlowStream<'a, 'b, 'c> |
Returns
FlowStream<'a, 'b, 'c>
Verification Examples
stream |> FlowStream.take 10Skips the first
count values.Parameters
| Name | Type | Description |
|---|---|---|
| count | int | |
| FlowStream op | FlowStream<'a, 'b, 'c> |
Returns
FlowStream<'a, 'b, 'c>
Verification Examples
stream |> FlowStream.skip 10Emits values while a predicate remains true.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'a -> bool | |
| FlowStream op | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'a>
Verification Examples
stream |> FlowStream.takeWhile (fun value -> value < 100)Skips values while a predicate remains true.
Parameters
| Name | Type | Description |
|---|---|---|
| predicate | 'a -> bool | |
| FlowStream op | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'a>
Verification Examples
stream |> FlowStream.skipWhile String.IsNullOrEmptyEmits each value paired with its zero-based index.
Parameters
| Name | Type | Description |
|---|---|---|
| FlowStream op | FlowStream<'a, 'b, 'c> |
Returns
FlowStream<'a, 'b, (int * 'c)>
Verification Examples
stream |> FlowStream.indexedEmits successive accumulator states.
Parameters
| Name | Type | Description |
|---|---|---|
| folder | 'a -> 'b -> 'a | |
| initial | 'a | |
| FlowStream op | FlowStream<'c, 'd, 'b> |
Returns
FlowStream<'c, 'd, 'a>
Verification Examples
stream |> FlowStream.scan (+) 0Suppresses consecutive duplicate values according to a projection.
Parameters
| Name | Type | Description |
|---|---|---|
| projection | 'a -> 'b | |
| FlowStream op | FlowStream<'c, 'd, 'a> |
Returns
FlowStream<'c, 'd, 'a>
Verification Examples
stream |> FlowStream.distinctUntilChangedBy idConcatenates two streams, evaluating the second only after the first ends.
Parameters
| Name | Type | Description |
|---|---|---|
| FlowStream right | FlowStream<'a, 'b, 'c> | |
| FlowStream left | FlowStream<'a, 'b, 'c> |
Returns
FlowStream<'a, 'b, 'c>
Verification Examples
first |> FlowStream.append secondMaps each value to a stream and concatenates the resulting streams.
Parameters
| Name | Type | Description |
|---|---|---|
| mapper | 'a -> FlowStream<'b, 'c, 'd> | |
| FlowStream outer | FlowStream<'b, 'c, 'a> |
Returns
FlowStream<'b, 'c, 'd>
Verification Examples
stream |> FlowStream.collect FlowStream.fromSeqPairs values from two streams until either stream ends.
Parameters
| Name | Type | Description |
|---|---|---|
| FlowStream right | FlowStream<'a, 'b, 'c> | |
| FlowStream left | FlowStream<'a, 'b, 'd> |
Returns
FlowStream<'a, 'b, ('d * 'c)>
Verification Examples
left |> FlowStream.zip rightFolds a stream into one value inside Flow.
Parameters
| Name | Type | Description |
|---|---|---|
| folder | 'state -> 'a -> 'state | |
| initial | 'state | |
| FlowStream op | FlowStream<'env, 'error, 'a> |
Returns
Flow<'env, 'error, 'state>
Verification Examples
stream |> FlowStream.runFold (+) 0Collects all emitted values into a list.
Parameters
| Name | Type | Description |
|---|---|---|
| stream | FlowStream<'a, 'b, 'c> |
Returns
Flow<'a, 'b, 'c list>
Verification Examples
stream |> FlowStream.runCollectConsumes a stream and ignores its values.
Parameters
| Name | Type | Description |
|---|---|---|
| stream | FlowStream<'a, 'b, 'c> |
Returns
Flow<'a, 'b, unit>
Verification Examples
stream |> FlowStream.runDrainRuns an effectful action for every stream value.
Parameters
| Name | Type | Description |
|---|---|---|
| action | 'a -> Flow<'env, 'error, unit> | |
| FlowStream op | FlowStream<'env, 'error, 'a> |
Returns
Flow<'env, 'error, unit>
Verification Examples
stream |> FlowStream.runForEachFlow save
