Fsharp.Core :: {Array;List;Set;Array.Parallel} partitionWith (taking Choice<T,U> partitioner)#19335
Merged
Fsharp.Core :: {Array;List;Set;Array.Parallel} partitionWith (taking Choice<T,U> partitioner)#19335
Conversation
Adds List.partitionWith that splits a list into two lists of potentially different types using a Choice-returning partitioner function. - Implementation in list.fs using ListCollector and recursive loop - Signature with XML docs and example in list.fsi - Unit tests covering basic, empty, all-Choice1, all-Choice2, single element, and order preservation cases
Adds Array.partitionWith function that splits an array into two arrays by applying a partitioner function returning Choice<'T1,'T2>. Uses ArrayCollector<'T> for efficient array building. Includes XML documentation with example and unit tests covering: - Basic type-changing partition - Empty array input - All Choice1Of2 / all Choice2Of2 - Single element - Order preservation - Null input throws ArgumentNullException
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- List: stack safety test with 100k elements verifying tail recursion - List/Array/Set: exception propagation tests with InvalidOperationException Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tests Replace Assert.Throws<InvalidOperationException> with the existing CheckThrowsInvalidOperationExn helper from LibraryTestFx.fs for consistency with the rest of the test codebase. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds FsCheck property-based consistency tests to CollectionModulesConsistency.fs: - List vs Array: verifies identical ordered results across int, string, NormalFloat - Set vs Array: verifies set-equal results (order-independent) across int, string, NormalFloat Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace iter-based ascending traversal with right→key→left recursive traversal, matching partitionAux's proven strategy. Elements are inserted largest-first into output trees, causing fewer rebalancing rotations. Internal accumulator uses struct tuples to avoid per-step allocations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace ChunkedArrayCollector with a two-pass strategy: - Pass 1: call partitioner, store results, count Choice1Of2 - Pass 2: allocate exact-sized arrays, scatter results Mark function inline with [<InlineIfLambda>] on partitioner parameter. Remove ChunkedArrayCollector type (only used by partitionWith). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rewrite body to use ListCollector instead of freshConsNoTail/setFreshConsTail to avoid FieldAccessException when inlined into external assemblies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement the parallel version of Array.partitionWith using the same Parallel.For + thread-local accumulator + Interlocked.Add pattern as Array.Parallel.choose. - Implementation in src/FSharp.Core/array.fs - Signature with XML docs in src/FSharp.Core/array.fsi - Unit tests and consistency tests - Surface area baselines updated (4 .bsl files) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ase notes - Replace intermediate Choice<'T1,'T2>[] in Array.partitionWith with the 3-array pattern (bool[] + T1[] + T2[]) matching the parallel version, eliminating N per-element heap allocations of Choice DU objects - Add Array.Parallel.partitionWith to release notes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
❗ Release notes required
Warning No PR link found in some release notes, please consider adding it.
|
Member
|
No Choice<'a, 'b, 'c> or Choice<'a, 'b, 'c, 'd> versions? |
Member
Author
fsharp/fslang-suggestions#1119 (comment) But your question made me realize that if we wanted to support all various sorts (all the 7 choices, and result,..), it could be solved by a language-level facility that inverts collection of N-case DU items, and puts them into N different collections of respective fields of those cases. Maybe more on the "type provider generate types+members from existing types" side ... ? |
abonie
approved these changes
Feb 26, 2026
The new Array.partitionWith and Array.Parallel.partitionWith methods produce StackUnexpected ILVerify errors for Bool/Byte types on the stack, matching the existing pattern for Array.Parallel.Choose/Filter/Partition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
T-Gro
added a commit
that referenced
this pull request
Mar 6, 2026
* Type checker: recover on argument/overload checking (#19314) * [main] Update dependencies from dotnet/arcade (#19333) * Update dependencies from https://github.com/dotnet/arcade build 20260219.2 On relative base path root Microsoft.DotNet.Arcade.Sdk From Version 10.0.0-beta.26117.6 -> To Version 10.0.0-beta.26119.2 * Update dependencies from https://github.com/dotnet/arcade build 20260223.2 On relative base path root Microsoft.DotNet.Arcade.Sdk From Version 10.0.0-beta.26117.6 -> To Version 10.0.0-beta.26123.2 --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [main] Source code updates from dotnet/dotnet (#19343) * Backflow from https://github.com/dotnet/dotnet / 854c152 build 302768 [[ commit created by automation ]] * Update dependencies from build 302768 No dependency updates to commit [[ commit created by automation ]] * Backflow from https://github.com/dotnet/dotnet / 51587e2 build 302820 [[ commit created by automation ]] * Update dependencies from build 302820 No dependency updates to commit [[ commit created by automation ]] --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com> * Update image used for insert into VS step (#19357) * Fix :: FAR :: Remove corrupted .ctor symbol reference (#19358) * DotNetBuildUseMonoRuntime stackguard (#19360) * Fsharp.Core :: {Array;List;Set;Array.Parallel} partitionWith (taking Choice<T,U> partitioner) (#19335) * Sort out some outstanding issues after xUnit upgrade (#19363) * Improve collection comparison diagnostics in tests (#19365) Added shouldBeEqualCollections to Assert.fs for detailed collection comparison, including reporting missing/unexpected items and positional differences. Updated Project25 symbol uses test to use this helper and print actual/expected values for easier debugging. * Enhance the compiler to produce a FS0750 error on let! or use! outside a CE (#19347) * Update to latest .NET 10 SDK patch (#19350) * Feature: `#elif` preprocessor directive (#19323) * Support #exit;; as alias to #quit;; in fsi (#19329) * Checker: prevent reporting optional parameter rewritten tree symbols (#19353) * Improve static compilation of state machines (#19297) * Add FSC compiler options tests (#19348) * Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20260226.1 (#19366) On relative base path root optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime From Version 1.0.0-prerelease.26117.2 -> To Version 1.0.0-prerelease.26126.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Fix Get-PrBuildIds.ps1 reporting SUCCESS while builds in progress (#19313) * Fix flaky Project25 TP test by replacing FSharp.Data NuGet with TestTP (#19364) (#19373) Replace FSharp.Data (resolved via NuGet at runtime) with the built-in TestTP type provider for the Project25 symbol API tests. This fixes non-deterministic test failures on Linux CI caused by Directory.GetFiles returning DLLs in random inode order on ext4, which varied whether the FSharp.Data namespace was tagged as 'provided' or not. Changes: - Replace 70-line NuGet restore/staging setup with 2-line TestTP reference - Update source to use ErasedWithConstructor.Provided.MyType instead of FSharp.Data.XmlProvider - Replace brittle exact-match symbol list with targeted assertions for provided types, methods, and namespaces - Remove FactSkipOnSignedBuild (TestTP is always available after build) - Rename test variables to match the types being tested Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add automatic merge flow from main to feature/net11-scouting (#19283) * Optimize Set.intersect symmetry and add release notes (#19292) Co-authored-by: Ahmed <w0lf@192.168.1.8> * Fix strong name signature size to align with Roslyn for public signing (#11887) (#19242) * Use culture-independent `IndexOf` in interpolated string parsing (#19370) * Rename "inline hints" to "inlay hints" (#19318) * Rename "inline hints" to "inlay hints" for LSP consistency Aligns F#-owned terminology with LSP and VS Code conventions. The Roslyn ExternalAccess types (IFSharpInlineHintsService, etc.) are left unchanged as they are owned by Roslyn. Fixes #16608 * Add release note for inline-to-inlay hints rename --------- Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com> * FCS: capture additional types during analysis (#19305) * remove duplicate FlatErrors file (#19383) * Update dependencies from https://github.com/dotnet/arcade build 20260302.1 (#19379) [main] Update dependencies from dotnet/arcade * [main] Update dependencies from dotnet/msbuild (#19021) * Update dependencies from https://github.com/dotnet/msbuild build 20251021.3 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25521-03 * Update dependencies from https://github.com/dotnet/msbuild build 20251023.2 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25523-02 * Update dependencies from https://github.com/dotnet/msbuild build 20251024.3 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25524-03 * Update dependencies from https://github.com/dotnet/msbuild build 20251027.5 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25527-05 * Update dependencies from https://github.com/dotnet/msbuild build 20251027.6 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25527-06 * Update dependencies from https://github.com/dotnet/msbuild build 20251104.4 On relative base path root Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.1.0-preview-25515-01 -> To Version 18.1.0-preview-25554-04 * Bump dependency versions in Version.Details.props Updated package versions for several dependencies. --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com> * Add fsharp-release-announcement agent (#19390) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix Seq.empty rendering as "EmptyEnumerable" in serializers (#19317) * Update FileContentMapping.fs (#19391) * Fix flaky help_options test: restore enableConsoleColoring after mutation (#19385) * Initial plan * Fix flaky help_options test by saving/restoring enableConsoleColoring global The `fsc --consolecolors switch` test mutates the global `enableConsoleColoring` via `--consolecolors-`. When help_options tests run after this test, the help output says "(off by default)" instead of "(on by default)", causing baseline mismatches. Fix: save and restore `enableConsoleColoring` around the test. Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com> * isolate checker (#19393) Isolate type-provider tests with dedicated FSharpChecker Introduce Project25.checker to avoid shared state races in type-provider tests. All relevant test cases now use this dedicated instance, improving test isolation, reliability, and determinism without changing test functionality. * Introduce CallRelatedSymbolSink to avoid affect name resolution with related symbols (#19361) * Add RelatedSymbolUseKind flags enum and separate sink for related symbols Address auduchinok's review comments on PR #19252: related symbols (union case testers, copy-and-update record types) are now reported via a separate NotifyRelatedSymbolUse sink instead of abusing NotifyNameResolution. - Add [<Flags>] RelatedSymbolUseKind enum (None/UnionCaseTester/CopyAndUpdateRecord/All) - Add NotifyRelatedSymbolUse to ITypecheckResultsSink interface - Refactor RegisterUnionCaseTesterForProperty to use the new sink - Refactor copy-and-update in TcRecdExpr to use CallRelatedSymbolSink - Add ?relatedSymbolKinds parameter to GetUsesOfSymbolInFile (default: None) - Wire up VS FAR to pass relatedSymbolKinds=All - Write related symbols to ItemKeyStore for background FAR - Update semantic classification tests: tester properties now classified as Property (not UnionCase) since they're no longer in capturedNameResolutions * Add release notes for FSharp.Compiler.Service 11.0.100 --------- Co-authored-by: Eugene Auduchinok <eugene.auduchinok@gmail.com> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com> Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com> Co-authored-by: Jakub Majocha <1760221+majocha@users.noreply.github.com> Co-authored-by: Evgeny Tsvetkov <61620612+evgTSV@users.noreply.github.com> Co-authored-by: Youssef Victor <youssefvictor00@gmail.com> Co-authored-by: Bozhidar Batsov <bozhidar@batsov.dev> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Ahmed Waleed <ahmedwalidahmed.0@gmail.com> Co-authored-by: Ahmed <w0lf@192.168.1.8> Co-authored-by: Brian Rourke Boll <brianrourkeboll@users.noreply.github.com> Co-authored-by: Apoorv Darshan <ad13dtu@gmail.com> Co-authored-by: T-Gro <46543583+T-Gro@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.
Implements fsharp/fslang-suggestions#1119
Signatures
Example — active patterns
A total active pattern
(|A|B|)is already'T -> Choice<'T1, 'T2>— pass it directly.