Result Module
Contains operations for working with values of type Result.
Functions and values
Function or value |
Description
|
Full Usage:
bind binder result
Parameters:
'T -> Result<'U, 'TError>
-
A function that takes the value of type T from a result and transforms it into
a result containing a value of type U.
result : Result<'T, 'TError>
-
The input result.
Returns: Result<'U, 'TError>
A result of the output type of the binder.
Modifiers: inline Type parameters: 'T, 'U, 'TError |
Example
val tryParse: input: string -> Result<int,string>
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 Result.Ok: ResultValue: 'T -> Result<'T,'TError>
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val bind: binder: ('T -> Result<'U,'TError>) -> result: Result<'T,'TError> -> Result<'U,'TError>
|
|
Evaluates to true if result is
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val contains: value: 'T -> result: Result<'T,'Error> -> bool (requires equality)
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
|
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val count: result: Result<'T,'Error> -> int
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
defaultValue value result
Parameters:
'T
-
The specified default value.
result : Result<'T, 'Error>
-
The input result.
Returns: 'T
The result if the result is Ok, else the default value.
Modifiers: inline Type parameters: 'T, 'Error |
Gets the value of the result if the result is
Example
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val defaultValue: value: 'T -> result: Result<'T,'Error> -> 'T
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
defaultWith defThunk result
Parameters:
'Error -> 'T
-
A thunk that provides a default value when evaluated.
result : Result<'T, 'Error>
-
The input result.
Returns: 'T
The result if the result is Ok, else the result of evaluating defThunk.
Modifiers: inline Type parameters: 'Error, 'T |
Gets the value of the result if the result is
defThunk is not evaluated unless result is
Example
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val defaultWith: defThunk: ('Error -> 'T) -> result: Result<'T,'Error> -> 'T
val error: obj
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
val error: int
|
Full Usage:
exists predicate result
Parameters:
'T -> bool
-
A function that evaluates to a boolean when given a value from the result type.
result : Result<'T, 'Error>
-
The input result.
Returns: bool
False if the result is Error, otherwise it returns the result of applying the predicate
to the result value.
Modifiers: inline Type parameters: 'T, 'Error |
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val exists: predicate: ('T -> bool) -> result: Result<'T,'Error> -> bool
val x: int
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
fold folder state result
Parameters:
'State -> 'T -> 'State
-
A function to update the state data when given a value from an result.
state : 'State
-
The initial state.
result : Result<'T, 'Error>
-
The input result.
Returns: 'State
The original state if the result is Error, otherwise it returns the updated state with the folder
and the result value.
Modifiers: inline Type parameters: 'T, 'Error, 'State |
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val fold<'T,'Error,'State> : folder: ('State -> 'T -> 'State) -> state: 'State -> result: Result<'T,'Error> -> 'State
val accum: int
val x: int
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
foldBack folder result state
Parameters:
'T -> 'State -> 'State
-
A function to update the state data when given a value from an result.
result : Result<'T, 'Error>
-
The input result.
state : 'State
-
The initial state.
Returns: 'State
The original state if the result is Error, otherwise it returns the updated state with the folder
and the result value.
Modifiers: inline Type parameters: 'T, 'Error, 'State |
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val foldBack<'T,'Error,'State> : folder: ('T -> 'State -> 'State) -> result: Result<'T,'Error> -> state: 'State -> 'State
val x: int
val accum: int
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
forall predicate result
Parameters:
'T -> bool
-
A function that evaluates to a boolean when given a value from the result type.
result : Result<'T, 'Error>
-
The input result.
Returns: bool
True if the result is Error, otherwise it returns the result of applying the predicate
to the result value.
Modifiers: inline Type parameters: 'T, 'Error |
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val forall: predicate: ('T -> bool) -> result: Result<'T,'Error> -> bool
val x: int
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
|
Returns true if the result is Error.
Example
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val isError: result: Result<'T,'Error> -> bool
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
|
|
Returns true if the result is Ok.
Example
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val isOk: result: Result<'T,'Error> -> bool
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
|
|
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val iter: action: ('T -> unit) -> result: Result<'T,'Error> -> unit
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
Full Usage:
map mapping result
Parameters:
'T -> 'U
-
A function to apply to the OK result value.
result : Result<'T, 'TError>
-
The input result.
Returns: Result<'U, 'TError>
A result of the input value after applying the mapping function, or Error if the input is Error.
Modifiers: inline Type parameters: 'T, 'U, 'TError |
Example
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val map: mapping: ('T -> 'U) -> result: Result<'T,'TError> -> Result<'U,'TError>
val x: int
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
val x: obj
|
Full Usage:
mapError mapping result
Parameters:
'TError -> 'U
-
A function to apply to the Error result value.
result : Result<'T, 'TError>
-
The input result.
Returns: Result<'T, 'U>
A result of the error value after applying the mapping function, or Ok if the input is Ok.
Modifiers: inline Type parameters: 'TError, 'U, 'T |
Example
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val mapError: mapping: ('TError -> 'U) -> result: Result<'T,'TError> -> Result<'T,'U>
val x: obj
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
val x: string
|
|
Convert the result to an array of length 0 or 1.
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val toArray: result: Result<'T,'Error> -> 'T array
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
|
Convert the result to a list of length 0 or 1.
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val toList: result: Result<'T,'Error> -> 'T list
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
|
Convert the result to an Option value.
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val toOption: result: Result<'T,'Error> -> 'T option
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|
|
Convert the result to an Option value.
Example
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
Multiple items
module Result from Microsoft.FSharp.Core -------------------- [<Struct>] type Result<'T,'TError> = | Ok of ResultValue: 'T | Error of ErrorValue: 'TError val toOption: result: Result<'T,'Error> -> 'T option
union case Result.Ok: ResultValue: 'T -> Result<'T,'TError>
|