3 ms·
`await` can only be used in an `async` function. How is that so different from `let!` only being available in a computation expression?
by sparkie 2y ago
`await` can only be used in an `async` function. How is that so different from `let!` only being available in a computation expression?
- shortrounddev2 2y agobecause an async function doesn't require you to change syntaxes to get them to work
- Smaug123 2y agoIt's actually sort of the other way round. C# has hardcoded syntax for async/await. F#'s syntax for async/await is a fully-general user-accessible mechanism.
- sparkie 2y agoThey're not so different in that regard. C# `await` can be adapted by making an awaitable and awaiter type[1], which isn't to dissimilar to how a computation expression in F# needs to implement methods `Bind`, `Return`, `Yield`, etc. In both languages these patterns make up for the absence of typeclasses to express things like a functor, applicative, monad, comonad, etc. [1]https://ecma-international.org/wp-content/uploads/ECMA-334_7th_edition_december_2023.pdf#%5B%7B%22num%22%3A744%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C55%2C585%2C0%5D https://ecma-international.org/wp-content/uploads/ECMA-334_7...