Table of Contents

Class MaybeLinqExtensionsValueTaskAsync

Namespace
Trellis
Assembly
Trellis.Core.dll

Provides LINQ query expression support for ValueTask<TResult> of Maybe<T>, enabling C# query syntax over fully asynchronous Maybe-returning operations that may complete synchronously.

public static class MaybeLinqExtensionsValueTaskAsync
Inheritance
MaybeLinqExtensionsValueTaskAsync
Inherited Members

Remarks

These overloads match the C# query-pattern signatures (Select, SelectMany, Where) for an async receiver and async continuations. Semantics mirror MaybeLinqExtensions: a None short-circuits subsequent steps; only present values flow through.

Methods

SelectMany<TSource, TCollection, TResult>(ValueTask<Maybe<TSource>>, Func<TSource, ValueTask<Maybe<TCollection>>>, Func<TSource, TCollection, TResult>)

Projects the value of an awaited Maybe<T> through an async collection selector and combines the results (LINQ SelectMany over async/async, ValueTask variant).

public static ValueTask<Maybe<TResult>> SelectMany<TSource, TCollection, TResult>(this ValueTask<Maybe<TSource>> source, Func<TSource, ValueTask<Maybe<TCollection>>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector) where TSource : notnull where TCollection : notnull where TResult : notnull

Parameters

source ValueTask<Maybe<TSource>>

The asynchronous source Maybe.

collectionSelector Func<TSource, ValueTask<Maybe<TCollection>>>

An async function returning the intermediate Maybe.

resultSelector Func<TSource, TCollection, TResult>

A synchronous function combining the source and intermediate values.

Returns

ValueTask<Maybe<TResult>>

A value task producing the combined Maybe, or None if any step has no value.

Type Parameters

TSource

Type of the source value.

TCollection

Type of the intermediate collection value.

TResult

Type of the final projected value.

Select<TIn, TOut>(ValueTask<Maybe<TIn>>, Func<TIn, TOut>)

Projects the value of an awaited Maybe<T> using a synchronous selector (LINQ Select over ValueTask<TResult>).

public static ValueTask<Maybe<TOut>> Select<TIn, TOut>(this ValueTask<Maybe<TIn>> maybeTask, Func<TIn, TOut> selector) where TIn : notnull where TOut : notnull

Parameters

maybeTask ValueTask<Maybe<TIn>>

The asynchronous Maybe to project.

selector Func<TIn, TOut>

The projection function applied to the value.

Returns

ValueTask<Maybe<TOut>>

A value task producing a Maybe with the projected value, or None if the input has no value.

Type Parameters

TIn

The type of the input value.

TOut

The type of the output value.

Where<TSource>(ValueTask<Maybe<TSource>>, Func<TSource, bool>)

Filters an awaited Maybe<T> by a synchronous predicate (LINQ Where over ValueTask<TResult>).

public static ValueTask<Maybe<TSource>> Where<TSource>(this ValueTask<Maybe<TSource>> source, Func<TSource, bool> predicate) where TSource : notnull

Parameters

source ValueTask<Maybe<TSource>>

The asynchronous Maybe to filter.

predicate Func<TSource, bool>

The predicate to test the value.

Returns

ValueTask<Maybe<TSource>>

The original Maybe when the predicate is true; otherwise None. None inputs stay None.

Type Parameters

TSource

Type of the source value.