Conversation
Adds two new combinators that fold a task sequence without requiring an explicit initial state — the first element is used instead. Raises ArgumentException on an empty sequence, matching Seq.reduce semantics. - TaskSeq.reduce : synchronous folder - TaskSeq.reduceAsync: asynchronous folder 75 new tests covering: null/empty guards, singleton sources, call-count verification (folder called n-1 times), string concatenation, and side-effecting sequences. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8 tasks
dsyme
approved these changes
Mar 7, 2026
github-actions bot
pushed a commit
that referenced
this pull request
Mar 7, 2026
…289) - TaskSeq.chunkBySize: divides a task sequence into non-overlapping chunks of at most chunkSize elements. Uses a fixed-size array buffer (vs. ResizeArray) to avoid intermediate allocations and resizing. - TaskSeq.windowed: returns overlapping sliding windows of a fixed size. Uses a ring buffer internally so that only a single allocation (per window) is needed; no redundant element copies on each step. Both functions validate their size argument eagerly (before enumeration starts), raise ArgumentException for non-positive sizes, and are fully documented in the .fsi signature file. Also: - Update README.md to mark chunkBySize, windowed, pairwise, scan/scanAsync, reduce/reduceAsync, and unfold/unfoldAsync as implemented (these were merged in PRs #293, #296, #299, #300 respectively). - Update release-notes.txt for 0.5.0. - 171 new tests across TaskSeq.ChunkBySize.Tests.fs and TaskSeq.Windowed.Tests.fs. All 4021 existing tests continue to 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 PR was created by Repo Assist, an automated AI assistant.
Summary
Adds
TaskSeq.reduceandTaskSeq.reduceAsync— fold-without-initial-state operations that use the first element as the accumulator seed, matching the semantics ofSeq.reduceandAsyncSeq.reduce.Part of the work to align with
FSharp.Control.AsyncSeq(ref #289). Please do not close #289 as this is one PR of several.Implementation
Root cause / motivation
TaskSeq.foldrequires an explicit initial state. For cases where the element type and state type are the same (e.g. summing, string concatenation, taking max),reduceis the idiomatic operation — no seed needed.Changes
TaskSeqInternal.fsreducefunction: reads first element, raises on empty, folds restTaskSeq.fsreduce/reduceAsyncdispatching toFolderAction/AsyncFolderActionTaskSeq.fsiTaskSeq.Reduce.Tests.fsFSharp.Control.TaskSeq.Test.fsprojSemantics
ArgumentExceptionwhen the sequence is empty (mirrorsSeq.reduce)Test Status
Build: ✅ succeeded (0 warnings, 0 errors)
Tests: ✅ 75/75 passed
Fantomas: ✅ clean after formatting
Test categories: