FSharpPlus


ValueOption Module

Additional operations on ValueOption

Functions and values

Function or value Description

ValueOption.apply f x

Full Usage: ValueOption.apply f x

Parameters:
    f : ('T -> 'U) voption - The option function.
    x : 'T voption - The option value.

Returns: 'U voption An option of the function applied to the value, or ValueNone if either the function or the value is ValueNone.

Applies an option value to an option function.

f : ('T -> 'U) voption

The option function.

x : 'T voption

The option value.

Returns: 'U voption

An option of the function applied to the value, or ValueNone if either the function or the value is ValueNone.

ValueOption.ofOption source

Full Usage: ValueOption.ofOption source

Parameters:
    source : 'T option

Returns: 'T voption

Converts an Option to a ValueOption.

source : 'T option
Returns: 'T voption

ValueOption.ofPair (arg1, arg2)

Full Usage: ValueOption.ofPair (arg1, arg2)

Parameters:
    arg0 : bool
    arg1 : 'T

Returns: 'T voption ValueSome if bool is `true`, ValueNone otherwise.

Converts pair of bool and value to ValueOption.

Useful for handling C# try pattern with `out` parameter. E.g. `Int.TryParse` or `Dictionary.TryGetValue`.

arg0 : bool
arg1 : 'T
Returns: 'T voption

ValueSome if bool is `true`, ValueNone otherwise.

ValueOption.ofResult source

Full Usage: ValueOption.ofResult source

Parameters:
    source : Result<'T, 'Error> - The Result value.

Returns: 'T voption The resulting option value.

Converts a Result to an option.

The error value (if any) is lost.

source : Result<'T, 'Error>

The Result value.

Returns: 'T voption

The resulting option value.

ValueOption.protect f x

Full Usage: ValueOption.protect f x

Parameters:
    f : 'T -> 'U
    x : 'T

Returns: 'U voption

Creates a safe version of the supplied function, which returns an voption<'U> instead of throwing exceptions.

f : 'T -> 'U
x : 'T
Returns: 'U voption

ValueOption.toOption source

Full Usage: ValueOption.toOption source

Parameters:
Returns: 'T option

Converts a ValueOption to an Option.

source : ValueOption<'T>
Returns: 'T option

ValueOption.toResult source

Full Usage: ValueOption.toResult source

Parameters:
    source : 'T voption - The option value.

Returns: Result<'T, unit> The resulting Result value.

Converts an option to a Result.

source : 'T voption

The option value.

Returns: Result<'T, unit>

The resulting Result value.

ValueOption.toResultWith errorValue source

Full Usage: ValueOption.toResultWith errorValue source

Parameters:
    errorValue : 'Error - The error value to be used in case of ValueNone.
    source : 'T voption - The option value.

Returns: Result<'T, 'Error> The resulting Result value.

Converts an option to a Result.

errorValue : 'Error

The error value to be used in case of ValueNone.

source : 'T voption

The option value.

Returns: Result<'T, 'Error>

The resulting Result value.

ValueOption.unzip v

Full Usage: ValueOption.unzip v

Parameters:
    v : ('T * 'U) voption - The value.

Returns: 'T voption * 'U voption The resulting tuple.

If value is ValueSome, returns both of them tupled. Otherwise it returns ValueNone tupled.

v : ('T * 'U) voption

The value.

Returns: 'T voption * 'U voption

The resulting tuple.

ValueOption.zip x y

Full Usage: ValueOption.zip x y

Parameters:
    x : 'T voption - The first value.
    y : 'U voption - The second value.

Returns: ('T * 'U) voption The resulting option.

If both value are ValueSome, returns both of them tupled. Otherwise it returns ValueNone.

x : 'T voption

The first value.

y : 'U voption

The second value.

Returns: ('T * 'U) voption

The resulting option.

ValueOption.zip3 x y z

Full Usage: ValueOption.zip3 x y z

Parameters:
    x : 'T voption - The first value.
    y : 'U voption - The second value.
    z : 'V voption - The third value.

Returns: ('T * 'U * 'V) voption The resulting option.

If all 3 value are ValueSome, returns them tupled. Otherwise it returns ValueNone.

x : 'T voption

The first value.

y : 'U voption

The second value.

z : 'V voption

The third value.

Returns: ('T * 'U * 'V) voption

The resulting option.