File tree 1 file changed +13
-0
lines changed
src/FSharpPlus/Extensions
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,19 @@ module Result =
88
88
/// <returns>A result of the output type of the binder.</returns>
89
89
let inline bindError ( binder : 'Error -> Result < 'T , 'Error2 >) ( source : Result < 'T , 'Error >) = match source with Ok v -> Ok v | Error e -> binder e
90
90
91
+ /// <summary><c>iterError f inp</c> executes <c>match inp with Ok _ -> () | Error x -> f x</c>.</summary>
92
+ ///
93
+ /// <param name="action">A function to apply to the error part of the source value.</param>
94
+ /// <param name="source">The input result.</param>
95
+ ///
96
+ /// <example id="iter-1">
97
+ /// <code lang="fsharp">
98
+ /// Ok "Hello world" |> Result.iter (printfn "%s") // does nothing
99
+ /// Error "Hello world" |> Result.iter (printfn "%s") // prints "Hello world"
100
+ /// </code>
101
+ /// </example>
102
+ let inline iterError ( [<InlineIfLambda>] action : 'Error -> unit ) ( source : Result < 'T , 'Error >) = match source with Ok _ -> () | Error x -> action x
103
+
91
104
/// <summary>Extracts a value from either side of a Result.</summary>
92
105
/// <param name="fOk">Function to be applied to source, if it contains an Ok value.</param>
93
106
/// <param name="fError">Function to be applied to source, if it contains an Error value.</param>
You can’t perform that action at this time.
0 commit comments