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
sourceValueTask<Maybe<TSource>>The asynchronous source Maybe.
collectionSelectorFunc<TSource, ValueTask<Maybe<TCollection>>>An async function returning the intermediate Maybe.
resultSelectorFunc<TSource, TCollection, TResult>A synchronous function combining the source and intermediate values.
Returns
- ValueTask<Maybe<TResult>>
A value task producing the combined Maybe, or
Noneif any step has no value.
Type Parameters
TSourceType of the source value.
TCollectionType of the intermediate collection value.
TResultType 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
maybeTaskValueTask<Maybe<TIn>>The asynchronous Maybe to project.
selectorFunc<TIn, TOut>The projection function applied to the value.
Returns
- ValueTask<Maybe<TOut>>
A value task producing a Maybe with the projected value, or
Noneif the input has no value.
Type Parameters
TInThe type of the input value.
TOutThe 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
sourceValueTask<Maybe<TSource>>The asynchronous Maybe to filter.
predicateFunc<TSource, bool>The predicate to test the value.
Returns
- ValueTask<Maybe<TSource>>
The original Maybe when the predicate is true; otherwise
None.Noneinputs stayNone.
Type Parameters
TSourceType of the source value.