Additional operations on Result<'T,'Error>
Function or value | Description |
|
Applies the wrapped value to the wrapped function when both are Ok and returns a wrapped result or the first Error.
The function wrapped in an Ok or an Error.
The value wrapped in an Ok or an Error.
|
|
|
|
|
Full Usage:
Result.bimap errorMapper okMapper source
Parameters:
'TError -> 'UError
-
Function to be applied to source, if it contains an Error value.
okMapper : 'T -> 'U
-
Function to be applied to source, if it contains an Ok value.
source : Result<'T, 'TError>
-
The source value, containing an Ok or an Error.
Returns: Result<'U, 'UError>
The result of applying the corresponding mapping function.
|
|
Full Usage:
Result.bindError binder source
Parameters:
'Error -> Result<'T, 'Error2>
-
A function that takes the error and transforms it into a result.
source : Result<'T, 'Error>
-
The source input value.
Returns: Result<'T, 'Error2>
A result of the output type of the binder.
Modifiers: inline Type parameters: 'Error, 'T, 'Error2 |
|
|
|
Full Usage:
Result.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.
|
Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.
|
Full Usage:
Result.defaultWith defThunk result
Parameters:
'Error -> 'T
-
A thunk that provides a default value when evaluated.
result : Result<'T, 'Error>
-
The input result.
Returns: 'T
|
Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.
|
Full Usage:
Result.either fOk fError source
Parameters:
'T -> 'U
-
Function to be applied to source, if it contains an Ok value.
fError : 'Error -> 'U
-
Function to be applied to source, if it contains an Error value.
source : Result<'T, 'Error>
-
The source value, containing an Ok or an Error.
Returns: 'U
The result of applying either functions.
Modifiers: inline Type parameters: 'T, 'U, 'Error |
|
|
|
|
|
Full Usage:
Result.iterError action source
Parameters:
'Error -> unit
-
A function to apply to the error part of the source value.
source : Result<'T, 'Error>
-
The input result.
Modifiers: inline Type parameters: 'Error, '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 iter: action: ('T -> unit) -> result: Result<'T,'Error> -> unit
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case Result.Error: ErrorValue: 'TError -> Result<'T,'TError>
|
|
|
Full Usage:
Result.map3 f x y z
Parameters:
'T -> 'U -> 'V -> 'W
-
The mapping function.
x : Result<'T, 'Error>
-
The first Result value.
y : Result<'U, 'Error>
-
The second Result value.
z : Result<'V, 'Error>
-
The third Result value.
Returns: Result<'W, 'Error>
The combined value, or the first Error.
|
|
|
|
Full Usage:
Result.partition source
Parameters:
Result<'T, 'Error> list
Returns: 'T list * 'Error list
A tuple with both resulting lists, Oks are in the first list.
|
|
|
|
|
|
|
|
|
|
|