Deedle


OptionalValue

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 valueDescription
asOption value
Signature:value:'T opt -> 'T option
Type parameters: 'T

Turns the OptionalValue<T> into a corresponding standard F# option<T> value

bind f input
Signature:f:('T -> OptionalValue<'R>) -> input:OptionalValue<'T> -> OptionalValue<'R>
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.

get optional
Signature:optional:'T opt -> 'T
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)

map f input
Signature:f:('T -> 'R) -> input:OptionalValue<'T> -> OptionalValue<'R>
Type parameters: 'T, 'R

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

ofNullable value
Signature:value:Nullable<'T> -> 'T opt
Type parameters: 'T

Creates OptionalValue<T> from a .NET Nullable<T> type.

ofOption opt
Signature:opt:'T option -> 'T opt
Type parameters: 'T

Turns a standard F# option<T> value into a corresponding OptionalValue<T>

ofTuple (b, value)
Signature:(b:bool * value:'T) -> 'T opt
Type parameters: 'T

Creates OptionalValue<T> 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

Active patterns

Active patternDescription
( |Missing|Present| ) optional
Signature:optional:'T opt -> Choice<unit,'T>
Type parameters: 'T

Complete active pattern that can be used to pattern match on OptionalValue<T>. For example:

let optVal = OptionalValue(42)
match optVal with
| OptionalValue.Missing -> printfn "Empty"
| OptionalValue.Present(v) -> printfn "Contains %d" v
Fork me on GitHub