CondExt Class

Extensions to the Cond type

DECLARATION
public static class CondExt
NAMESPACE
LanguageExt

Methods

All<A, B>(Cond<A, B>, Func<B, bool>)
SUMMARY

A conditional computation where the input value must match all of the predicates provided to return a positive Some/True state. This is like an if(a && b && c ...) operation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
predicates
Func<B, bool>
The predicates to test the bound value with
DECLARATION
[Pure]
public static Cond<A, B> All<A, B>(this Cond<A, B> self, Func<B, bool> predicates)
RETURNS
Cond<A, B>
A conditional computation
Any<A, B>(Cond<A, B>, Func<B, bool>)
SUMMARY

A conditional computation where the input value can match any of the predicates provided to return a positive Some/True state. This is like an if(a || b || c ...) operation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
predicates
Func<B, bool>
The predicates to test the bound value with
DECLARATION
[Pure]
public static Cond<A, B> Any<A, B>(this Cond<A, B> self, Func<B, bool> predicates)
RETURNS
Cond<A, B>
A conditional computation
Apply<A, B>(A, Func<A, B>)
SUMMARY

Apply a value as the first argument to the function provided.

PARAMETERS
a
A
Value to apply to the function
f
Func<A, B>
Function to apply the value to
REMARKS
This is a general case apply function, however it is especially useful for fluently applying a value to the result of the Cond.Else() extension method.
DECLARATION
[Pure]
public static B Apply<A, B>(this A a, Func<A, B> f)
RETURNS
B
The result of applying the value to the function
Else<A, B>(Cond<A, B>, Func<A, B>)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
f
Func<A, B>
The Else function to run if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<A, B> Else<A, B>(this Cond<A, B> self, Func<A, B> f)
RETURNS
Func<A, B>
The result of the conditional computation
Else<A, B>(Cond<A, B>, Func<B>)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
f
Func<B>
The else function to run if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<A, B> Else<A, B>(this Cond<A, B> self, Func<B> f)
RETURNS
Func<A, B>
The result of the conditional computation
Else<A, B>(Cond<A, B>, B)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
value
B
The else value to use if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<A, B> Else<A, B>(this Cond<A, B> self, B value)
RETURNS
Func<A, B>
The result of the conditional computation
ElseAsync<A, B>(Cond<A, B>, Func<A, B>)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
f
Func<A, B>
The Else function to run if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<Task<A>, Task<B>> ElseAsync<A, B>(this Cond<A, B> self, Func<A, B> f)
RETURNS
Func<Task<A>, Task<B>>
The result of the conditional computation
ElseAsync<A, B>(Cond<A, B>, Func<B>)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
f
Func<B>
The else function to run if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<Task<A>, Task<B>> ElseAsync<A, B>(this Cond<A, B> self, Func<B> f)
RETURNS
Func<Task<A>, Task<B>>
The result of the conditional computation
ElseAsync<A, B>(Cond<A, B>, B)
SUMMARY

Builds a delegate that runs the conditional computation, taking an input value and returning a result value. This would usually be the last thing in a fluent Cond computation.

PARAMETERS
self
Cond<A, B>
The Cond computation to test
value
B
The else value to use if the Cond computation ends up in a None/False state.
DECLARATION
[Pure]
public static Func<Task<A>, Task<B>> ElseAsync<A, B>(this Cond<A, B> self, B value)
RETURNS
Func<Task<A>, Task<B>>
The result of the conditional computation
Filter<A, B>(Cond<A, B>, Func<B, bool>)
SUMMARY

Filter the conditional computation. This is the equivalent of the predicate in an If statement.

PARAMETERS
self
Cond<A, B>
The conditional computation to test
pred
Func<B, bool>
The predicate function
DECLARATION
[Pure]
public static Cond<A, B> Filter<A, B>(this Cond<A, B> self, Func<B, bool> pred)
RETURNS
Cond<A, B>
A conditional computation
Map<A, B, C>(Cond<A, B>, Func<B, C>)
SUMMARY

Functor map of the conditional computation

PARAMETERS
self
Cond<A, B>
The conditional computation to map
map
Func<B, C>
Functor mapping function
DECLARATION
[Pure]
public static Cond<A, C> Map<A, B, C>(this Cond<A, B> self, Func<B, C> map)
RETURNS
Cond<A, C>
A mapped conditional computation
Select<A, B, C>(Cond<A, B>, Func<B, C>)
SUMMARY

Functor map of the conditional computation

PARAMETERS
self
Cond<A, B>
The conditional computation to map
map
Func<B, C>
Functor mapping function
DECLARATION
[Pure]
public static Cond<A, C> Select<A, B, C>(this Cond<A, B> self, Func<B, C> map)
RETURNS
Cond<A, C>
A mapped conditional computation
SelectMany<A, B, C, D>(Cond<A, B>, Func<B, Cond<A, C>>, Func<B, C, D>)
SUMMARY

Monadic bind for conditional computations. Allows nesting of computations that follow the rules of Cond, namely that a None/False result cancels the operation until an Else is encountered.

PARAMETERS
self
Cond<A, B>
bind
Func<B, Cond<A, C>>
project
Func<B, C, D>
DECLARATION
[Pure]
public static Cond<A, D> SelectMany<A, B, C, D>(this Cond<A, B> self, Func<B, Cond<A, C>> bind, Func<B, C, D> project)
RETURNS
Cond<A, D>
Then<A, B>(Cond<A, A>, Func<A, B>)
SUMMARY

Provide the behaviour to run if the condition of the Cond computation is in a Some/True state. This is equivalent to the 'then' part of an If/Then/Else operation.

PARAMETERS
self
Cond<A, A>
The Cond computation to compose with
f
Func<A, B>
The 'then' computation
DECLARATION
[Pure]
public static Cond<A, B> Then<A, B>(this Cond<A, A> self, Func<A, B> f)
RETURNS
Cond<A, B>
A conditional computation
Then<A, B>(Cond<A, A>, Func<B>)
SUMMARY

Provide the behaviour to run if the condition of the Cond computation is in a Some/True state. This is equivalent to the 'then' part of an If/Then/Else operation.

PARAMETERS
self
Cond<A, A>
The Cond computation to compose with
f
Func<B>
The 'then' computation
DECLARATION
[Pure]
public static Cond<A, B> Then<A, B>(this Cond<A, A> self, Func<B> f)
RETURNS
Cond<A, B>
A conditional computation
Then<A, B>(Cond<A, A>, B)
SUMMARY

Provide the behaviour to run if the condition of the Cond computation is in a Some/True state. This is equivalent to the 'then' part of an If/Then/Else operation.

PARAMETERS
self
Cond<A, A>
The Cond computation to compose with
value
B
The 'then' value
DECLARATION
[Pure]
public static Cond<A, B> Then<A, B>(this Cond<A, A> self, B value)
RETURNS
Cond<A, B>
A conditional computation
Where<A, B>(Cond<A, B>, Func<B, bool>)
SUMMARY

Filter the conditional computation. This is the equivalent of the predicate in an If statement.

PARAMETERS
self
Cond<A, B>
The conditional computation to test
pred
Func<B, bool>
The predicate function
DECLARATION
[Pure]
public static Cond<A, B> Where<A, B>(this Cond<A, B> self, Func<B, bool> pred)
RETURNS
Cond<A, B>
A conditional computation