Is your feature request related to a problem? Please describe.
Exceptions are an important part of the F# ecosystem.
Sometimes error-handling is best done "railway style" and sometimes it's better to use exceptions. And sometimes we want different styles in different areas of a program.
We already have a way to go from "exception world" to "railway world", using AsyncResult.catch.
This feature request is to include a small helper function for going the other way: Async<Result<'ok, exn>> -> Async<'ok>.
Describe the solution you'd like
Add a helper function for this.
For example:
module AsyncResult =
open System.Runtime.ExceptionServices
let orReraise (workflow : Async<Result<'a, exn>>) : Async<'a> =
async {
match! workflow with
| Ok a ->
return a
| Error exn ->
ExceptionDispatchInfo.Capture(exn).Throw()
return Unchecked.defaultof<_>
}
Describe alternatives you've considered
Everyone writes their own!
Additional context
None