File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/FSharpPlus/Extensions Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,16 @@ module Result =
6161 | Error e, _, _
6262 | _, Error e, _
6363 | _, _, Error e -> Error e
64+
65+ /// <summary>Maps both Ok and Error of a Result.</summary>
66+ /// <param name="errorMapper">Function to be applied to source, if it contains an Error value.</param>
67+ /// <param name="okMapper">Function to be applied to source, if it contains an Ok value.</param>
68+ /// <param name="source">The source value, containing an Ok or an Error.</param>
69+ /// <returns>The result of applying the corresponding mapping function.</returns>
70+ let bimap ( errorMapper : 'TError -> 'UError ) ( okMapper : 'T -> 'U ) source =
71+ match source with
72+ | Error e -> Error ( errorMapper e)
73+ | Ok a -> Ok ( okMapper a)
6474
6575 /// <summary>Flattens two nested Results.</summary>
6676 /// <param name="source">The nested Results.</param>
You can’t perform that action at this time.
0 commit comments