FSharpPlus


Result Module

Additional operations on Result<'T,'Error>

Functions and values

Function or value Description

Result.apply f x

Full Usage: Result.apply f x

Parameters:
Returns: Result<'U, 'Error>

Applies the wrapped value to the wrapped function when both are Ok and returns a wrapped result or the first Error. The function wrapped in an Ok or an Error. The value wrapped in an Ok or an Error. An Ok of the function applied to the value, or the first Error if either the function or the value is Error.

f : Result<('T -> 'U), 'Error>
x : Result<'T, 'Error>
Returns: Result<'U, 'Error>

Result.bindError binder source

Full Usage: Result.bindError binder source

Parameters:
    binder : 'Error -> Result<'T, 'Error2> - A function that takes the error and transforms it into a result.
    source : Result<'T, 'Error> - The source input value.

Returns: Result<'T, 'Error2> A result of the output type of the binder.
Modifiers: inline
Type parameters: 'Error, 'T, 'Error2

If the input value is an Ok leaves it unchanged, otherwise maps the Error value and flattens the resulting nested Result.

binder : 'Error -> Result<'T, 'Error2>

A function that takes the error and transforms it into a result.

source : Result<'T, 'Error>

The source input value.

Returns: Result<'T, 'Error2>

A result of the output type of the binder.

Result.defaultValue value source

Full Usage: Result.defaultValue value source

Parameters:
    value : 'T
    source : Result<'T, 'Error>

Returns: 'T

Extracts the Ok value or use the supplied default value when it's an Error.

value : 'T
source : Result<'T, 'Error>
Returns: 'T

Result.defaultWith compensation source

Full Usage: Result.defaultWith compensation source

Parameters:
    compensation : 'Error -> 'T
    source : Result<'T, 'Error>

Returns: 'T

Extracts the Ok value or applies the compensation function over the Error.

compensation : 'Error -> 'T
source : Result<'T, 'Error>
Returns: 'T

Result.either fOk fError source

Full Usage: Result.either fOk fError source

Parameters:
    fOk : 'T -> 'U - Function to be applied to source, if it contains an Ok value.
    fError : 'Error -> 'U - Function to be applied to source, if it contains an Error value.
    source : Result<'T, 'Error> - The source value, containing an Ok or an Error.

Returns: 'U The result of applying either functions.
Modifiers: inline
Type parameters: 'T, 'U, 'Error

Extracts a value from either side of a Result.

fOk : 'T -> 'U

Function to be applied to source, if it contains an Ok value.

fError : 'Error -> 'U

Function to be applied to source, if it contains an Error value.

source : Result<'T, 'Error>

The source value, containing an Ok or an Error.

Returns: 'U

The result of applying either functions.

Result.flatten source

Full Usage: Result.flatten source

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

Returns: Result<'T, 'Error> A single Ok of the value when it was nested with OKs, or the Error.

Flattens two nested Results.

flatten is equivalent to bind id.

source : Result<Result<'T, 'Error>, 'Error>

The nested Results.

Returns: Result<'T, 'Error>

A single Ok of the value when it was nested with OKs, or the Error.

Result.get source

Full Usage: Result.get source

Parameters:
Returns: 'T

Gets the 'Ok' value. If it's an 'Error' this function will throw an exception.

source : Result<'T, 'Error>
Returns: 'T

Result.map2 f x y

Full Usage: Result.map2 f x y

Parameters:
    f : 'T -> 'U -> 'V - The mapping function.
    x : Result<'T, 'Error> - The first Result value.
    y : Result<'U, 'Error> - The second Result value.

Returns: Result<'V, 'Error> The combined value, or the first Error.

Creates a Result value from a pair of Result values, using a function to combine them.

f : 'T -> 'U -> 'V

The mapping function.

x : Result<'T, 'Error>

The first Result value.

y : Result<'U, 'Error>

The second Result value.

Returns: Result<'V, 'Error>

The combined value, or the first Error.

Result.map3 f x y z

Full Usage: Result.map3 f x y z

Parameters:
    f : 'T -> 'U -> 'V -> 'W - The mapping function.
    x : Result<'T, 'Error> - The first Result value.
    y : Result<'U, 'Error> - The second Result value.
    z : Result<'V, 'Error> - The third Result value.

Returns: Result<'W, 'Error> The combined value, or the first Error.

Creates a Result value from three Result values, using a function to combine them.

f : 'T -> 'U -> 'V -> 'W

The mapping function.

x : Result<'T, 'Error>

The first Result value.

y : Result<'U, 'Error>

The second Result value.

z : Result<'V, 'Error>

The third Result value.

Returns: Result<'W, 'Error>

The combined value, or the first Error.

Result.ofChoice source

Full Usage: Result.ofChoice source

Parameters:
Returns: Result<'T, 'U>

Creates a Result<'T,'Error> from a Choice<'T,'Error>.

source : Choice<'T, 'U>
Returns: Result<'T, 'U>

Result.partition source

Full Usage: Result.partition source

Parameters:
    source : Result<'T, 'Error> list

Returns: 'T list * 'Error list A tuple with both resulting lists, Oks are in the first list.

Creates two lists by classifying the values depending on whether they were wrapped with Ok or Error.

source : Result<'T, 'Error> list
Returns: 'T list * 'Error list

A tuple with both resulting lists, Oks are in the first list.

Result.protect f x

Full Usage: Result.protect f x

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

Returns: Result<'U, exn>

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

f : 'T -> 'U
x : 'T
Returns: Result<'U, exn>

Result.result value

Full Usage: Result.result value

Parameters:
    value : 'T

Returns: Result<'T, 'Error>

Creates an Ok with the supplied value.

value : 'T
Returns: Result<'T, 'Error>

Result.throw value

Full Usage: Result.throw value

Parameters:
    value : 'Error

Returns: Result<'T, 'Error>

Creates an Error With the supplied value.

value : 'Error
Returns: Result<'T, 'Error>

Result.toChoice source

Full Usage: Result.toChoice source

Parameters:
Returns: Choice<'T, 'U>

Converts a Result<'T,'Error> to a Choice<'T,'Error>.

source : Result<'T, 'U>
Returns: Choice<'T, 'U>