Conversation
…ByAsync Adds six generic numeric aggregation functions aligned with F#'s Seq module API: - TaskSeq.sum: sums elements using the (+) operator (SRTP) - TaskSeq.sumBy / sumByAsync: sums projected values - TaskSeq.average: averages elements using (+) and DivideByInt (SRTP) - TaskSeq.averageBy / averageByAsync: averages projected values All six are module-level inline functions in TaskSeqExtensions.TaskSeq, which avoids FS1113 errors that occur with type static inline members when SRTP operators are resolved at cross-assembly call sites. The inline bodies directly implement the accumulation loop, following the same pattern as FSharp.Core's Seq.sum. Includes 147 tests covering: null source, empty sequence (zero for sum, exception for average), sequences of int/float/int64/float32, single element, side-effect counting, and immutable variant enumeration (1..10, sum=55, avg=5.5). Also relaxes global.json SDK constraint from patch-exact to latestPatch so the build works with any 10.0.x SDK available in the environment. Co-authored-by: Copilot <[email protected]>
Mark as implemented (✅) following the wave of PRs merged for v0.6.0: - TaskSeq.average, averageBy, averageByAsync (#304) - TaskSeq.sum, sumBy, sumByAsync (#304) - TaskSeq.distinct, distinctBy, distinctByAsync, distinctUntilChanged (#305) - TaskSeq.mapFold, mapFoldAsync (#306) - TaskSeq.groupBy, groupByAsync (#307) - TaskSeq.countBy, countByAsync — add missing table row (#307) - TaskSeq.partition, partitionAsync — add missing table row (#307) Also: - Fix typo 'dictinctBy' → 'distinctBy' - Update 'Status & planning' checklist to reflect completed work - Add PR link definitions (#304–#307) at the bottom Co-authored-by: Copilot <[email protected]>
|
edit: Sorry, jumped the gun; tests failing to compile prove that they need to be A comment and moving @dsyme Any reason why these need to live in They work fine when moved into Can post a PR moving them into the |
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds six generic numeric aggregation functions to
TaskSeq, aligned with F#'sSeqmodule API:TaskSeq.sum+operator via SRTP)TaskSeq.sumByTaskSeq.sumByAsyncTaskSeq.average+andDivideByIntvia SRTP)TaskSeq.averageByTaskSeq.averageByAsyncWorks with all built-in numeric types (
int,float,float32,int64, etc.).average/averageBy/averageByAsyncrequireDivideByInt, so they work with floating-point types only (same constraint asSeq.average).Design Notes
These are module-level
inlinefunctions inTaskSeqExtensions.TaskSeq, following the same pattern asSeq.sum,Array.sum, etc. in FSharp.Core. This is intentional:inlinemembers in[(Sealed; AbstractClass)]types trigger FS1113 when SRTP operators are resolved at cross-assembly call sites (the inline body is expanded in the calling assembly, which cannot access internal F# Core machinery)let inlinefunctions do not have this restriction — FSharp.Core uses this pattern throughoutThe functions are accessible as
TaskSeq.sum,TaskSeq.sumBy, etc. — identical to calling static members.Example
Files Changed
src/FSharp.Control.TaskSeq/TaskSeq.fs: Added 6 module-level inline functionssrc/FSharp.Control.TaskSeq/TaskSeq.fsi: Added signatures toTaskSeqExtensions.TaskSeqmodulesrc/FSharp.Control.TaskSeq.Test/TaskSeq.SumBy.Tests.fs: 147 new testssrc/FSharp.Control.TaskSeq.Test/FSharp.Control.TaskSeq.Test.fsproj: Included new test filerelease-notes.txt: Added entry for new functionsglobal.json: ChangedrollForwardfromminortolatestPatchto accept any10.0.xSDK ≥10.0.100Test Status
✅ Library build:
dotnet build src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj -c Release— 0 warnings, 0 errors✅ Full test suite:
dotnet test src/FSharp.Control.TaskSeq.Test -c Release— 3997 passed, 2 skipped (the 2 skipped are pre-existing infrastructure/real-world stream tests)✅ Formatting:
dotnet fantomas .— no changes needed after final buildNew tests cover:
ArgumentNullExceptionArgumentException1..10sequence: sum = 55, average = 5.5int,float,float32,int64