Skip to content

[Repo Assist] Add AsyncSeq.ofList, AsyncSeq.ofArray, and AsyncSeq.cycle#308

Merged
dsyme merged 2 commits intomainfrom
repo-assist/improve-oflist-ofarray-cycle-20260413-aff071fc4272ec05
Apr 13, 2026
Merged

[Repo Assist] Add AsyncSeq.ofList, AsyncSeq.ofArray, and AsyncSeq.cycle#308
dsyme merged 2 commits intomainfrom
repo-assist/improve-oflist-ofarray-cycle-20260413-aff071fc4272ec05

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

This PR adds three convenience combinators to AsyncSeq:

New Functions

AsyncSeq.ofList : 'T list -> AsyncSeq<'T>

Creates an async sequence from an F# list. Uses direct cell traversal (h :: t pattern matching) rather than boxing through IEnumerator<T>, avoiding heap allocation.

AsyncSeq.ofArray : 'T[] -> AsyncSeq<'T>

Creates an async sequence from an array. Uses a mutable index into the array, avoiding IEnumerator<T> boxing.

AsyncSeq.cycle : AsyncSeq<'T> -> AsyncSeq<'T>

Returns an async sequence that infinitely cycles through the elements of the source. The source is materialised to an array on first enumeration. Returns an empty sequence if the source is empty.

Rationale

  • ofList and ofArray are natural complements to the existing ofSeq — they express intent clearly and are marginally more efficient.
  • cycle is a commonly needed combinator (present in Haskell, Python itertools, Rust, etc.) that is not straightforward to write correctly with the existing API. The implementation is simple and handles the empty-source edge case.

Changes

  • src/FSharp.Control.AsyncSeq/AsyncSeq.fs — implementations of ofList, ofArray, cycle
  • src/FSharp.Control.AsyncSeq/AsyncSeq.fsi — signature file entries
  • tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs — 9 new tests
  • RELEASE_NOTES.md — updated for 4.13.0

Test Status

Build: succeeded (0 errors, pre-existing warnings only)
.NET tests: 411/411 passed (9 new tests for ofList, ofArray, cycle)

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

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

- ofList: creates async sequence from F# list with direct cell traversal
- ofArray: creates async sequence from array with index-based access
- cycle: infinitely cycles through a source async sequence

All three include signature file entries and 9 new tests (411 total pass).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review April 13, 2026 02:02
@dsyme dsyme merged commit 13d3e42 into main Apr 13, 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