Yaaf.FSharp.Helper


AsyncSeq

Defined in Yaaf.FSharp.Helper.dll.

Module with helper functions for working with asynchronous sequences

Nested types and modules

TypeDescription
AsyncSeqBuilder

Computation builder that allows creating of asynchronous sequences using the 'asyncSeq { ... }' syntax

Functions and values

Function or valueDescription
append seq1 seq2
Signature: seq1:AsyncSeq<'T> -> seq2:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Yields all elements of the first asynchronous sequence and then all elements of the second asynchronous sequence.

asyncSeq
Signature: AsyncSeqBuilder

Builds an asynchronou sequence using the computation builder syntax

cache input
Signature: input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Create a new asynchronous sequence that caches all elements of the sequence specified as the input. When accessing the resulting sequence multiple times, the input will still be evaluated only once

choose f input
Signature: f:('T -> '?22546 option) -> input:AsyncSeq<'T> -> AsyncSeq<'?22546>
Type parameters: 'T, '?22546

Same as AsyncSeq.chooseAsync, but the specified function is synchronous and processes the input element immediately.

chooseAsync f input
Signature: f:('T -> Async<'R option>) -> input:AsyncSeq<'T> -> AsyncSeq<'R>
Type parameters: 'T, 'R

Asynchronously iterates over the input sequence and generates 'x' for every input element for which the specified asynchronous function returned 'Some(x)' The specified function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

collect f input
Signature: f:('T -> AsyncSeq<'TResult>) -> input:AsyncSeq<'T> -> AsyncSeq<'TResult>
Type parameters: 'T, 'TResult

Creates an asynchronou sequence that iterates over the given input sequence. For every input element, it calls the the specified function and iterates over all elements generated by that asynchronous sequence. This is the 'bind' operation of the computation expression (exposed using the 'for' keyword in asyncSeq computation).

empty
Signature: AsyncSeq<'T>
Type parameters: 'T

Creates an empty asynchronou sequence that immediately ends

