Conversation
…ByAsync Performance (Task 8): - Add dedicated 'exists' implementation returning bool directly, avoiding the intermediate Option<'T> allocation that the previous tryFind+isSome approach incurred. Both exists/existsAsync and contains now use this path. - 'contains' also avoids the (=) closure allocation from the old impl. Coding improvement (Task 5): - Add TaskSeq.distinct: removes all duplicate elements (keeps first occurrence) using a HashSet, complementing the existing distinctUntilChanged. - Add TaskSeq.distinctBy: de-duplicates by a key projection function. - Add TaskSeq.distinctByAsync: async variant of distinctBy. - 75 new tests covering empty sequences, functionality, side effects, and comparison with Seq/distinctUntilChanged semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
approved these changes
Mar 7, 2026
dsyme
approved these changes
Mar 7, 2026
9 tasks
github-actions bot
added a commit
that referenced
this pull request
Mar 8, 2026
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 <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
This PR bundles two improvements from the selected runs (Task 8: Performance, Task 5: Coding Improvements):
Performance: optimize
exists/existsAsync/containsBefore: all three functions went through
tryFind, which boxes the found element into a heap-allocatedSome 'Tbefore the caller immediately discards it viaOption.isSome.containsadditionally created a(=) valuepartial-application closure.After: a dedicated
existsfunction (mirroring the existingforallimplementation) returnsbooldirectly, with an early-exit loop that never touchesOption.containsuses its own tight loop with an inline equality check.This eliminates one heap allocation per successful call and avoids a closure allocation for
contains.Coding improvement:
TaskSeq.distinct/distinctBy/distinctByAsyncAdds three new combinators that complement the existing
distinctUntilChanged,except, andexceptOfSeq:TaskSeq.distinctTaskSeq.distinctBy projectionTaskSeq.distinctByAsync projectiondistinctByAll three use a
HashSetand iterate the source once. Likeexcept, they are not suitable for infinite sequences.Difference from
distinctUntilChanged:distinctUntilChangedonly removes consecutive duplicates (likeuniq).distinctremoves all duplicates regardless of position (likesort | uniq -u).Files changed
TaskSeqInternal.fs— newexists,contains,distinct,distinctBy,distinctByAsyncimplementationsTaskSeq.fsi— public API signatures with full XML doc commentsTaskSeq.fs— wire-upTaskSeq.Distinct.Tests.fs(new) — 75 testsFSharp.Control.TaskSeq.Test.fsproj— test file registrationrelease-notes.txt— updatedTest Status
Build: ✅ succeeded (Release)
Tests: ✅ 3893 passed, 0 failed, 2 skipped (pre-existing infrastructure skips)