You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c90668b
Browse filesBrowse the repository at this point in the historyBrowse files
docs: accept ADR 0002 and record the answers to its questions
The maintainers accepted every recommendation of section 11 on
2026-10-18, and pull request #28 implements step 1.
- Status Accepted; section 11 records the decisions.
- Section 1: the library compiles against the signature, `Slice`
included.
- Sections 5 and 6: step 1 also has `unsafeOfArray`, which throws for
`null` like `ofArray`.
- Section 7: the categories as implemented, the exact allocation
counts, and the C# test project that the maintainers chose.
- Section 9: the four differences the first consumer notices when it
moves to the library type.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`InteropTestCategory`, `JsonTestCategory`and `PatternMatchingTestCategory`, in the `TestCategories.fs`that step 1
431
+
adds. `BuilderTestCategory` and `ComputationExpressionTestCategory` come with step 2.
429
432
***Equality under every caller**: `=`, `.Equals`, `EqualityComparer<_>.Default`, `HashIdentity.Structural`, a default
430
433
`Dictionary` and `HashSet`, `ValueTuple.Equals`, a record field, a recursive union.
431
434
***The defects of `ImmutableArray` as regression tests**: arrays of different length compare, sort and build a `Set`;
@@ -443,7 +446,9 @@ attributes sorted by type name.
443
446
***Constraints**: the type parameter carries `EqualityConditionalOn` and `ComparisonConditionalOn`, read by reflection,
444
447
since a test cannot assert a compile error.
445
448
***Allocation**: 0 B, by `GC.GetAllocatedBytesForCurrentThread`, for `=` on arrays of `int`, `string`, a union and
446
-
struct tuples, on the value and as a record field; for `for`; for a pattern match. These tests run in Release only.
449
+
struct tuples, on the value and as a record field; for `for`; for a pattern match. These tests run in Release only,
450
+
with tiered compilation off so that every method is fully optimized from its first call. A control test shows that
451
+
the counter sees an allocation.
447
452
***Interop**: both conversions keep the underlying array; `CollectionBuilderAttribute` names the factory class and
448
453
`Create`, and the class has exactly one `Create`; `GetSlice` follows F# arrays; `Slice` follows `ImmutableArray.Slice`,
449
454
including `ArgumentOutOfRangeException`; `op_Equality` and `op_Inequality` agree with `Equals`; the mutating members of
@@ -456,8 +461,9 @@ attributes sorted by type name.
456
461
the failure readable; sizes with `Assert.HasCount` and `Assert.IsEmpty`. `CollectionAssert` does not apply: it needs
457
462
the non-generic `ICollection`.
458
463
459
-
C# collection expressions were checked in the design probe. A C# test project is added only if the maintainer wants C#
460
-
covered in CI.
464
+
The maintainers chose to cover C# in CI. The C# MSTest project `tests/FSharp.Collections.Immutable.CSharp.Tests` checks
465
+
what only the C# compiler binds: collection expressions, indices and ranges, `==` and `!=`, the default collections,
466
+
record structs, the implicit conversions and the compiled names of the module.
461
467
462
468
## 8. Benchmarks before release
463
469
@@ -475,11 +481,15 @@ type; JSON within 10 % of `ImmutableArray<'T>`.
475
481
476
482
## 9. Consumers and migration
477
483
478
-
***The first consumer** removes its own `EquatableArray` after the release that contains the type and opens
479
-
`FSharp.Collections.Immutable` instead. The constructor, `Items`, `Length`, `IsEmpty`, the indexer, `for` and the
480
-
module functions it uses keep their names. It will notice three things: the patterns take `EquatableArray<'T>` where
481
-
its own take `ImmutableArray<'T>` (question 4); the type has comparison where its own is `NoComparison`; `ToString ()`
482
-
prints `[|1; 2|]` where its own prints `[| 1; 2 |]`.
484
+
***The first consumer** removes its own `EquatableArray` after the release that contains the type and adds
485
+
`open FSharp.Collections.Immutable` to the files that use it. The constructor, `Items`, `Length`, `IsEmpty`, the
486
+
indexer, `for` and the module functions it uses keep their names. It will notice four things:
487
+
*`ofArray null` and `unsafeOfArray null` throw `ArgumentNullException` where its own return an empty array.
488
+
* The type has comparison where its own is `NoComparison`, so its records and unions gain comparison.
489
+
* The patterns take `EquatableArray<'T>` where its own take `ImmutableArray<'T>` (question 4). Its own patterns are
490
+
not used in its production code.
491
+
*`ToString ()` of an array wider than one line, or longer than 100 elements, wraps and ends in `...`, as `%A` of an
492
+
F# array does. Short arrays print the same `[|1; 2|]`.
483
493
***`FlatList` users** change nothing. They switch a field to `EquatableArray<'T>` where the value is a key, is compared
484
494
or is persisted; stored JSON stays valid (§4).
485
495
***Query translators** that map collection functions by compiled declaring type add
@@ -513,36 +523,38 @@ Deliberately different from the FS-1094 draft:
513
523
|`%A`| the notation of an F# array |`immarray [1; 2; 3]`|
514
524
| Library additions |`Items`, the constructor, `AsMemory`, `Slice`, read-only `IList<'T>`, `==` and `!=`, the JSON converter, the patterns, `equatableArray { }`| no `==`, no converter on the type, patterns left to users |
515
525
516
-
## 11. Open questions
526
+
## 11. Questions and decisions
527
+
528
+
The maintainers accepted every recommendation on 2026-10-18. The questions stay here with the reasons for each answer.
517
529
518
530
1.**Element equality.**`EqualityComparer<'T>.Default`, or the rules of F# lists through `IStructuralEquatable`?
519
-
*Recommendation: `EqualityComparer<'T>.Default`.* It is the only strategy that does not allocate for struct elements,
531
+
*Decided: `EqualityComparer<'T>.Default`.* It is the only strategy that does not allocate for struct elements,
520
532
and allocation-free equality is the first use case. The price is the two differences of §2 and, for elements that
521
533
are arrays, the keys of question 8.
522
-
2.**Comparison.** Length first as for F# arrays, or lexicographic as for F# lists? *Recommendation: length first.* It
534
+
2.**Comparison.** Length first as for F# arrays, or lexicographic as for F# lists? *Decided: length first.* It
523
535
is the rule of F# arrays and of the FS-1094 draft, and arrays of different length are compared without reading an
524
536
element. Independently of that, elements are compared in the order of F# generic comparison and not with
525
-
`Comparer<'T>.Default` as in the first draft of this design (§3); this needs confirming.
526
-
3.**`op_Implicit` in both directions**, or only the named conversions? *Recommendation: both.* The conversions are O(1)
537
+
`Comparer<'T>.Default` as in the first draft of this design (§3); the maintainers confirmed this too.
538
+
3.**`op_Implicit` in both directions**, or only the named conversions? *Decided: both.* The conversions are O(1)
527
539
and lose nothing, a default array becomes empty, and F# warns wherever the conversion is not at a method argument.
528
540
4.**The input of the patterns.**`EquatableArray<'T>`, or `ImmutableArray<'T>` as in the first consumer?
529
-
*Recommendation: `EquatableArray<'T>`*: nested in a union case a pattern cannot convert, at the head of a `match` the
541
+
*Decided: `EquatableArray<'T>`*: nested in a union case a pattern cannot convert, at the head of a `match` the
530
542
wrap is one word. Inline patterns constrained on `Length` and the indexer accept both types and F# arrays without
531
543
allocation *(verified)*, but they throw `NullReferenceException` on a default `ImmutableArray` and need the input
532
544
type known at the pattern.
533
-
5.**Read-only `IList<'T>` and `ICollection<'T>`.***Recommendation: yes.* FSharp.Core and LINQ take their fast paths
545
+
5.**Read-only `IList<'T>` and `ICollection<'T>`.***Decided: yes.* FSharp.Core and LINQ take their fast paths
534
546
for these two interfaces, not for `IReadOnlyList<'T>`. On 1000 `int`*(verified)*: `Seq.length` 4630 ns → 30 ns,
0 commit comments