File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/FSharpPlus/Extensions Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,19 @@ module Result =
8888 /// <returns>A result of the output type of the binder.</returns>
8989 let inline bindError ( binder : 'Error -> Result < 'T , 'Error2 >) ( source : Result < 'T , 'Error >) = match source with Ok v -> Ok v | Error e -> binder e
9090
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+
91104 /// <summary>Extracts a value from either side of a Result.</summary>
92105 /// <param name="fOk">Function to be applied to source, if it contains an Ok value.</param>
93106 /// <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