Skip to content

[Repo Assist] Add AsyncSeq.isEmpty, tryHead, except#264

Merged
dsyme merged 4 commits intomainfrom
repo-assist/improve-isempty-tryhead-except-2471744-646c6897389cdfcb
Mar 3, 2026
Merged

[Repo Assist] Add AsyncSeq.isEmpty, tryHead, except#264
dsyme merged 4 commits intomainfrom
repo-assist/improve-isempty-tryhead-except-2471744-646c6897389cdfcb

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 2, 2026

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

Summary

Adds three new combinators to AsyncSeq, filling gaps relative to the standard Seq module:

Function Description Mirrors
isEmpty Returns true if the sequence is empty; short-circuits after the first element Seq.isEmpty
tryHead Returns the first element as option, or None if empty Seq.tryHead
except Returns a new sequence excluding elements present in a given collection (HashSet lookup) Seq.except

Implementation Notes

  • isEmpty is O(1) for non-empty sequences — it advances the enumerator exactly once and disposes it, making it far more efficient than length = 0 or toArray().Length = 0.
  • tryHead is a direct alias for the existing tryFirst, providing the standard Seq-module name. Both names are now available.
  • except builds a HashSet<'T> from the excluded collection up front (O(n) once), then filters the source in O(1) per element. Requires 'T : equality.

Test Status

Build: ✅ succeeded (0 errors, 1 pre-existing warning on groupByAsync)
Tests: ✅ 276/276 passed (267 pre-existing + 9 new)

New tests cover:

  • isEmpty on empty, non-empty, and singleton sequences (3 tests)
  • tryHead on empty and non-empty sequences (2 tests)
  • except with partial exclusion, no exclusion, full exclusion, and empty source (4 tests)

Generated by Repo Assist

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@da02dddebe71d9a937665abdcd1f5214dab852a7

- isEmpty: checks if sequence has no elements; short-circuits after the first
- tryHead: returns first element as option (mirrors Seq.tryHead / alias for tryFirst)
- except: filters out elements present in a given collection (mirrors Seq.except)

All 276 tests pass (267 pre-existing + 9 new).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 3, 2026 09:04
@dsyme dsyme merged commit 8ee2296 into main Mar 3, 2026
1 check passed
github-actions bot added a commit that referenced this pull request Mar 3, 2026
…→ 4.6.0

- Fix merge conflict in RELEASE_NOTES.md (4.6.0 section had unresolved
  conflict markers from concurrent PRs #261 and #264 merging into main)
- Bump version.props from 4.5.0 to 4.6.0 to cover all unreleased additions
  merged since the 4.5.0 version bump:
  - PR #261: findIndex, tryFindIndex, findIndexAsync, tryFindIndexAsync, sortWith
  - PR #264: isEmpty, tryHead, except

All 287 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme pushed a commit that referenced this pull request Mar 4, 2026
…OTES.md, bump version 4.5.0 → 4.6.0 (#265)

* Prepare release 4.6.0 — fix merge conflict, bump version.props 4.5.0 → 4.6.0

- Fix merge conflict in RELEASE_NOTES.md (4.6.0 section had unresolved
  conflict markers from concurrent PRs #261 and #264 merging into main)
- Bump version.props from 4.5.0 to 4.6.0 to cover all unreleased additions
  merged since the 4.5.0 version bump:
  - PR #261: findIndex, tryFindIndex, findIndexAsync, tryFindIndexAsync, sortWith
  - PR #264: isEmpty, tryHead, except

All 287 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: trigger CI checks

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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