Skip to content

Instantly share code, notes, and snippets.

@bent-rasmussen
Created April 26, 2022 09:01
Show Gist options
  • Save bent-rasmussen/116fc4f90737c0646148469d74f29a70 to your computer and use it in GitHub Desktop.
Save bent-rasmussen/116fc4f90737c0646148469d74f29a70 to your computer and use it in GitHub Desktop.
F# async workflow early return
// No early return
// Prints "gotcha"
async {
return ()
printfn "gotcha"
}
|> Async.RunSynchronously
// Early return
// Does not print anything
type ReturnException() =
inherit exn()
async {
try
raise (new ReturnException())
printfn "gotcha"
with
| :? ReturnException -> ()
}
|> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment