Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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 :: tpattern matching) rather than boxing throughIEnumerator<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
ofListandofArrayare natural complements to the existingofSeq— they express intent clearly and are marginally more efficient.cycleis 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 ofofList,ofArray,cyclesrc/FSharp.Control.AsyncSeq/AsyncSeq.fsi— signature file entriestests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs— 9 new testsRELEASE_NOTES.md— updated for 4.13.0Test Status
✅ Build: succeeded (0 errors, pre-existing warnings only)
✅ .NET tests: 411/411 passed (9 new tests for
ofList,ofArray,cycle)