Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YieldFrom overload for seq<'a>? #123

Open
voroninp opened this issue Nov 19, 2020 · 1 comment
Open

Add YieldFrom overload for seq<'a>? #123

voroninp opened this issue Nov 19, 2020 · 1 comment

Comments

@voroninp
Copy link

I'd like to turn Async<seq> to AsyncSeq

While this works

asyncSeq {
    for item in items -> item
}

yield! version does not:

asyncSeq {
    yield! items
}

I need this to get all pages from the endpoint in one go. Reading a single page yields Async<seq<Result>> , I'd like the result to be presented as AsyncSeq

@abelbraaksma
Copy link
Member

abelbraaksma commented Nov 13, 2022

Both your solutions work the same way here. If yield! were implemented (not sure it has, since then), it would act the same as your first solution here. After all, sequences are delay-iterated.

If you want the whole result at once, then AsyncSeq is probably not the correct solution. Though, if you already have an Async<seq>, and you want to read all at once, you can just do Async.map Seq.toList.

If you do want AsyncSeq, it'll give you different behavior than you describe, but the solution in your first suggestion above does give you what you want.

For posterity, since a few days, taskSeq was released. In there, you can do taskSeq { yield! items }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants