Skip to content

[Repo Assist] Add AsyncSeq.head, iteri, find, tryFindAsync, tail#255

Merged
dsyme merged 2 commits intomainfrom
repo-assist/improve-head-iteri-find-tail-edfca61a273ff76e
Feb 27, 2026
Merged

[Repo Assist] Add AsyncSeq.head, iteri, find, tryFindAsync, tail#255
dsyme merged 2 commits intomainfrom
repo-assist/improve-head-iteri-find-tail-edfca61a273ff76e

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist.

Adds five new combinators that mirror standard F# Seq/List module functions, filling gaps in the AsyncSeq API.

Changes

Function Description Mirrors
AsyncSeq.head Returns first element; raises InvalidOperationException if empty Seq.head
AsyncSeq.iteri Sync iteration with element index — was already implemented in .fs but not exported via .fsi Seq.iteri
AsyncSeq.find Returns first element satisfying predicate; raises KeyNotFoundException if no match Seq.find
AsyncSeq.tryFindAsync Async-predicate variant of AsyncSeq.tryFind, returning option
AsyncSeq.tail Returns sequence without first element; empty input returns empty Seq.tail / List.tail

Rationale

These functions follow standard F# naming conventions. Users coming from Seq / List expect head, tail, find, and iteri. The tryFindAsync function fills the notable gap where tryFind (sync predicate) exists but its async-predicate counterpart did not.

iteri was already fully implemented in AsyncSeq.fs (line 849) but accidentally omitted from the .fsi signature, so that fix is a one-line addition to the signature file.

Test Status

  • 11 new tests added covering all new functions including edge cases (empty sequence, no match, etc.)
  • All 248 tests pass (was 237 before)
  • Pre-existing Fable test build errors (FS0039/FS0041 in tests/fable/) are unrelated to this PR

Trade-offs

  • tail on an empty sequence returns empty (same as Seq.tail when used lazily). This matches the semantics of skip 1.
  • head and find use InvalidOperationException / KeyNotFoundException respectively, matching their Seq counterparts.

Generated by Repo Assist

To install this agentic workflow, run

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

Five new combinators mirroring standard F# module functions:
- head: returns first element; raises InvalidOperationException on empty (mirrors Seq.head)
- iteri: sync iteration with element index exposed in .fsi (was already implemented but not exported)
- find: returns first matching element; raises KeyNotFoundException if no match (mirrors Seq.find)
- tryFindAsync: async-predicate variant of tryFind, returning option
- tail: returns sequence without first element (mirrors Seq.tail / List.tail)

11 new tests added; all 248 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 27, 2026 00:48
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