package flux
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0e66f5509a2b93fba91bddaefa92647fe961d0d7a79986cdec68e5b86ce67f06
sha512=f25e7d6d477e9168e12390f535c1cc243e5b07610a51919a44adb99b321474e8b666250f6e5dfe2a326f2766bc003ef7eaebaea8c5f45a72e3e6437869b9a9a0
doc/flux/Flux/Stream/index.html
Module Flux.StreamSource
Creating streams.
range ~by:step n m is a sequence of integers starting from n to m (excluding m) incremented by step. The range is pen on the right side.
repeat ~times:n x produces a stream by repeating x n times. If n is omitted, x is repeated ad infinitum.
unfold seed next is a stream created from a seed state and a function that produces elements and an updated state. The stream will terminate when next produces None.
concat s0 s1 is a stream that exhausts all elements from s0 and then all elements from s1.
Transforming a stream.
A stream with all elements transformed with a mapping function.
Pass each element through an effectful function.
Take first n elements from the stream and discard the rest.
A stream that includes only the elements that satisfy a predicate.
filter_map fn src applies fn to every element x of source, discarding it if fn x produces None, and keeping the transformed value otherwise.
Combining streams.
Inserts a separator element between each stream element.
flat_map fn stream is a stream concatenated from sub-streams produced by applying fn to all elements of stream.
Consumers.
each fn stream applies an function fn to all elements of stream. Each function is performed cooperatively via the Miou scheduler.
Adaptors.
into sink stream is the result value produced by streaming all elements of stream into sink.
via flow stream is stream produced by transforming all elements of stream via flow.
from source is a stream created from a source. To retain control over the given src resource, by default, if the stream has fully filled the result, the source is properly disposed of (i.e. its stop function is called correctly).
Fuses sources, sinks and flows and produces a result and a leftover.
let r, leftover = Stream.run ~from:source ~via:flow ~into:sinkStreams elements from source into sink via a stream transformer flow. In addition to the result value r produced by sink, a leftover source is returned, if source was not exhausted.
NOTE: If a leftover source is produced, it is required to either consume it or manually dispose its resources. Not doing so might lead to resource leaks.
I/O Streams.