FSharpPlus


Choice Module

Additional operations on Choice

Functions and values

Function or value Description

Choice.apply f x

Full Usage: Choice.apply f x

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

Applies the wrapped value to the wrapped function when both are Choice1Of2 and returns a wrapped result or the first Choice2Of2. This is as if Choice1Of2 respresents a Success value and Choice2Of2 a Failure. The function wrapped in a Choice1Of2 or a Choice2Of2. The value wrapped in a Choice1Of2 or a Choice2Of2. A Choice1Of2 of the function applied to the value, or the first Choice2Of2 if either the function or the value is Choice2Of2.

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

Choice.apply2With combiner f x y

Full Usage: Choice.apply2With combiner f x y

Parameters:
    combiner : 'Error -> 'Error -> 'Error
    f : 'T -> 'U -> 'V
    x : Choice<'T, 'Error>
    y : Choice<'U, 'Error>

Returns: Choice<'V, 'Error>
combiner : 'Error -> 'Error -> 'Error
f : 'T -> 'U -> 'V
x : Choice<'T, 'Error>
y : Choice<'U, 'Error>
Returns: Choice<'V, 'Error>

Choice.apply3With combiner f x y z

Full Usage: Choice.apply3With combiner f x y z

Parameters:
    combiner : 'Error -> 'Error -> 'Error
    f : 'T -> 'U -> 'V -> 'W
    x : Choice<'T, 'Error>
    y : Choice<'U, 'Error>
    z : Choice<'V, 'Error>

Returns: Choice<'W, 'Error>
combiner : 'Error -> 'Error -> 'Error
f : 'T -> 'U -> 'V -> 'W
x : Choice<'T, 'Error>
y : Choice<'U, 'Error>
z : Choice<'V, 'Error>
Returns: Choice<'W, 'Error>

Choice.bind binder source

Full Usage: Choice.bind binder source

Parameters:
    binder : 'T -> Choice<'U, 'T2> - A function that takes the value of type T and transforms it into a Choice containing (potentially) a value of type U.
    source : Choice<'T, 'T2> - The source input value.

Returns: Choice<'U, 'T2> A result of the output type of the binder.

If the input value is a Choice2Of2 leaves it unchanged, otherwise maps the value on the Choice1Of2 and flattens the resulting nested Choice.

binder : 'T -> Choice<'U, 'T2>

A function that takes the value of type T and transforms it into a Choice containing (potentially) a value of type U.

source : Choice<'T, 'T2>

The source input value.

Returns: Choice<'U, 'T2>

A result of the output type of the binder.

Choice.bindChoice2Of2 binder source

Full Usage: Choice.bindChoice2Of2 binder source

Parameters:
    binder : 'T2 -> Choice<'T, 'U2> - A function that takes the value of type T and transforms it into a Choice containing (potentially) a value of type U.
    source : Choice<'T, 'T2> - The source input value.

Returns: Choice<'T, 'U2> A result of the output type of the binder.

If the input value is a Choice1Of2 leaves it unchanged, otherwise maps the value on the Choice2Of2 and flattens the resulting nested Choice.

binder : 'T2 -> Choice<'T, 'U2>

A function that takes the value of type T and transforms it into a Choice containing (potentially) a value of type U.

source : Choice<'T, 'T2>

The source input value.

Returns: Choice<'T, 'U2>

A result of the output type of the binder.

Choice.catch x f

Full Usage: Choice.catch x f

Parameters:
Returns: Choice<'v, 'e>
Modifiers: inline

Like Choice.bindChoice2Of2 but with flipped arguments.

x : Choice<'v, 'a>
f : 'a -> Choice<'v, 'e>
Returns: Choice<'v, 'e>

Choice.either fChoice1Of2 fChoice2Of2 source

Full Usage: Choice.either fChoice1Of2 fChoice2Of2 source

Parameters:
    fChoice1Of2 : 'a -> 'b - Function to be applied to source, if it contains a Choice1Of2 value.
    fChoice2Of2 : 'c -> 'b - Function to be applied to source, if it contains a Choice2Of2 value.
    source : Choice<'a, 'c> - The source value, containing a Choice1Of2 or a Choice2Of2.

