Page
Library
Module
Module type
Parameter
Class
Class type
Source
Streaming.Flow
SourceModule with definitions for flows.
Flows define streaming transformation, filtering or groupping operations that are fully disconnected from input and output. Their implementation intercepts an internal folding function and modifies the input one value at a time.
Flows are a great way to define decoupled transformations that can be used with Stream.via
.
A flow can be applied to a stream with Stream.via
:
# Stream.range 10 100
|> Stream.via (Flow.map (fun x -> x + 1))
|> Stream.into Sink.sum
- : int = 4995
Flows can also be composed to form a pipeline:
# let flow = Flow.(map (fun x -> x + 1) >> filter (fun x -> x mod 2 = 0)) in
Stream.range 10 100
|> Stream.via flow
|> Stream.into Sink.sum
- : int = 2475
A flow that includes only the elements that satisfy a predicate.
A flow with all elements transformed with a mapping function.
Collects n
elements into an array buffer. Once the buffer is full it is emmited as a stream item.
through sink
repeatedly processes incoming elements with sink
producing computed results.
Note: The provided sink might consume the whole input if it is infinite, or if the input terminates before filling the sink.
Composes two flows from right to left.
More precisely f1 << f2
is compose f1 f2
.