Skip to content

What types should async methods return #1385

Answered by louthy
slimshader asked this question in Q&A
Discussion options

You must be logged in to vote

If you haven't started using the *Async variants yet, then you may want to skip them and go straight to v5. The proposal to remove the *Async variants has been acted upon and they don't exist any more.

If you want to continue with OptionAsync on v4 then you use LINQ, not async/await:

static OptionAsync<int> GetIntAsync() =>
    from _ in SomeAsync(wait(1))
    select 42;

static async Task<Unit> wait(int seconds)
{
    await Task.Delay(TimeSpan.FromSeconds(1));
    return unit;
}

So, all of the standard functional operators (Map, Bind, Apply, etc.) understand the asynchrony and apply it as part of their implementations.

In version 5 you'd use the IO monad (support for async essentially) w…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@slimshader
Comment options

Answer selected by slimshader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1380 on October 20, 2024 09:38.