Deedle


OptionalValue

Namespace: Deedle

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.

defaultArg def optional
Signature: def:'T -> optional:'T opt -> 'T
Type parameters: 'T

Returns the value def when the argument is missing, otherwise returns its 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.

map2 f input1 input2
Signature: f:('T1 -> 'T2 -> 'R) -> input1:OptionalValue<'T1> -> input2:OptionalValue<'T2> -> OptionalValue<'R>
Type parameters: 'T1, 'T2, 'R

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

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:

1: 
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:

1: 
2: 
3: 
4: 
let optVal = OptionalValue(42)
match optVal with
| OptionalValue.Missing -> printfn "Empty"
| OptionalValue.Present(v) -> printfn "Contains %d" v
val optVal : obj

Full name: docs.optVal
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Fork me on GitHub