Ferrous API Reference

All Types / Ferrous.Results

class ResultExtensions

public static class ResultExtensions

Async and LINQ query comprehension combinators for Result<T, TError> and Option<T>.

Methods

public static Result<TResult, TError> Select<T, TError, TResult>(
        this Result<T, TError> result,
        Func<T, TResult> selector)

LINQ select projection for Result<T, TError>.

public static Result<TResult, TError> SelectMany<T, TError, TIntermediate, TResult>(
        this Result<T, TError> result,
        Func<T, Result<TIntermediate, TError>> binder,
        Func<T, TIntermediate, TResult> projector)

LINQ from ... from ... select monadic bind for Result<T, TError>, enabling ergonomic ?-style error propagation chains.

public static Option<TResult> Select<T, TResult>(
        this Option<T> option,
        Func<T, TResult> selector)

LINQ select projection for Option<T>.

public static Option<TResult> SelectMany<T, TIntermediate, TResult>(
        this Option<T> option,
        Func<T, Option<TIntermediate>> binder,
        Func<T, TIntermediate, TResult> projector)

LINQ from ... from ... select monadic bind for Option<T>.

public static async Task<Result<TResult, TError>> MapAsync<T, TError, TResult>(
        this Task<Result<T, TError>> resultTask,
        Func<T, Task<TResult>> selector)

Asynchronously maps the Ok value of a Task<TResult> producing a Result<T, TError>.

public static async Task<Result<TResult, TError>> AndThenAsync<T, TError, TResult>(
        this Task<Result<T, TError>> resultTask,
        Func<T, Task<Result<TResult, TError>>> binder)

Asynchronously chains another Result<T, TError>-producing operation when Ok.

public static async Task<Result<T, TNewError>> OrElseAsync<T, TError, TNewError>(
        this Task<Result<T, TError>> resultTask,
        Func<TError, Task<Result<T, TNewError>>> recovery)

Asynchronously recovers from an Err result.

public static async Task<TResult> MatchAsync<T, TError, TResult>(
        this Task<Result<T, TError>> resultTask,
        Func<T, Task<TResult>> onOk,
        Func<TError, Task<TResult>> onErr)

Asynchronously matches both Ok and Err branches of a Task<TResult>.

public static async ValueTask<Result<TResult, TError>> MapAsync<T, TError, TResult>(
        this ValueTask<Result<T, TError>> resultTask,
        Func<T, ValueTask<TResult>> selector)

Asynchronously maps the Ok value of a ValueTask<TResult> producing a Result<T, TError>.

public static async ValueTask<Result<TResult, TError>> AndThenAsync<T, TError, TResult>(
        this ValueTask<Result<T, TError>> resultTask,
        Func<T, ValueTask<Result<TResult, TError>>> binder)

Asynchronously chains another Result<T, TError>-producing ValueTask<TResult> when Ok.