Returns: 'b The result of applying either functions.
Modifiers: inline
Type parameters: 'a, 'b, 'c

Extracts a value from either side of a Choice.

fChoice1Of2 : 'a -> 'b

Function to be applied to source, if it contains a Choice1Of2 value.

fChoice2Of2 : 'c -> 'b

Function to be applied to source, if it contains a Choice2Of2 value.

source : Choice<'a, 'c>

The source value, containing a Choice1Of2 or a Choice2Of2.

Returns: 'b

The result of applying either functions.

Choice.flatten source

Full Usage: Choice.flatten source

Parameters:
    source : Choice<Choice<'T1, 'T2>, 'T2> - The nested Choice.

Returns: Choice<'T1, 'T2> A single Choice1Of2 of the value when it was nested with Choice1Of2s, or the Choice2Of2.

Flattens two nested Choice.

flatten is equivalent to bind id.

source : Choice<Choice<'T1, 'T2>, 'T2>

The nested Choice.

Returns: Choice<'T1, 'T2>

A single Choice1Of2 of the value when it was nested with Choice1Of2s, or the Choice2Of2.

Choice.map mapping source

Full Usage: Choice.map mapping source

Parameters:
    mapping : 'T -> 'U - A function to apply to the Choice1Of2 value.
    source : Choice<'T, 'T2> - The source input value.

Returns: Choice<'U, 'T2> A Choice1Of2 of the input value after applying the mapping function, or the original Choice2Of2 value if the input is Choice2Of2.

Maps the value on the Choice1Of2 if any.

mapping : 'T -> 'U

A function to apply to the Choice1Of2 value.

source : Choice<'T, 'T2>

The source input value.

Returns: Choice<'U, 'T2>

A Choice1Of2 of the input value after applying the mapping function, or the original Choice2Of2 value if the input is Choice2Of2.

Choice.map2 mapping x y

Full Usage: Choice.map2 mapping x y

Parameters:
    mapping : 'T -> 'U -> 'V - A function to apply to the Choice1Of2 values.
    x : Choice<'T, 'Error> - The first Choice value.
    y : Choice<'U, 'Error> - The second Choice value.

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

Creates a Choice value from a pair of Choice values, using a function to combine the Choice1Of2 values.

mapping : 'T -> 'U -> 'V

A function to apply to the Choice1Of2 values.

x : Choice<'T, 'Error>

The first Choice value.

y : Choice<'U, 'Error>

The second Choice value.

Returns: Choice<'V, 'Error>

The combined value, or the first Choice2Of2.

Choice.map3 mapping x y z

Full Usage: Choice.map3 mapping x y z

Parameters:
    mapping : 'T -> 'U -> 'V -> 'W - A function to apply to the Choice1Of2 values.
    x : Choice<'T, 'Error> - The first Choice value.
    y : Choice<'U, 'Error> - The second Choice value.
    z : Choice<'V, 'Error> - The third Choice value.

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

Creates a Choice value from three of Choice values, using a function to combine the Choice1Of2 values.

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

A function to apply to the Choice1Of2 values.

x : Choice<'T, 'Error>

The first Choice value.

y : Choice<'U, 'Error>

The second Choice value.

z : Choice<'V, 'Error>

The third Choice value.

Returns: Choice<'W, 'Error>

The combined value, or the first Choice2Of2.

Choice.protect f x

Full Usage: Choice.protect f x

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

Returns: Choice<'U, exn>

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

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

Choice.result x

Full Usage: Choice.result x

Parameters:
    x : 'a

Returns: Choice<'a, 'b>

Creates a Choice1Of2 with the supplied value.

x : 'a
Returns: Choice<'a, 'b>

Choice.throw x

Full Usage: Choice.throw x

Parameters:
    x : 'a

Returns: Choice<'b, 'a>

Creates a Choice2Of2 with the supplied value.

x : 'a
Returns: Choice<'b, 'a>