Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Static Public Member Functions | List of all members
Loyc.Maybe Class Reference

Source file:

Static Public Member Functions

static Maybe< T > Value< T > (T value)
 Returns new Maybe<T>(value). (exists for type inference) More...
 
static Maybe< T > AsMaybe< T > (this Nullable< T > val)
 Creates a Maybe{T}, using Maybe{T}.NoValue if and only if the input is null. More...
 
static Maybe< T > AsMaybe< T > (this T val)
 Creates a Maybe{T}, using Maybe{T}.NoValue if and only if the input is null. More...
 
static T OrNull< T > (this Maybe< T > val)
 Converts Maybe{T} to a Nullable{T} having the same HasValue property. More...
 
static T Or< M, T > (this M maybe, T defaultValue)
 Converts IMaybe{T} to T, returning a default value if HasValue is false. More...
 
static T Or< M, T > (this M maybe, Func< T > getDefaultValue)
 Converts IMaybe{T} to T, calling a factory function if HasValue is false. More...
 
static void Then< T > (this IMaybe< T > maybe, Action< T > then)
 Runs a function if and only if IMaybe{T}.HasValue. More...
 
static R Then< T, R > (this IMaybe< T > maybe, Func< T, R > then, Func< R > @else)
 Runs one of two functions depending on whether IMaybe{T}.HasValue. More...
 
static R Then< T, R > (this IMaybe< T > maybe, Func< T, R > then, R defaultValue)
 Runs a function if and only if IMaybe{T}.HasValue, returning a default value otherwise. More...
 

Member Function Documentation

static Maybe<T> Loyc.Maybe.AsMaybe< T > ( this Nullable< T >  val)
inlinestatic

Creates a Maybe{T}, using Maybe{T}.NoValue if and only if the input is null.

Type Constraints
T :struct 
static Maybe<T> Loyc.Maybe.AsMaybe< T > ( this T  val)
inlinestatic

Creates a Maybe{T}, using Maybe{T}.NoValue if and only if the input is null.

Type Constraints
T :class 
static T Loyc.Maybe.Or< M, T > ( this M  maybe,
defaultValue 
)
static

Converts IMaybe{T} to T, returning a default value if HasValue is false.

This is like the ?? operator of T?.

Type Constraints
M :IMaybe<T> 
M :maybe.HasValue 
M :maybe.Value 
M :defaultValue 
static T Loyc.Maybe.Or< M, T > ( this M  maybe,
Func< T >  getDefaultValue 
)
static

Converts IMaybe{T} to T, calling a factory function if HasValue is false.

This is like the ?? operator of T?.

Type Constraints
M :IMaybe<T> 
M :maybe.HasValue 
M :maybe.Value 
M :getDefaultValue() 
static T Loyc.Maybe.OrNull< T > ( this Maybe< T >  val)
inlinestatic

Converts Maybe{T} to a Nullable{T} having the same HasValue property.

Type Constraints
T :struct 
static void Loyc.Maybe.Then< T > ( this IMaybe< T >  maybe,
Action< T >  then 
)
inlinestatic

Runs a function if and only if IMaybe{T}.HasValue.

static R Loyc.Maybe.Then< T, R > ( this IMaybe< T >  maybe,
Func< T, R >  then,
Func< R > @  else 
)
static

Runs one of two functions depending on whether IMaybe{T}.HasValue.

static R Loyc.Maybe.Then< T, R > ( this IMaybe< T >  maybe,
Func< T, R >  then,
defaultValue 
)
static

Runs a function if and only if IMaybe{T}.HasValue, returning a default value otherwise.

static Maybe<T> Loyc.Maybe.Value< T > ( value)
inlinestatic

Returns new Maybe<T>(value). (exists for type inference)