Skip to content

Comments

[Auto Maintainer Assistant] Add AsyncSeq.chunkBy and AsyncSeq.chunkByAsync#222

Merged
dsyme merged 1 commit intomainfrom
co-maintainer/chunkby-consecutive-grouping-9ea149af742b39a9
Feb 21, 2026
Merged

[Auto Maintainer Assistant] Add AsyncSeq.chunkBy and AsyncSeq.chunkByAsync#222
dsyme merged 1 commit intomainfrom
co-maintainer/chunkby-consecutive-grouping-9ea149af742b39a9

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by the repository's automated AI maintenance assistant.

Closes #156

Summary

Adds two new functions to the AsyncSeq module that group consecutive elements sharing the same key — analogous to Seq.groupBy but for runs of adjacent equal keys rather than all elements:

  • AsyncSeq.chunkByAsync — accepts an async key projection 'T -> Async<'Key>
  • AsyncSeq.chunkBy — accepts a synchronous key projection 'T -> 'Key

Both return AsyncSeq<'Key * 'T list>. The return type uses 'T list (rather than ResizeArray) to avoid leaking implementation details.

Example

asyncSeq { yield 1; yield 1; yield 2; yield 2; yield 1 }
|> AsyncSeq.chunkBy id
// yields: (1, [1;1]), (2, [2;2]), (1, [1])

This mirrors the Seq.chunkBy function from FSharpPlus described in the issue.

Implementation Notes

  • chunkBy delegates to chunkByAsync via projection >> async.Return, following the same pattern as groupBy/groupByAsync.
  • The implementation uses the same GetEnumerator/MoveNext pattern as chunkBySize.
  • 'Key : equality constraint is required and is declared in the .fsi signatures.

Test Status

  • Debug build passes (dotnet build -c Debug)
  • Release build passes (dotnet build -c Release)
  • Debug tests pass (dotnet test -c Debug) — 187/187
  • Release tests pass (dotnet test -c Release) — 187/187

Generated by Auto Maintainer Assistant

Groups consecutive elements sharing the same key, yielding
AsyncSeq<'Key * 'T list>. Mirrors the existing chunkBySize pattern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 21, 2026 03:46
@dsyme dsyme closed this Feb 21, 2026
@dsyme dsyme reopened this Feb 21, 2026
@dsyme dsyme merged commit 696e172 into main Feb 21, 2026
1 check passed
github-actions bot pushed a commit that referenced this pull request Feb 21, 2026
Update version.props to 3.3.1 and update RELEASE_NOTES.md to include
chunkBy/chunkByAsync (PR #222) and mergeAll seq widening (PR #221)
alongside the previously documented improvements.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant