Table of Contents

Class MaybeLinqExtensionsTaskAsync

Namespace
Trellis
Assembly
Trellis.Core.dll

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

public static class MaybeLinqExtensionsTaskAsync
Inheritance
MaybeLinqExtensionsTaskAsync
Inherited Members

Remarks

These overloads match the C# query-pattern signatures (Select, SelectMany, Where) for an async receiver and async continuations. With them, from x in FindAsync() compiles when FindAsync() returns Task<Maybe<T>>, removing the need to await each step and re-enter a sync query block.

The semantics mirror the synchronous MaybeLinqExtensions overloads: a None short-circuits subsequent steps; only present values are passed to the next selector.

Methods

SelectMany<TSource, TCollection, TResult>(Task<Maybe<TSource>>, Func<TSource, Task<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).

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

Parameters

source Task<Maybe<TSource>>

The asynchronous source Maybe.

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

An async function returning the intermediate Maybe.

resultSelector Func<TSource, TCollection, TResult>

A synchronous function combining the source and intermediate values.

Returns

Task<Maybe<TResult>>

A 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>(Task<Maybe<TIn>>, Func<TIn, TOut>)

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

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

Parameters

maybeTask Task<Maybe<TIn>>

The asynchronous Maybe to project.

selector Func<TIn, TOut>

The projection function applied to the value.

Returns

Task<Maybe<TOut>>

A 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>(Task<Maybe<TSource>>, Func<TSource, bool>)

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

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

Parameters

source Task<Maybe<TSource>>

The asynchronous Maybe to filter.

predicate Func<TSource, bool>

The predicate to test the value.

Returns

Task<Maybe<TSource>>

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

Type Parameters

TSource

Type of the source value.