Module Flux.SinkSource

Sourceval fold : ('r -> 'a -> 'r) -> 'r -> ('a, 'r) sink

fold fn init is a sink that reduces all input elements with the stepping function fn starting with the accumulator value init.

Basic sinks.

Sourceval full : ('a, unit) sink

A full sink taht will not consume any input and will not produce any results.

Sourceval is_full : ('a, 'r) sink -> bool

is_full sink is true if sink is full. Full sinks do not consume any elements but will be initialized to determine if they are full.

Sourceval is_empty : ('a, bool) sink

is_empty is a sink that produces true when it is stopped without consuming any elements.

Sourceval length : ('a, int) sink

Consumes and counts all input elements.

Sourceval drain : ('a, unit) sink

Consumes all elements producing nothing. Useful for triggering actions in effectful streams.

Data sinks.

Sourceval string : (string, string) sink

Consumes and concatenates bytes.

Sourceval list : ('a, 'a list) sink

Puts all input elements into a list.

Sourceval seq : 'a Seq.t -> ('a, 'a Seq.t) sink

seq s puts all input elements into the given s.

Sourceval bqueue : size:int -> ('a, unit) sink * ('a, 'a option) Bqueue.t

bqueue ~size returns a sink which fills the returned bounded-queue. The queue can be consumed by something else cooperatively (or in parallel).

Sourceval array : ('a, 'a array) sink

Puts all input elements into an array.

Sourceval buffer : int -> ('a, 'a array) sink

Similar to array but will only consume n elements.

Sourceval fill : 'r -> ('a, 'r) sink

fill x uses x to fill the sink. This sink will not consume any input and will immediately produce x when used.

Combining sinks.

Sourceval zip : ('a, 'r0) sink -> ('a, 'r1) sink -> ('a, 'r0 * 'r1) sink

zip l r computes both l and r cooperatively with the same input being sent to both sinks. The results of both sinks are produced.

Sourceval both : ('a, 'r0) sink -> ('a, 'r1) sink -> ('a, 'r0 * 'r1) sink

both l r computes both l and r in parallel with the same input being sent to both sinks. The results of both sinks are produced.

NOTE: Please note that this function does not comply with Miou's rules if you attempt to use it in the form of a let-binding and+.

Sourceval unzip : ('a, 'r0) sink -> ('b, 'r1) sink -> ('a * 'b, 'r0 * 'r1) sink

unzip l r is a sink that receives pairs 'a * 'b, sending the first element into l and the second into r. Both sinks are computed cooperatively and their results returned as an output pair.

The sink becomes full when either l or r get full.

Sourcetype ('a, 'b) race =
  1. | Left of 'a
  2. | Right of 'b
  3. | Both of 'a * 'b
Sourceval race : ('a, 'r0) sink -> ('a, 'r1) sink -> ('a, ('r0, 'r1) race) sink
Sourceval each : ?parallel:bool -> init:'a -> merge:('b -> 'a -> 'a) -> ('c -> 'b) -> ('c, 'a) sink

each ?parallel ~init ~merge fn applies fn to all input elements and merge producing results with init. If parallel is true (default is false), fn is executed in parallel to the domain in which the sink is executed. Otherwise, the actions are executed cooperatively. If one of these actions terminates abnormally, the execution of the returned sink raises an exception.

Sourceval premap : ('b -> 'a) -> ('a, 'r) sink -> ('b, 'r) sink

premap fn sink is a sink that premaps the input value.

I/O sinks.

Sourceval file : filename:string -> (string, unit) sink

file ~filename saves string elements into the given file filename.

Sourceval out_channel : ?close:bool -> out_channel -> (string, unit) sink

out_channel ?close oc saves string elements into the given out channel oc. If oc is not stdout and ?close is true (by default), out_channel will close it at the end.

Sourcemodule Syntax : sig ... end
Sourcemodule Infix : sig ... end