r/fsharp • • 5h ago

article Async in F#, C# and TypeScript, and where task { } in Fable stands as of 5.21

12 Upvotes

An F# async { } doesn't run until something starts it, while a Task or a Promise is already running by the time you get it back. The article goes through the bugs that come from mixing the two up, and the upside: retries, timeouts and racing written as ordinary functions over Async, compared with what C# and TypeScript need for the same thing.

It also covers Fable now that task { } compiles to a promise, including a few things that compile but fail when the module loads in 5.21 (Async.StartAsTask, Async.Choice, Async.OnCancel, Task.Delay), and the Async.StartTaskImmediate and Async.Await additions coming in FSharp.Core 11.

https://si-fi.dev/articles/async-task-confusion/