package flux

  1. Overview
  2. Docs
Composable streaming abstractions with Miou

Install

dune-project
 Dependency

Authors

Maintainers

Sources

flux-0.0.1.beta2.tbz
sha256=dbfb198a16aab3f8987cc2ba31bc8da3720b9031d2b6b1a3313e6c1342cbf4b3
sha512=ec0ab77c2b1db2fd730581cefbb92f8391c3f8801cd02bb558609f46daff493e8c513e1d0978d1cdc613ce7ef1799e144d1f9740e0863169e45992df4c117ba4

doc/flux/Flux/Flow/index.html

Module Flux.FlowSource

Transforming a flow.

Sourceval identity : ('a, 'a) flow

A neutral flow that does not change the elements.

Sourceval map : ('a -> 'b) -> ('a, 'b) flow

A flow with all elements transformed with a mapping function.

Sourceval tap : ('a -> unit) -> ('a, 'a) flow

A flow with all elements passed through an effectful function.

Sourceval take : int -> ('a, 'a) flow

Take first n elements from the source and discard the rest.

Sourceval filter : ('a -> bool) -> ('a, 'a) flow

A flow that includes only elements that satisfy a predicate.

Sourceval filter_map : ('a -> 'b option) -> ('a, 'b) flow

filter_map fn applies fn to element, discarding it if fn x produces None, and keeping the transformed value otherwise.

Sourceval bound : int -> ('a, 'a) flow

bounds limits the consumption of an infinite source to a source with bounded memory consumption. Indeed, the effective aspect of consuming a source, transforming it, and producing a final value (in other words, Stream.run) can lead (depending on the source) to a peak in memory usage that will only end when the process terminates, leaving no room for other processes to run (in parallel and/or cooperatively) correctly (and surely ending in an Out_of_memory exception if we are in a restricted context).

Sourceval split_on_char : char -> (string, string) flow

split_on_char sep is a flow which emits (possibly empty) subtrings of incoming elements that are delimited by the character sep.

Sourceval bstr : len:int -> (string, bstr) flow

bstr ~len allocates a bigarray of len bytes and copies the incoming strings into this bigarray. Once it is full, it is transferred to the next consumer.

NOTE: the consumer must immediately consume, in one way or another, the given bigarray. bstr reuses this same bigarray (and does not allocate a new one) to refill it with the incoming strings.

Composing flows.

Sourceval compose : ('a, 'b) flow -> ('b, 'c) flow -> ('a, 'c) flow

Compose two flows to form a new flow.

Sourceval (>>) : ('a, 'b) flow -> ('c, 'a) flow -> ('c, 'b) flow

f1 << f2 is compose f1 f2.

Sourceval (<<) : ('a, 'b) flow -> ('b, 'c) flow -> ('a, 'c) flow

f1 >> f2 is compose f2 f1.