package lambda_streams

  1. Overview
  2. Docs
Lambda-based streaming library

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.2.tar.gz
md5=8c1ce04ee769b56434696bd57aee1a5b
sha512=9bb794f3852da60e536277f41ca5c6db678e5f0f5100ca13bf4c054a8d5c17834891c9ba2d73ddd35dc4f52f4b8be6076611b8f8c413eb6e93d61c161c67f9aa

doc/lambda_streams/Lambda_streams/Sync/index.html

Module Lambda_streams.SyncSource

Sourcetype 'a input = private unit -> 'a

Generalizes the notion of a synchronous, readable input stream.

Sourcetype 'a output = private 'a -> unit

Generalizes the notion of a synchronous, writable output stream.

Sourcetype 'a connection = ('a input, unit output) Connection.t

Represents a connection-based input stream with an output stream to close it.

Sourceval make_input : (unit -> 'a) -> 'a input
Sourceval make_output : ('a -> unit) -> 'a output
Sourceval make_mutator : initial:'a -> 'a input * 'a output

Creates a mutator: a pair of input and output streams that together behave like a mutable variable. Mutating the value is accomplished by sending data to the output stream. Fetching the current value is done by reading the input stream.

Sourceval pure : 'a -> 'a input
Sourceval enumerate : unit -> int input

Creates an input stream that enumerates the natural numbers.

Sourceval next : 'a input -> 'a

Gets the next value (or current value if it's a behavior) from the input stream.

Sourceval send : 'a -> 'a output -> unit

Sends a single value to the output stream. Semantically equivalent to:

Finite.Sync.pure value |> Finite.Sync.pipe output_stream

But it's more efficient because it doesn't involve instatiating an input stream.

Sourceval pipe : 'a output -> 'a input -> unit

Pipes an input stream into an output stream.

Sourceval accumulate : int -> ('b -> 'a -> 'b) -> 'b -> 'a input -> 'b

Like fold_left but for infinite streams, ending at signal n.

Sourceval map : ('a -> 'b) -> 'a input -> 'b input
Sourceval filter : ('a -> bool) -> 'a input -> 'a input

Filters the input stream based on a predicate. This function returns a stream that, when invoked, will continue to invoke the original input stream until a value that satisfies the predicate is given, which is then returned. This means that an invocation of the returned stream may possibly never terminate.

For example:

enumerate () |> filter ((>=) 10)

Will block and never terminate after 10 invocations, because after those invocations any future values of enumerate () will never be less than 10.

On the other hand,

 let is_even x = x mod 2 = 0 in
 enumerate () |> filter is_even

Will always return a value, because there will always be a successor to a natural number that is even (every other number).

Sourceval scan : ('b -> 'a -> 'b) -> 'b -> 'a input -> 'b input
OCaml

Innovation. Community. Security.