FlowStreamUnion
Represents a cold stream of values that requires an environment, can fail with a typed error,
and supports backpressure.
Specification
Kind
Union
Members
27
Examples
0
unfoldFlowSignature
FlowStream.unfoldFlow step initialState
fromSeqSignature
FlowStream.fromSeq values
emptySignature
FlowStream.empty
singletonSignature
FlowStream.singleton value
fromFlowSignature
FlowStream.fromFlow flow
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Union cases | ||
| FlowStream | FlowStream 'env -> CancellationToken -> Execution | No description available. |
| Operations | ||
| 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. |
Union cases
Operations
kind:member
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)) 0kind:member
Creates 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 ()kind:member
kind:member
kind:member
kind:member
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 ()kind:member
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)kind:member
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 DomainErrorkind:member
kind:member
kind:member
Runs 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 logValuekind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
Suppresses 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 idkind:member
Concatenates 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 secondkind:member
Maps 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.fromSeqkind:member
Pairs 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 rightkind:member
Folds 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 (+) 0kind:member
kind:member
kind:member
Runs 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
