Logo Deedle

OptionalValue Module

Provides various helper functions for using the OptionalValue<T> type from F# (The functions are similar to those in the standard Option module).

Functions and values

Function or value Description

asOption value

Full Usage: asOption value

Parameters:
    value : 'T opt

Returns: 'T option
Modifiers: inline
Type parameters: 'T

Turns the `OptionalValue` into a corresponding standard F# `option` value

value : 'T opt
Returns: 'T option

bind f input

Full Usage: bind f input

Parameters:
Returns: OptionalValue<'R>
Modifiers: inline
Type parameters: 'T, 'R

If the OptionalValue<T> does not contain a value, then returns a new OptionalValue<R>.Empty. Otherwise, returns the result of applying the function f to the value contained in the provided optional value.

f : 'T -> OptionalValue<'R>
input : OptionalValue<'T>
Returns: OptionalValue<'R>

defaultArg def optional

Full Usage: defaultArg def optional

Parameters:
    def : 'T
    optional : 'T opt

Returns: 'T
Modifiers: inline
Type parameters: 'T

Returns the value `def` when the argument is missing, otherwise returns its value

def : 'T
optional : 'T opt
Returns: 'T

get optional

Full Usage: get optional

Parameters:
    optional : 'T opt

Returns: 'T
Modifiers: inline
Type parameters: 'T

Get the value stored in the specified optional value. If a value is not available, throws an exception. (This is equivalent to the `Value` property)

optional : 'T opt
Returns: 'T

map f input

Full Usage: map f input

Parameters:
Returns: OptionalValue<'R>
Modifiers: inline
Type parameters: 'T, 'R

If the `OptionalValue` does not contain a value, then returns a new `OptionalValue.Empty`. Otherwise, returns the result `OptionalValue` containing the result of applying the function `f` to the value contained in the provided optional value.

f : 'T -> 'R
input : OptionalValue<'T>
Returns: OptionalValue<'R>

map2 f input1 input2

Full Usage: map2 f input1 input2

Parameters:
Returns: OptionalValue<'R>
Modifiers: inline
Type parameters: 'T1, 'T2, 'R

If both of the arguments contain value, apply the specified function to their values and return `OptionalValue` with the result. Otherwise return `OptionalValue.Missing`.

f : 'T1 -> 'T2 -> 'R
input1 : OptionalValue<'T1>
input2 : OptionalValue<'T2>
Returns: OptionalValue<'R>

ofNullable value

Full Usage: ofNullable value

Parameters:
Returns: 'T opt
Modifiers: inline
Type parameters: 'T (requires (new : unit -> 'T) and struct and :> System.ValueType)

Creates `OptionalValue` from a .NET `Nullable` type.

value : Nullable<'T>
Returns: 'T opt

ofOption opt

Full Usage: ofOption opt

Parameters:
    opt : 'T option

Returns: 'T opt
Modifiers: inline
Type parameters: 'T

Turns a standard F# `option` value into a corresponding `OptionalValue`

opt : 'T option
Returns: 'T opt

ofTuple (b, value)

Full Usage: ofTuple (b, value)

Parameters:
    b : bool
    value : 'T

Returns: 'T opt
Modifiers: inline
Type parameters: 'T
 Creates `OptionalValue` from a tuple of type `bool * 'T`. This function
 can be used with .NET methods that use `out` arguments. For example:

     Int32.TryParse("42") |> OptionalValue.ofTuple
b : bool
value : 'T
Returns: 'T opt

Active patterns

Active pattern Description

(|Missing|Present|) optional

Full Usage: (|Missing|Present|) optional

Parameters:
    optional : 'T opt

Returns: Choice<unit, 'T>
Type parameters: 'T
 Complete active pattern that can be used to pattern match on `OptionalValue`.
 For example:

     let optVal = OptionalValue(42)
     match optVal with
     | OptionalValue.Missing -> printfn "Empty"
     | OptionalValue.Present(v) -> printfn "Contains %d" v
optional : 'T opt
Returns: Choice<unit, 'T>

Type something to start searching.