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 AsyncSeq.head and AsyncSeq.tail #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Caleb9
Copy link

@Caleb9 Caleb9 commented Jul 21, 2022

Hello!

Regular Seq contains simple convenience functions head and tail. I implemented those for AsyncSeq, maybe they could be added?

Thanks.

@Caleb9 Caleb9 force-pushed the main branch 2 times, most recently from 4c5571f to 97e2249 Compare July 21, 2022 17:18
@abelbraaksma
Copy link
Member

abelbraaksma commented Nov 4, 2022

Isn't Async.head the same as Async.first, which already exists? Well, firstOrDefault exists, which is close enough, no? https://fsprojects.github.io/FSharp.Control.AsyncSeq/reference/fsharp-control-asyncseq.html#firstOrDefault

Though there's no tail. There should probably be a tail and tryTail pair, and yes, maybe it does make sense to have a head and tryHead for parity with Seq.

@Caleb9
Copy link
Author

Caleb9 commented Nov 7, 2022

It sure is, it's just a slight inconsistency with non-async collections API (i.e. Seq has head and tail). It's no biggie, the PR can be closed if it's not desirable to have these two APIs aligned in this way :).

@abelbraaksma
Copy link
Member

abelbraaksma commented Nov 7, 2022

FWIW, TaskSeq, which uses a resumable state machine and task from F# 6 under the hood, and implements IAsyncEnumerable<_> similar to async foreach in C#, has those functions: https://github.com/fsprojects/FSharp.Control.TaskSeq

Copy link
Member

@abelbraaksma abelbraaksma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Caleb9, sorry for leaving this PR hanging (I wasn't a maintainer yet, at the time). We'll need a few tests, but otherwise this looks good to go in.

I'd understand if you're not around anymore for editing your PR, in which case I can take over and finish it.

@dsyme
Copy link
Contributor

dsyme commented Aug 21, 2024

@abelbraaksma Should we close this old one out?

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

Successfully merging this pull request may close these issues.

None yet

3 participants