Skip to content

[Repo Assist] Add AsyncSeq.tryFindBack, findBack, tryFindBackAsync, findBackAsync#294

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/add-findback-2026-03-31-a394b5ee1c69fead
Draft

[Repo Assist] Add AsyncSeq.tryFindBack, findBack, tryFindBackAsync, findBackAsync#294
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/add-findback-2026-03-31-a394b5ee1c69fead

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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

Adds four new functions mirroring Array.findBack / List.findBack from the F# standard library:

Function Description
tryFindBackAsync Returns the last element satisfying an async predicate, or None if none found
tryFindBack Returns the last element satisfying a sync predicate, or None if none found
findBackAsync Like tryFindBackAsync but raises KeyNotFoundException when no element is found
findBack Like tryFindBack but raises KeyNotFoundException when no element is found

Implementation

Each function scans the entire sequence from front to back, tracking the last element that satisfied the predicate. This is the correct approach since async sequences are not randomly accessible and cannot be reversed without materialisation.

The async-predicate variants (tryFindBackAsync, findBackAsync) use a direct enumerator loop. The sync-predicate variants delegate to their async counterparts via predicate >> async.Return. findBack / findBackAsync delegate to tryFindBack / tryFindBackAsync and raise on None.

Changes

  • src/FSharp.Control.AsyncSeq/AsyncSeq.fs — 4 new function implementations
  • src/FSharp.Control.AsyncSeq/AsyncSeq.fsi — 4 new public signatures with XML-doc
  • tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs — 10 new tests
  • RELEASE_NOTES.md — updated 4.11.0 entry

Test Status

✅ Build succeeded (0 errors, pre-existing warnings only — FS9999 for groupByAsync).

✅ All 382 tests pass — 10 new, 372 pre-existing.

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

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

Adds four new functions mirroring Array.findBack / List.findBack from
the F# standard library:

- tryFindBackAsync: returns the last element satisfying an async predicate, or None
- tryFindBack: synchronous predicate variant of the above
- findBackAsync: like tryFindBackAsync but raises KeyNotFoundException
- findBack: like tryFindBack but raises KeyNotFoundException

Implementation scans the entire sequence, keeping track of the last
matching element. 10 new tests added; all 382 tests pass.

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.

0 participants