Table of Contents

Class BindExtensions

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Provides extension methods for binding (chaining) operations over Result values.

public static class BindExtensions
Inheritance
BindExtensions
Inherited Members

Remarks

Bind is the core operation in Railway Oriented Programming. It allows you to chain together operations that can fail, automatically short-circuiting on the first failure. If the input Result is a success, the bind function is called with the value. If the input Result is a failure, the bind function is skipped and the failure is propagated.

Methods

Bind<TValue, TResult>(Result<TValue>, Func<TValue, Result<TResult>>)

Binds the result to a function that returns a new result. If the starting result is a success, the function is called with the value. If the starting result is a failure, the function is skipped and the failure is returned.

public static Result<TResult> Bind<TValue, TResult>(this Result<TValue> result, Func<TValue, Result<TResult>> func)

Parameters

result Result<TValue>

The result to bind.

func Func<TValue, Result<TResult>>

The function to call if the result is successful.

Returns

Result<TResult>

A new result from the function if success; otherwise the original failure.

Type Parameters

TValue

Type of the input result value.

TResult

Type of the output result value.