Conversation
Implements TaskSeq.mapFold and TaskSeq.mapFoldAsync, which apply a mapping function that both transforms each element and threads an accumulator state through the sequence in a single pass. The result is a pair of a 'Result array and the final 'State, mirroring List.mapFold, Array.mapFold, and Seq.mapFold from FSharp.Core. - Adds MapFolderAction DU type to TaskSeqInternal.fs - Adds mapFold internal implementation (eager, collects to array) - Exposes TaskSeq.mapFold / TaskSeq.mapFoldAsync on the public type - Adds signatures to TaskSeq.fsi with full XML doc comments - Adds 56 tests covering: empty, single element, multi-element, state threading order, side-effect variants, parity with List.mapFold - Updates release notes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
dsyme
approved these changes
Mar 7, 2026
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.mapFoldandTaskSeq.mapFoldAsync, which combine a map and a fold in a single pass over a task sequence — mirroringList.mapFold,Array.mapFold, andSeq.mapFoldfrom FSharp.Core.Signature
The mapping function receives the current state and element, returns a mapped result and a new state. All elements are consumed eagerly (like
List.mapFold), producing an array of results and the final state.Changes
TaskSeqInternal.fs: newMapFolderActionstruct DU;mapFoldinternal implementation using aResizeArraycollectorTaskSeq.fs: two delegating members (mapFold,mapFoldAsync)TaskSeq.fsi: full XML doc-comment signatures for both membersTaskSeq.MapFold.Tests.fs: 56 tests acrossEmptySeq,Functionality, andSideEffectsmodules — including parity test againstList.mapFoldrelease-notes.txt: updated for 0.5.0Trade-offs
'Result[](notTaskSeq<'Result>) because the final state is only known after the full sequence is consumed. This matches FSharp.Core's eager semantics formapFold.(TaskSeq<'Result> * Task<'State>)is theoretically possible but would require buffering or two-pass consumption, and would diverge from idiomatic F# usage.Test Status
✅ Build succeeded (0 warnings, 0 errors)
✅ All 56 new
mapFold/mapFoldAsynctests pass✅ Full test suite: 3906 passed, 2 skipped (infra), 0 failed
✅ Fantomas format check passes