package flux

  1. Overview
  2. Docs
Composable streaming abstractions with Miou

Install

dune-project
 Dependency

Authors

Maintainers

Sources

flux-0.0.1.beta1.tbz
sha256=ad74df51aaf796f4ed14f56296380a3aa795a8d6f9217b6383c9ac833ff334fc
sha512=4d03ef0130a0df993dd3e1c879c45162e57f48c2535f115f23e572214f365a7a052056c89661b4d7bc198209c0adf57dae6f96ea82b6b5c5f30223b653a29f5c

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.