Created
April 26, 2022 09:01
-
-
Save bent-rasmussen/116fc4f90737c0646148469d74f29a70 to your computer and use it in GitHub Desktop.
F# async workflow early return
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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