FSharpPlus


Option Module

Additional operations on Option

Functions and values

Function or value Description

Option.apply f x

Full Usage: Option.apply f x

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

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

Applies an option value to an option function.

f : ('T -> 'U) option

The option function.

x : 'T option

The option value.

Returns: 'U option

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

Option.ofPair (arg1, arg2)

Full Usage: Option.ofPair (arg1, arg2)

Parameters:
    arg0 : bool
    arg1 : 'T

Returns: 'T option Some if bool is `true`, None otherwise.

Converts pair of bool and value to Option.

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

arg0 : bool
arg1 : 'T
Returns: 'T option

Some if bool is `true`, None otherwise.

Option.ofResult source

Full Usage: Option.ofResult source

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

Returns: 'T option 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 option

The resulting option value.

Option.protect f x

Full Usage: Option.protect f x

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

Returns: 'U option

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

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

Option.toResult source

Full Usage: Option.toResult source

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

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

Converts an option to a Result.

source : 'T option

The option value.

Returns: Result<'T, unit>

The resulting Result value.

Option.toResultWith errorValue source

Full Usage: Option.toResultWith errorValue source

Parameters:
    errorValue : 'Error - The error value to be used in case of None.
    source : 'T option - 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 None.

source : 'T option

The option value.

Returns: Result<'T, 'Error>

The resulting Result value.

Option.unzip v

Full Usage: Option.unzip v

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

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

If value is Some, returns both of them tupled. Otherwise it returns None tupled.

v : ('T * 'U) option

The value.

Returns: 'T option * 'U option

The resulting tuple.

Option.zip x y

Full Usage: Option.zip x y

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

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

If both value are Some, returns both of them tupled. Otherwise it returns None.

x : 'T option

The first value.

y : 'U option

The second value.

Returns: ('T * 'U) option

The resulting option.

Option.zip3 x y z

Full Usage: Option.zip3 x y z

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

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

If all 3 value are Some, returns them tupled. Otherwise it returns None.

x : 'T option

The first value.

y : 'U option

The second value.

z : 'V option

The third value.

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

The resulting option.