Skip to content

Commit cbf0a56

Browse files
xperiandriclaude
andcommitted
fixup! docs: HashSet and ISet in the changelog and the collection table
The changelog gave `HashSet.ofSeq elements` as the way to pass a sequence to `IsSubsetOf`, `IsProperSubsetOf`, `IsProperSupersetOf`, `SetEquals`, `Intersect` and `SymmetricExcept`, or `(HashSet.forComparer (HashSet.comparer set)).ofSeq elements` to give the elements the comparer of the first hash set. `ofSeq elements` converts them with the default comparer, which merges the elements that it finds equal before the function sees them. The answer is the one of the member when the comparer of the hash set finds equal every pair of elements that the default comparer finds equal, as the default comparer and `StringComparer.OrdinalIgnoreCase` do. It can differ when the comparer tells such elements apart, as `HashIdentity.Reference` does for two strings with the same text: a hash set that compares by reference and holds both is a subset of the sequence of both, but not of the hash set that the default comparer makes of it, which keeps one of them. The conversion with the comparer of the first hash set is now the recipe, `HashSet.ofSeq` is named with the condition and the counterexample, and `Overlaps` and `IsSupersetOf` stay `Seq.exists` and `Seq.forall` with `HashSet.contains`, which compare in the comparer of the hash set for every comparer. The `ISet` bullet gives the recipe of the interface, which cannot tell its comparer: `ISet.addRange elements (ISet.clear set)`, which has the implementation and the comparer of the set. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 1998f40 commit cbf0a56

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5656
`tryGetValue` returns a `voption`, `choose` takes a function that returns a `voption`, and `partition` and
5757
`partitionWith` return struct tuples.
5858
* The set algebra and the relations of `HashSet` take hash sets, as the `Set` functions do. The BCL members that take a
59-
sequence map as follows: `Union` and `Except` are `addRange` and `removeRange`, `Overlaps` and `IsSupersetOf` are
60-
`Seq.exists` and `Seq.forall` with `contains`, and the others take `HashSet.ofSeq elements`, or
61-
`(HashSet.forComparer (HashSet.comparer set)).ofSeq elements` to give the elements the comparer of the first hash set.
59+
sequence map as follows. `Union` and `Except` are `addRange` and `removeRange`, and `Overlaps` and `IsSupersetOf` are
60+
`Seq.exists` and `Seq.forall` with `HashSet.contains`, which compare in the comparer of the hash set for every
61+
comparer. To pass a sequence to `Intersect`, `SymmetricExcept`, `IsSubsetOf`, `IsProperSubsetOf`,
62+
`IsProperSupersetOf` or `SetEquals`, convert it with `(HashSet.forComparer (HashSet.comparer set)).ofSeq elements`:
63+
the elements get the comparer of the first hash set, as they do in the members. `HashSet.ofSeq elements` converts
64+
them with the default comparer instead, which merges the elements that it finds equal before the function sees them.
65+
The answer is that of the member when the comparer of `set` finds equal every pair of elements that the default
66+
comparer finds equal, as the default comparer and `StringComparer.OrdinalIgnoreCase` do. It can differ when the
67+
comparer of `set` tells such elements apart, as `HashIdentity.Reference` does for two strings with the same text.
6268
* The element that stays when the comparer finds two elements equal follows the BCL: `union` and `addRange` keep the
6369
element of the first hash set, `intersect` keeps the elements of the second one, and the creation functions keep the
6470
first element of their input. `isProperSuperset` is the exception: it counts the elements of the second hash set that
6571
the comparer of the first one finds equal once, as the documentation of `IsProperSupersetOf` says, where the member
6672
counts each of them.
6773
* The `ISet` module works on any `IImmutableSet<'T>` with the functions of `HashSet` that need neither a creation nor a
6874
comparer, `addRange` and `removeRange` included; the transformations that keep the element type return the
69-
implementation of their input.
75+
implementation of their input. The interface cannot tell its comparer, so a sequence for a relation, `intersect` or
76+
`symmetricDifference` is converted with `ISet.addRange elements (ISet.clear set)`, which has the implementation and
77+
the comparer of `set`, where `HashSet` uses `(HashSet.forComparer (HashSet.comparer set)).ofSeq elements`.
7078
* The `FSharp.Collections.Immutable.Option.HashSet`, `FSharp.Collections.Immutable.Tuple.HashSet`,
7179
`FSharp.Collections.Immutable.Option.ISet` and `FSharp.Collections.Immutable.Tuple.ISet` modules repeat `choose` and
7280
`tryGetValue` with options, and `partition` and `partitionWith` with reference tuples.

0 commit comments

Comments
 (0)