From e5853003824634430b1f1c4a2c006ca18b050a13 Mon Sep 17 00:00:00 2001 From: webwarrior Date: Wed, 18 Jan 2023 11:07:22 +0100 Subject: [PATCH] Fsdk: added UnwrapEither function Added UnwrapEither function. --- Fsdk/FSharpUtil.fs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Fsdk/FSharpUtil.fs b/Fsdk/FSharpUtil.fs index 64aaab77..88e795dc 100644 --- a/Fsdk/FSharpUtil.fs +++ b/Fsdk/FSharpUtil.fs @@ -286,6 +286,13 @@ module FSharpUtil = ReRaise ex |> ignore failwith "unreachable" + let UnwrapEither<'T, 'TExn when 'TExn :> Exception> + (eitherValue: Either<'T, 'TExn>) + = + match eitherValue with + | SuccessfulValue result -> result + | FailureResult ex -> raise <| ReRaise ex + type OptionBuilder() = // see https://github.com/dsyme/fsharp-presentations/blob/master/design-notes/ces-compared.md#overview-of-f-computation-expressions member x.Bind(v, f) =