Skip to content

Comments

[Repo Assist] Add AsyncSeq.min, max, minBy, maxBy, minByAsync, maxByAsync#243

Merged
dsyme merged 3 commits intomainfrom
repo-assist/improve-minmax-20260223-54863d68fedaee21
Feb 24, 2026
Merged

[Repo Assist] Add AsyncSeq.min, max, minBy, maxBy, minByAsync, maxByAsync#243
dsyme merged 3 commits intomainfrom
repo-assist/improve-minmax-20260223-54863d68fedaee21

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.


Summary

Adds six new aggregation combinators that mirror Seq.min / Seq.max / Seq.minBy / Seq.maxBy:

AsyncSeq.min       : source:AsyncSeq<'T>                            -> Async<'T>   when 'T : comparison
AsyncSeq.max       : source:AsyncSeq<'T>                            -> Async<'T>   when 'T : comparison
AsyncSeq.minBy     : projection:('T -> 'Key) -> source:AsyncSeq<'T> -> Async<'T>  when 'Key : comparison
AsyncSeq.maxBy     : projection:('T -> 'Key) -> source:AsyncSeq<'T> -> Async<'T>  when 'Key : comparison
AsyncSeq.minByAsync: projection:('T -> Async<'Key>) -> source:AsyncSeq<'T> -> Async<'T>  when 'Key : comparison
AsyncSeq.maxByAsync: projection:('T -> Async<'Key>) -> source:AsyncSeq<'T> -> Async<'T>  when 'Key : comparison

All six raise InvalidOperationException on empty sequences, matching the behaviour of the corresponding Seq functions.

Implementation Notes

  • Built on top of foldAsync with an option accumulator — no new enumerator boilerplate.
  • min/max delegate to minBy id / maxBy id.
  • Fixes a latent shadowing issue in bufferByTime: the existing Async.Sleep (max 0 rt) call was shadowed by the new max definition, and has been qualified as Operators.max 0 rt.

Test Status

All 202 tests pass ✅ (8 new tests added covering: correct min/max, async projections, empty-sequence errors for min and max).

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@2f03fdaafb8c1ae62dfde7e0be762a822a201aeb. View source at https://github.com/githubnext/agentics/tree/2f03fdaafb8c1ae62dfde7e0be762a822a201aeb/workflows/repo-assist.md.

Six new aggregation combinators mirroring Seq.min/max/minBy/maxBy:
- minByAsync / maxByAsync: find element with min/max async-projected key
- minBy / maxBy: synchronous projection variants
- min / max: compare elements directly (require 'T : comparison)

All raise InvalidOperationException on empty sequences, matching Seq behaviour.
Includes 8 tests covering correctness, async projections, and empty-sequence errors.

Fixes shadowing of Operators.max in bufferByTime by qualifying the call.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

Pull request created: #243

@dsyme dsyme marked this pull request as ready for review February 24, 2026 02:19
@dsyme dsyme closed this Feb 24, 2026
@dsyme dsyme reopened this Feb 24, 2026
@dsyme dsyme merged commit 240d26b into main Feb 24, 2026
1 check passed
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