Skip to content

[Repo Assist] feat: add TaskSeq.findBack, tryFindBack, findIndexBack, tryFindIndexBack (and async variants)#374

Closed
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feat-findback-2026-04-01-4e2fd7081889fdd8
Closed

[Repo Assist] feat: add TaskSeq.findBack, tryFindBack, findIndexBack, tryFindIndexBack (and async variants)#374
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feat-findback-2026-04-01-4e2fd7081889fdd8

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 1, 2026

🤖 This is an automated pull request from Repo Assist.

Summary

Adds eight new functions mirroring Seq.findBack, Seq.tryFindBack, Seq.findIndexBack, and Seq.tryFindIndexBack from FSharp.Core:

Function Description
TaskSeq.tryFindBack Last element matching predicate, or None
TaskSeq.tryFindBackAsync Async predicate variant
TaskSeq.findBack Last element matching predicate; throws KeyNotFoundException if not found
TaskSeq.findBackAsync Async predicate variant
TaskSeq.tryFindIndexBack Index of last element matching predicate, or None
TaskSeq.tryFindIndexBackAsync Async predicate variant
TaskSeq.findIndexBack Index of last matching element; throws if not found
TaskSeq.findIndexBackAsync Async predicate variant

Key design decision

Unlike the forward variants (find, findIndex), the *Back variants always consume the entire sequence — they must scan to the end to determine which match is last. This is documented in the XML doc comments and tested explicitly.

Implementation

  • TaskSeqInternal.fs: Two core functions tryFindBack and tryFindIndexBack. Both scan the full sequence using a while loop, updating a foundItem/foundIndex mutable on every match.
  • TaskSeq.fs: Eight public members; the throwing variants pipe through Task.map (Option.defaultWith Internal.raiseNotFound) following the same pattern as find/findIndex.
  • TaskSeq.fsi: Full XML doc comments matching the project style.

Test Status

  • ✅ Build: dotnet build — succeeded, 0 warnings
  • ✅ Tests: dotnet test5290 passed, 2 skipped (273 new; 2 skipped are pre-existing infrastructure-only skips)
  • ✅ Formatting: dotnet fantomas . --check — no issues

Generated by 🌈 Repo Assist at Run. Learn more.

To install this agentic workflow, run

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

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

…ync, findIndexBack, findIndexBackAsync, tryFindIndexBack, tryFindIndexBackAsync (273 tests)

These functions find the last matching element or index, mirroring Seq.findBack,
Seq.tryFindBack, Seq.findIndexBack, and Seq.tryFindIndexBack from FSharp.Core.
Unlike their forward counterparts, they consume the entire sequence to locate
the last match; this is documented in the signatures.

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

dsyme commented Apr 1, 2026

We don't need these for async sequences

@dsyme dsyme closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant