Skip to content

Commit 3f22fda

Browse files
xperiandriclaude
andcommitted
fixup! docs: HashMap and IMap in the changelog, the collection table and the tutorial
The changelog describes the comparer struct and the functions that create it, the creation members for every shape of the bindings and the nested `Tuple` and `ValueTuple` modules, and names the released comparer functions that they replace. The tutorial creates its hash map from reference tuples, shows `HashMap.forKeyComparer`, and closes its code block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c056dcb commit 3f22fda

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
* The `FlatListBuilder` module works on the builder of a flat list, and `flatList { }` builds a flat list.
1818
* `HashMap` has every function of the FSharp.Core `Map` module that applies to a hash map, with its semantics and
1919
exceptions, plus `choose` and `singleton`, the builder functions, and the wrappers of the `ImmutableDictionary` members
20-
`addRange`, `clear`, `containsValue`, `emptyWithComparers`, `emptyWithKeyComparer`, `keyComparer`, `ofKeyValuePairs`,
21-
`ofKeyValuePairsWithKeyComparer`, `ofSeqBy`, `ofSeqWithKeyComparer`, `removeRange`, `setItem`, `setItems`, `tryGetKey`,
22-
`valueComparer`, `withComparers` and `withKeyComparer`, which keep the semantics of the BCL.
20+
`addRange`, `clear`, `containsValue`, `keyComparer`, `ofSeqBy`, `removeRange`, `setItem`, `setItems`, `tryGetKey` and
21+
`valueComparer`, which keep the semantics of the BCL.
22+
* `HashMap.ofArray`, `HashMap.ofList` and `HashMap.ofSeq` take the bindings as `KeyValuePair`s, reference tuples or struct
23+
tuples: they are static members of `ImmutableDictionary<'Key, 'Value>` in the auto-opened `HashMapExtensions` module, one
24+
overload per shape, and every shape keeps the last binding of a repeated key, as `Map.ofSeq` does. They take a
25+
dictionary, an F# `Map` or another hash map too. C# does not see them as members.
26+
* `HashMap.forComparers` and `HashMap.forKeyComparer` return a `CustomComparersHashMap<'Key, 'Value>` struct whose members
27+
`empty`, `singleton`, `ofArray`, `ofList`, `ofSeq`, `ofSeqBy` and `builder` create hash maps with its comparers:
28+
`(HashMap.forKeyComparer StringComparer.OrdinalIgnoreCase).ofSeq pairs`. Its `ofSeq` gives an existing map the comparers
29+
of the struct. A `null` comparer throws `ArgumentNullException`.
30+
* `HashMap.addRange` and `HashMap.setItems` take `KeyValuePair`s; the nested modules `HashMap.Tuple` and
31+
`HashMap.ValueTuple` take reference and struct tuples: `HashMap.Tuple.addRange pairs table`.
2332
* The `IMap` module works on any `IImmutableDictionary<'Key, 'Value>` with the same functions, except the creation, builder
24-
and comparer functions and `containsValue`. Its transformations keep the implementation and the comparers of the map;
25-
`map` and `choose` return a `HashMap`.
33+
and comparer functions and `containsValue`, and has the nested modules `Tuple` and `ValueTuple` too. Its transformations
34+
keep the implementation and the comparers of the map; `map` and `choose` return a `HashMap`.
2635
* The `FSharp.Collections.Immutable.Option` and `FSharp.Collections.Immutable.Tuple` namespaces have `HashMap` and `IMap`
27-
modules that repeat the functions that use value options or struct tuples with options and reference tuples.
36+
modules that repeat the functions that use value options or return struct tuples with options and reference tuples.
2837
* `hashMap { }` builds a hash map from `yield struct (key, value)` and `yield KeyValuePair (key, value)`; `HashMapCE` takes
29-
a key comparer.
38+
a key comparer, and a `null` one throws `ArgumentNullException`.
3039

3140
### Changed
3241

