Table of Contents

Class BindZipExtensions

Namespace
Trellis
Assembly
Trellis.Core.dll

Extension methods that bind a function to a Result and zip the original value with the new value into a tuple. Enables sequential accumulation of values through a pipeline.

public static class BindZipExtensions
Inheritance
BindZipExtensions
Inherited Members

Remarks

BindZip differs from Bind in that it preserves the original value(s) and appends the new value.

var result = GetOrder(id)
    .BindZip(order => GetCustomer(order.CustomerId))
    .BindZip((order, customer) => GetInventory(order.ProductId))
    .BindZip((order, customer, inventory) => CalculateShipping(order, inventory));

Methods

BindZip<T1, T2>(Result<T1>, Func<T1, Result<T2>>)

Binds a function to the Result value and zips both values into a tuple on success. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2)> BindZip<T1, T2>(this Result<T1> result, Func<T1, Result<T2>> func)

Parameters

result Result<T1>

The result to bind and zip.

func Func<T1, Result<T2>>

The function to call if the result is successful.

Returns

Result<(T1, T2)>

A tuple result combining both values on success; otherwise the failure.

Type Parameters

T1

Type of the input result value.

T2

Type of the new result value.

BindZip<T1, T2, T3>(Result<(T1, T2)>, Func<T1, T2, Result<T3>>)

Binds a function that receives a 2-tuple's components and zips the result into a 3-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3)> BindZip<T1, T2, T3>(this Result<(T1, T2)> result, Func<T1, T2, Result<T3>> func)

Parameters

result Result<(T1, T2)>

The 2-tuple result to bind and zip.

func Func<T1, T2, Result<T3>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3)>

A 3-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of the new value to append.

BindZip<T1, T2, T3, T4>(Result<(T1, T2, T3)>, Func<T1, T2, T3, Result<T4>>)

Binds a function that receives a 3-tuple's components and zips the result into a 4-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4)> BindZip<T1, T2, T3, T4>(this Result<(T1, T2, T3)> result, Func<T1, T2, T3, Result<T4>> func)

Parameters

result Result<(T1, T2, T3)>

The 3-tuple result to bind and zip.

func Func<T1, T2, T3, Result<T4>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4)>

A 4-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of the new value to append.

BindZip<T1, T2, T3, T4, T5>(Result<(T1, T2, T3, T4)>, Func<T1, T2, T3, T4, Result<T5>>)

Binds a function that receives a 4-tuple's components and zips the result into a 5-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4, T5)> BindZip<T1, T2, T3, T4, T5>(this Result<(T1, T2, T3, T4)> result, Func<T1, T2, T3, T4, Result<T5>> func)

Parameters

result Result<(T1, T2, T3, T4)>

The 4-tuple result to bind and zip.

func Func<T1, T2, T3, T4, Result<T5>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4, T5)>

A 5-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of element 4 in the input tuple.

T5

The type of the new value to append.

BindZip<T1, T2, T3, T4, T5, T6>(Result<(T1, T2, T3, T4, T5)>, Func<T1, T2, T3, T4, T5, Result<T6>>)

Binds a function that receives a 5-tuple's components and zips the result into a 6-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4, T5, T6)> BindZip<T1, T2, T3, T4, T5, T6>(this Result<(T1, T2, T3, T4, T5)> result, Func<T1, T2, T3, T4, T5, Result<T6>> func)

Parameters

result Result<(T1, T2, T3, T4, T5)>

The 5-tuple result to bind and zip.

func Func<T1, T2, T3, T4, T5, Result<T6>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4, T5, T6)>

A 6-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of element 4 in the input tuple.

T5

The type of element 5 in the input tuple.

T6

The type of the new value to append.

BindZip<T1, T2, T3, T4, T5, T6, T7>(Result<(T1, T2, T3, T4, T5, T6)>, Func<T1, T2, T3, T4, T5, T6, Result<T7>>)

Binds a function that receives a 6-tuple's components and zips the result into a 7-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4, T5, T6, T7)> BindZip<T1, T2, T3, T4, T5, T6, T7>(this Result<(T1, T2, T3, T4, T5, T6)> result, Func<T1, T2, T3, T4, T5, T6, Result<T7>> func)

Parameters

result Result<(T1, T2, T3, T4, T5, T6)>

The 6-tuple result to bind and zip.

func Func<T1, T2, T3, T4, T5, T6, Result<T7>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4, T5, T6, T7)>

A 7-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of element 4 in the input tuple.

T5

The type of element 5 in the input tuple.

T6

The type of element 6 in the input tuple.

T7

The type of the new value to append.

BindZip<T1, T2, T3, T4, T5, T6, T7, T8>(Result<(T1, T2, T3, T4, T5, T6, T7)>, Func<T1, T2, T3, T4, T5, T6, T7, Result<T8>>)

Binds a function that receives a 7-tuple's components and zips the result into a 8-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> BindZip<T1, T2, T3, T4, T5, T6, T7, T8>(this Result<(T1, T2, T3, T4, T5, T6, T7)> result, Func<T1, T2, T3, T4, T5, T6, T7, Result<T8>> func)

Parameters

result Result<(T1, T2, T3, T4, T5, T6, T7)>

The 7-tuple result to bind and zip.

func Func<T1, T2, T3, T4, T5, T6, T7, Result<T8>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4, T5, T6, T7, T8)>

A 8-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of element 4 in the input tuple.

T5

The type of element 5 in the input tuple.

T6

The type of element 6 in the input tuple.

T7

The type of element 7 in the input tuple.

T8

The type of the new value to append.

BindZip<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Result<(T1, T2, T3, T4, T5, T6, T7, T8)>, Func<T1, T2, T3, T4, T5, T6, T7, T8, Result<T9>>)

Binds a function that receives a 8-tuple's components and zips the result into a 9-tuple. If the source or the function result is a failure, returns that failure.

public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> BindZip<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Result<(T1, T2, T3, T4, T5, T6, T7, T8)> result, Func<T1, T2, T3, T4, T5, T6, T7, T8, Result<T9>> func)

Parameters

result Result<(T1, T2, T3, T4, T5, T6, T7, T8)>

The 8-tuple result to bind and zip.

func Func<T1, T2, T3, T4, T5, T6, T7, T8, Result<T9>>

The function to call with the tuple components if the result is successful.

Returns

Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>

A 9-tuple result combining all values on success; otherwise the failure.

Type Parameters

T1

The type of element 1 in the input tuple.

T2

The type of element 2 in the input tuple.

T3

The type of element 3 in the input tuple.

T4

The type of element 4 in the input tuple.

T5

The type of element 5 in the input tuple.

T6

The type of element 6 in the input tuple.

T7

The type of element 7 in the input tuple.

T8

The type of element 8 in the input tuple.

T9

The type of the new value to append.