filter f input
Signature: f:('T -> bool) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Same as AsyncSeq.filterAsync, but the specified predicate is synchronous and processes the input element immediately.

filterAsync f input
Signature: f:('T -> Async<bool>) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Builds a new asynchronous sequence whose elements are those from the input sequence for which the specified function returned true. The specified function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

firstOrDefault def input
Signature: def:'T -> input:AsyncSeq<'T> -> Async<'T>
Type parameters: 'T

Asynchronously returns the first element that was generated by the given asynchronous sequence (or the specified default value).

fold f state input
Signature: f:('TState -> 'T -> 'TState) -> state:'TState -> input:AsyncSeq<'T> -> Async<'TState>
Type parameters: 'TState, 'T

Same as AsyncSeq.foldAsync, but the specified function is synchronous and returns the result of aggregation immediately.

foldAsync f state input
Signature: f:('TState -> 'T -> Async<'TState>) -> state:'TState -> input:AsyncSeq<'T> -> Async<'TState>
Type parameters: 'TState, 'T

Aggregates the elements of the input asynchronous sequence using the specified 'aggregation' function. The result is an asynchronous workflow that returns the final result. The aggregation function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

iter f input
Signature: f:('T -> unit) -> input:AsyncSeq<'T> -> Async<unit>
Type parameters: 'T

Same as AsyncSeq.iterAsync, but the specified function is synchronous and performs the side-effect immediately.

iterAsync f input
Signature: f:('T -> Async<unit>) -> input:AsyncSeq<'T> -> Async<unit>
Type parameters: 'T

Iterates over the input sequence and calls the specified function for every value (to perform some side-effect asynchronously). The specified function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

lastOrDefault def input
Signature: def:'T -> input:AsyncSeq<'T> -> Async<'T>
Type parameters: 'T

Asynchronously returns the last element that was generated by the given asynchronous sequence (or the specified default value).

map f input
Signature: f:('T -> 'b) -> input:AsyncSeq<'T> -> AsyncSeq<'b>
Type parameters: 'T, 'b

Same as AsyncSeq.mapAsync, but the specified function is synchronous and returns the result of projection immediately.

mapAsync f input
Signature: f:('T -> Async<'TResult>) -> input:AsyncSeq<'T> -> AsyncSeq<'TResult>
Type parameters: 'T, 'TResult

Builds a new asynchronous sequence whose elements are generated by applying the specified function to all elements of the input sequence. The specified function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

ofObservable input
Signature: input:IObservable<'?22567> -> AsyncSeq<'?22567>
Type parameters: '?22567

Converts observable to an asynchronous sequence. Values that are produced by the observable while the asynchronous sequence is blocked are discarded (this function doesn't guarantee that asynchronou ssequence will return all values produced by the observable)

ofObservableBuffered input
Signature: input:IObservable<'b> -> AsyncSeq<'b>
Type parameters: 'b

Converts observable to an asynchronous sequence. Values that are produced by the observable while the asynchronous sequence is blocked are stored to an unbounded buffer and are returned as next elements of the async sequence.

ofSeq input
Signature: input:seq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Creates an asynchronous sequence that lazily takes element from an input synchronous sequence and returns them one-by-one.

pairwise input
Signature: input:AsyncSeq<'T> -> AsyncSeq<'T * 'T>
Type parameters: 'T

Returns an asynchronous sequence that returns pairs containing an element from the input sequence and its predecessor. Empty sequence is returned for singleton input sequence.

scan f state input
Signature: f:('TState -> 'T -> 'TState) -> state:'TState -> input:AsyncSeq<'T> -> AsyncSeq<'TState>
Type parameters: 'TState, 'T

Same as AsyncSeq.scanAsync, but the specified function is synchronous and returns the result of aggregation immediately.

scanAsync f state input
Signature: f:('TState -> 'T -> Async<'TState>) -> state:'TState -> input:AsyncSeq<'T> -> AsyncSeq<'TState>
Type parameters: 'TState, 'T

Aggregates the elements of the input asynchronous sequence using the specified 'aggregation' function. The result is an asynchronous sequence of intermediate aggregation result. The aggregation function is asynchronous (and the input sequence will be asked for the next element after the processing of an element completes).

singleton v
Signature: v:'T -> AsyncSeq<'T>
Type parameters: 'T

Creates an asynchronous sequence that generates a single element and then ends

skip count input
Signature: count:int -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Skips the first N elements of an asynchronous sequence and then returns the rest of the sequence unmodified.

skipWhile p input
Signature: p:('T -> bool) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Skips elements from an asynchronous sequence while the specified predicate holds and then returns the rest of the sequence. The predicate is evaluated asynchronously.

skipWhileAsync p input
Signature: p:('T -> Async<bool>) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Skips elements from an asynchronous sequence while the specified predicate holds and then returns the rest of the sequence. The predicate is evaluated asynchronously.

take count input
Signature: count:int -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Returns the first N elements of an asynchronous sequence

takeWhile p input
Signature: p:('T -> bool) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Returns elements from an asynchronous sequence while the specified predicate holds. The predicate is evaluated synchronously.

takeWhileAsync p input
Signature: p:('T -> Async<bool>) -> input:AsyncSeq<'T> -> AsyncSeq<'T>
Type parameters: 'T

Returns elements from an asynchronous sequence while the specified predicate holds. The predicate is evaluated asynchronously.

toBlockingSeq input
Signature: input:AsyncSeq<'T> -> seq<'T>
Type parameters: 'T

Converts asynchronous sequence to a synchronous blocking sequence. The elements of the asynchronous sequence are consumed lazily.

toObservable aseq
Signature: aseq:AsyncSeq<'?22569> -> IObservable<'?22569>
Type parameters: '?22569

Converts asynchronous sequence to an IObservable<_>. When the client subscribes to the observable, a new copy of asynchronous sequence is started and is sequentially iterated over (at the maximal possible speed). Disposing of the observer cancels the iteration over asynchronous sequence.

zip input1 input2
Signature: input1:AsyncSeq<'T1> -> input2:AsyncSeq<'T2> -> AsyncSeq<'T1 * 'T2>
Type parameters: 'T1, 'T2

Combines two asynchronous sequences into a sequence of pairs. The values from sequences are retrieved in parallel.

Type extensions

Type extensionDescription
For(seq, action)
Signature: (seq:AsyncSeq<'T> * action:('T -> Async<unit>)) -> Async<unit>
Type parameters: 'T
Fork me on GitHub