package flux

  1. Overview
  2. Docs
Composable streaming abstractions with Miou

Install

dune-project
 Dependency

Authors

Maintainers

Sources

flux-0.0.1.beta3.tbz
sha256=96eda206d7eacfb921d5a6bb459254d7f8c507bbc11aa27f1544fb5c73e204c7
sha512=97cf49978fc18946eef5579b004907b2f2a58dc2452446476545385b388eb04bde072020b7a55900be02405f71bebbc919a6039caf636f221167a5d9335ffcce

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.