@@ -37,12 +46,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3746
* `FlatList`: every function throws what the FSharp.Core `Array` function of the same name throws. `take` and `splitAt`
3847
throw for a count beyond the length, and a default `ImmutableArray` throws `ArgumentNullException`.
3948
* `HashMap`: `tryFind` and `tryPick` return `voption`, and `pick` and `tryPick` take choosers that return `voption`.
40-
`ofArray`, `ofList`, `ofSeq`, `toArray`, `toList` and `toSeq` take and return struct tuples instead of `KeyValuePair`s;
41-
`ofKeyValuePairs` takes `KeyValuePair`s.
49+
`toArray`, `toList` and `toSeq` return struct tuples instead of `KeyValuePair`s.
4250
* `HashMap` follows the FSharp.Core `Map` module: `add` replaces the value of an existing key instead of throwing, `ofArray`
43-
and `ofSeq` keep the last binding of a repeated key, `filter` returns a map instead of a sequence, `map` keeps the keys
44-
and takes a function of the key and the value, `singleton` takes the key and the value curried, and `find`, `findKey`
45-
and `pick` throw the `KeyNotFoundException` of `Map`. A `null` map throws `ArgumentNullException`.
51+
and `ofSeq` keep the last binding of a repeated key instead of throwing, `filter` returns a map instead of a sequence,
52+
`map` keeps the keys and takes a function of the key and the value, `singleton` takes the key and the value curried, and
53+
`find`, `findKey` and `pick` throw the `KeyNotFoundException` of `Map`. A `null` map throws `ArgumentNullException`.
4654
* `HashMap`: every transformation keeps the key comparer of the map, and the value comparer when the type of the values
4755
does not change.
4856

@@ -53,8 +61,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5361
* `FlatList.removeAll`, `removeAllWith`, `removeRange`, `sortRange`, `sortRangeWith`, `sortRangeWithComparer` and `sub`,
5462
and the `ImmutableArray` module alias of `FlatList`.
5563
* The `Seq` module of conversions between the collections.
56-
* `HashMap.length`, `append`, `except`, `where`, `ofKeyComparer` and `ofComparers`: use `count`, `addRange`, `removeRange`,
57-
`filter`, `emptyWithKeyComparer` and `emptyWithComparers`.
64+
* `HashMap.length`, `append`, `except` and `where`: use `count`, `addRange`, `removeRange` and `filter`.
65+
* `HashMap.ofKeyComparer`, `ofComparers`, `builderWithKeyComparer` and `builderWithComparers`: use the members `empty` and
66+
`builder` of `HashMap.forKeyComparer` and `HashMap.forComparers`.
5867
* `HashMap.vTryFind`, `vTryPick` and `ofSeqWith`: use `tryFind`, `tryPick` and `ofSeqBy`.
5968
* `HashMap.ofSeqGroupBy`, `HashMap.check` and the `HashMapBuilder` abbreviation: group with the `groupBy` of a collection
6069
module and pass the groups to `HashMap.ofSeq`, and use `HashMap<'Key, 'Value>.Builder`.

‎docsSrc/Tutorials/Getting_Started.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ let list1 = ImmutableList.ofSeq [1; 2; 3]
2727
// Create an immutable hash set
2828
let set1 = HashSet.ofSeq ["a"; "b"]
2929
30-
// Create an immutable dictionary
31-
let dict1 = HashMap.ofSeq [ struct ("key1", 42); struct ("key2", 100) ]
30+
// Create an immutable dictionary from tuples, key/value pairs or struct tuples
31+
let dict1 = HashMap.ofSeq [ "key1", 42; "key2", 100 ]
32+
33+
// Create an immutable dictionary whose keys ignore the case; the later binding of "KEY1" wins
34+
let dict2 = (HashMap.forKeyComparer System.StringComparer.OrdinalIgnoreCase).ofSeq [ "key1", 42; "KEY1", 100 ]
3235
3336
3437
printfn "List: %A" (list1 |> Seq.toList)
3538
printfn "Set: %A" (set1 |> Seq.toList)
3639
printfn "Dict: %A" (dict1 |> Seq.toList)
40+
printfn "Dict ignoring the case: %A" (dict2 |> Seq.toList)
41+
```
42+
3743
## Next Steps
3844

3945
- Check out the [How-To Guides](../How_Tos/Doing_A_Thing.html) for common scenarios

0 commit comments

Comments
 (0)