Option Module
Contains operations for working with options.
Functions and values
Function or value |
Description
|
Full Usage:
Option.bind binder option
Parameters:
'T -> 'U option
-
A function that takes the value of type T from an option and transforms it into
an option containing a value of type U.
option : 'T option
-
The input option.
Returns: 'U option
An option of the output type of the binder.
Modifiers: inline Type parameters: 'T, 'U |
Example
val tryParse: input: string -> int option
val input: string
Multiple items
val string: value: 'T -> string -------------------- type string = System.String namespace System
[<Struct>]
type Int32 =
member CompareTo: value: int -> int + 1 overload
member Equals: obj: int -> bool + 1 overload
member GetHashCode: unit -> int
member GetTypeCode: unit -> TypeCode
member ToString: unit -> string + 3 overloads
member TryFormat: utf8Destination: Span<byte> * bytesWritten: byref<int> * ?format: ReadOnlySpan<char> * ?provider: IFormatProvider -> bool + 1 overload
static member Abs: value: int -> int
static member BigMul: left: int * right: int -> int64
static member Clamp: value: int * min: int * max: int -> int
static member CopySign: value: int * sign: int -> int
...
<summary>Represents a 32-bit signed integer.</summary> System.Int32.TryParse(s: string, result: byref<int>) : bool
System.Int32.TryParse(s: System.ReadOnlySpan<char>, result: byref<int>) : bool System.Int32.TryParse(utf8Text: System.ReadOnlySpan<byte>, result: byref<int>) : bool System.Int32.TryParse(s: string, provider: System.IFormatProvider, result: byref<int>) : bool System.Int32.TryParse(s: System.ReadOnlySpan<char>, provider: System.IFormatProvider, result: byref<int>) : bool System.Int32.TryParse(utf8Text: System.ReadOnlySpan<byte>, provider: System.IFormatProvider, result: byref<int>) : bool System.Int32.TryParse(s: string, style: System.Globalization.NumberStyles, provider: System.IFormatProvider, result: byref<int>) : bool System.Int32.TryParse(s: System.ReadOnlySpan<char>, style: System.Globalization.NumberStyles, provider: System.IFormatProvider, result: byref<int>) : bool System.Int32.TryParse(utf8Text: System.ReadOnlySpan<byte>, style: System.Globalization.NumberStyles, provider: System.IFormatProvider, result: byref<int>) : bool val v: int
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val bind: binder: ('T -> 'U option) -> option: 'T option -> 'U option
|
|
Evaluates to true if option is
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val contains: value: 'T -> option: 'T option -> bool (requires equality)
union case Option.Some: Value: 'T -> Option<'T>
|
|
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val count: option: 'T option -> int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.defaultValue value option
Parameters:
'T
-
The specified default value.
option : 'T option
-
The input option.
Returns: 'T
The option if the option is Some, else the default value.
Modifiers: inline Type parameters: 'T |
Gets the value of the option if the option is Identical to the built-in defaultArg operator, except with the arguments swapped.
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val defaultValue: value: 'T -> option: 'T option -> 'T
union case Option.Some: Value: 'T -> Option<'T>
|
|
Gets the value of the option if the option is
defThunk is not evaluated unless option is
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val defaultWith: defThunk: (unit -> 'T) -> option: 'T option -> 'T
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.exists predicate option
Parameters:
'T -> bool
-
A function that evaluates to a boolean when given a value from the option type.
option : 'T option
-
The input option.
Returns: bool
False if the option is None, otherwise it returns the result of applying the predicate
to the option value.
Modifiers: inline Type parameters: 'T |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val exists: predicate: ('T -> bool) -> option: 'T option -> bool
val x: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.filter predicate option
Parameters:
'T -> bool
-
A function that evaluates whether the value contained in the option should remain, or be filtered out.
option : 'T option
-
The input option.
Returns: 'T option
The input if the predicate evaluates to true; otherwise, None.
Modifiers: inline Type parameters: 'T |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val filter: predicate: ('T -> bool) -> option: 'T option -> 'T option
val x: int
union case Option.Some: Value: 'T -> Option<'T>
|
|
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
module Option
from Microsoft.FSharp.Core
val flatten: option: 'T option option -> 'T option
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.fold folder state option
Parameters:
'State -> 'T -> 'State
-
A function to update the state data when given a value from an option.
state : 'State
-
The initial state.
option : 'T option
-
The input option.
Returns: 'State
The original state if the option is None, otherwise it returns the updated state with the folder
and the option value.
Modifiers: inline Type parameters: 'T, 'State |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val fold<'T,'State> : folder: ('State -> 'T -> 'State) -> state: 'State -> option: 'T option -> 'State
val accum: int
val x: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.foldBack folder option state
Parameters:
'T -> 'State -> 'State
-
A function to update the state data when given a value from an option.
option : 'T option
-
The input option.
state : 'State
-
The initial state.
Returns: 'State
The original state if the option is None, otherwise it returns the updated state with the folder
and the option value.
Modifiers: inline Type parameters: 'T, 'State |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val foldBack: folder: ('T -> 'State -> 'State) -> option: 'T option -> state: 'State -> 'State
val x: int
val accum: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.forall predicate option
Parameters:
'T -> bool
-
A function that evaluates to a boolean when given a value from the option type.
option : 'T option
-
The input option.
Returns: bool
True if the option is None, otherwise it returns the result of applying the predicate
to the option value.
Modifiers: inline Type parameters: 'T |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val forall: predicate: ('T -> bool) -> option: 'T option -> bool
val x: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.get option
Parameters:
'T option
-
The input option.
Returns: 'T
The value within the option.
|
Gets the value associated with the option.
Example
union case Option.Some: Value: 'T -> Option<'T>
module Option
from Microsoft.FSharp.Core
val get: option: 'T option -> 'T
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
|
|
Returns true if the option is None.
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val isNone: option: 'T option -> bool
union case Option.Some: Value: 'T -> Option<'T>
|
|
Returns true if the option is not None.
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val isSome: option: 'T option -> bool
union case Option.Some: Value: 'T -> Option<'T>
|
|
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val iter: action: ('T -> unit) -> option: 'T option -> unit
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.map mapping option
Parameters:
'T -> 'U
-
A function to apply to the option value.
option : 'T option
-
The input option.
Returns: 'U option
An option of the input value after applying the mapping function, or None if the input is None.
Modifiers: inline Type parameters: 'T, 'U |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val map: mapping: ('T -> 'U) -> option: 'T option -> 'U option
val x: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.map2 mapping option1 option2
Parameters:
'T1 -> 'T2 -> 'U
-
A function to apply to the option values.
option1 : 'T1 option
-
The first option.
option2 : 'T2 option
-
The second option.
Returns: 'U option
An option of the input values after applying the mapping function, or None if either input is None.
Modifiers: inline Type parameters: 'T1, 'T2, 'U |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val map2: mapping: ('T1 -> 'T2 -> 'U) -> option1: 'T1 option -> option2: 'T2 option -> 'U option
val x: int
val y: int
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.map3 mapping option1 option2 option3
Parameters:
'T1 -> 'T2 -> 'T3 -> 'U
-
A function to apply to the option values.
option1 : 'T1 option
-
The first option.
option2 : 'T2 option
-
The second option.
option3 : 'T3 option
-
The third option.
Returns: 'U option
An option of the input values after applying the mapping function, or None if any input is None.
Modifiers: inline Type parameters: 'T1, 'T2, 'T3, 'U |
Example
union case Option.None: Option<'T>
module Option
from Microsoft.FSharp.Core
val map3: mapping: ('T1 -> 'T2 -> 'T3 -> 'U) -> option1: 'T1 option -> option2: 'T2 option -> option3: 'T3 option -> 'U option
val x: int
val y: int
val z: int
union case Option.Some: Value: 'T -> Option<'T>
|
|
Convert a Nullable value to an option.
Example
namespace System
Multiple items
[<Struct>] type Nullable<'T (requires default constructor and value type and 'T :> ValueType)> = new: value: 'T -> unit member Equals: other: obj -> bool member GetHashCode: unit -> int member GetValueOrDefault: unit -> 'T + 1 overload member ToString: unit -> string static member op_Explicit: value: Nullable<'T> -> 'T static member op_Implicit: value: 'T -> Nullable<'T> member HasValue: bool member Value: 'T <summary>Represents a value type that can be assigned <see langword="null" />.</summary> <typeparam name="T">The underlying value type of the <see cref="T:System.Nullable`1" /> generic type.</typeparam> -------------------- type Nullable = static member Compare<'T (requires default constructor and value type and 'T :> ValueType)> : n1: Nullable<'T> * n2: Nullable<'T> -> int static member Equals<'T (requires default constructor and value type and 'T :> ValueType)> : n1: Nullable<'T> * n2: Nullable<'T> -> bool static member GetUnderlyingType: nullableType: Type -> Type static member GetValueRefOrDefaultRef<'T (requires default constructor and value type and 'T :> ValueType)> : nullable: byref<Nullable<'T>> -> inref<'T> <summary>Supports a value type that can be assigned <see langword="null" />. This class cannot be inherited.</summary> -------------------- System.Nullable () System.Nullable(value: 'T) : System.Nullable<'T> Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int module Option
from Microsoft.FSharp.Core
val ofNullable: value: System.Nullable<'T> -> 'T option (requires default constructor and value type and 'T :> System.ValueType)
|
Full Usage:
Option.ofObj value
Parameters:
'T
-
The input value.
Returns: 'T option
The result option.
Modifiers: inline Type parameters: 'T |
Convert a potentially null value to an option.
Example
Multiple items
val string: value: 'T -> string -------------------- type string = System.String module Option
from Microsoft.FSharp.Core
val ofObj: value: 'T -> 'T option (requires 'T: null)
|
|
Convert a value option to an option.
Example
union case ValueOption.ValueSome: 'T -> ValueOption<'T>
module Option
from Microsoft.FSharp.Core
union case ValueOption.ValueNone: ValueOption<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T voption = ValueOption<'T>
|
|
Returns option if it is
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int module Option
from Microsoft.FSharp.Core
val orElse: ifNone: 'T option -> option: 'T option -> 'T option
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.orElseWith ifNoneThunk option
Parameters:
unit -> 'T option
-
A thunk that provides an alternate option when evaluated.
option : 'T option
-
The input option.
Returns: 'T option
The option if the option is Some, else the result of evaluating ifNoneThunk.
Modifiers: inline Type parameters: 'T |
Returns option if it is
ifNoneThunk is not evaluated unless option is
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int module Option
from Microsoft.FSharp.Core
val orElseWith: ifNoneThunk: (unit -> 'T option) -> option: 'T option -> 'T option
union case Option.Some: Value: 'T -> Option<'T>
|
|
Convert the option to an array of length 0 or 1.
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
module Option
from Microsoft.FSharp.Core
val toArray: option: 'T option -> 'T array
union case Option.Some: Value: 'T -> Option<'T>
|
|
Convert the option to a list of length 0 or 1.
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
module Option
from Microsoft.FSharp.Core
val toList: option: 'T option -> 'T list
union case Option.Some: Value: 'T -> Option<'T>
|
|
Convert the option to a Nullable value.
Example
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
module Option
from Microsoft.FSharp.Core
val toNullable: option: 'T option -> System.Nullable<'T> (requires default constructor and value type and 'T :> System.ValueType)
union case Option.Some: Value: 'T -> Option<'T>
|
Full Usage:
Option.toObj value
Parameters:
'T option
-
The input value.
Returns: 'T
The result value, which is null if the input was None.
Modifiers: inline Type parameters: 'T |
Convert an option to a potentially null value.
Example
union case Option.None: Option<'T>
Multiple items
val string: value: 'T -> string -------------------- type string = System.String type 'T option = Option<'T>
module Option
from Microsoft.FSharp.Core
val toObj: value: 'T option -> 'T (requires 'T: null)
union case Option.Some: Value: 'T -> Option<'T>
|
|
Convert an option to a value option.
Example
union case Option.Some: Value: 'T -> Option<'T>
module Option
from Microsoft.FSharp.Core
union case Option.None: Option<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T option = Option<'T>
|