Skip to content

Commit 3ff05d9

Browse files
xperiandriclaude
andcommitted
docs: HashMap and IMap in the changelog, the collection table and the tutorial
The tutorial creates its hash map from struct tuples, which `HashMap.ofSeq` takes now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent afee68b commit 3ff05d9

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* The `FSharp.Collections.Immutable.Option.FlatList` and `FSharp.Collections.Immutable.Tuple.FlatList` modules repeat the
1616
functions that use value options or struct tuples with options and reference tuples.
1717
* The `FlatListBuilder` module works on the builder of a flat list, and `flatList { }` builds a flat list.
18+
* `HashMap` has every function of the FSharp.Core `Map` module that applies to a hash map, with its semantics and
19+
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.
23+
* 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`.
26+
* 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.
28+
* `hashMap { }` builds a hash map from `yield struct (key, value)` and `yield KeyValuePair (key, value)`; `HashMapCE` takes
29+
a key comparer.
1830

1931
### Changed
2032

@@ -24,6 +36,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2436
`voption`; the functions that return tuples return struct tuples.
2537
* `FlatList`: every function throws what the FSharp.Core `Array` function of the same name throws. `take` and `splitAt`
2638
throw for a count beyond the length, and a default `ImmutableArray` throws `ArgumentNullException`.
39+
* `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.
42+
* `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`.
46+
* `HashMap`: every transformation keeps the key comparer of the map, and the value comparer when the type of the values
47+
does not change.
2748

2849
### Removed
2950

@@ -32,6 +53,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3253
* `FlatList.removeAll`, `removeAllWith`, `removeRange`, `sortRange`, `sortRangeWith`, `sortRangeWithComparer` and `sub`,
3354
and the `ImmutableArray` module alias of `FlatList`.
3455
* 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`.
58+
* `HashMap.vTryFind`, `vTryPick` and `ofSeqWith`: use `tryFind`, `tryPick` and `ofSeqBy`.
59+
* `HashMap.ofSeqGroupBy`, `HashMap.check` and the `HashMapBuilder` abbreviation: group with the `groupBy` of a collection
60+
module and pass the groups to `HashMap.ofSeq`, and use `HashMap<'Key, 'Value>.Builder`.
3561

3662
## [1.0.0] - 2020-02-23
3763

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Please also join the [F# Open Source Group](http://fsharp.github.com)
1616
| `ImmutableList` | `ImmutableList<'T>` | – |
1717
| `Stack` | `ImmutableStack<'T>` | – |
1818
| `Queue` | `ImmutableQueue<'T>` | – |
19-
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | – |
19+
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | `hashMap { }` |
20+
| `IMap` | `IImmutableDictionary<'Key, 'Value>` | – |
2021
| `SortedMap` | `ImmutableSortedDictionary<'Key, 'Value>` | – |
2122
| `HashSet` | `ImmutableHashSet<'T>` | – |
2223
| `SortedSet` | `ImmutableSortedSet<'T>` | – |

‎docsSrc/Explanations/Background.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ While F# has its own built-in immutable collections, System.Collections.Immutabl
3030
| `ImmutableList` | `ImmutableList<'T>` | – |
3131
| `Stack` | `ImmutableStack<'T>` | – |
3232
| `Queue` | `ImmutableQueue<'T>` | – |
33-
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | – |
33+
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | `hashMap { }` |
34+
| `IMap` | `IImmutableDictionary<'Key, 'Value>` | – |
3435
| `SortedMap` | `ImmutableSortedDictionary<'Key, 'Value>` | – |
3536
| `HashSet` | `ImmutableHashSet<'T>` | – |
3637
| `SortedSet` | `ImmutableSortedSet<'T>` | – |

‎docsSrc/Tutorials/Getting_Started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let list1 = ImmutableList.ofSeq [1; 2; 3]
2828
let set1 = HashSet.ofSeq ["a"; "b"]
2929
3030
// Create an immutable dictionary
31-
let dict1 = HashMap.ofSeq [KeyValuePair ("key1", 42); KeyValuePair ("key2", 100)]
31+
let dict1 = HashMap.ofSeq [ struct ("key1", 42); struct ("key2", 100) ]
3232
3333
3434
printfn "List: %A" (list1 |> Seq.toList)

‎docsSrc/index.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ F# bindings for [System.Collections.Immutable](https://learn.microsoft.com/en-us
1212
| `ImmutableList` | `ImmutableList<'T>` | – |
1313
| `Stack` | `ImmutableStack<'T>` | – |
1414
| `Queue` | `ImmutableQueue<'T>` | – |
15-
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | – |
15+
| `HashMap` | `ImmutableDictionary<'Key, 'Value>` | `hashMap { }` |
16+
| `IMap` | `IImmutableDictionary<'Key, 'Value>` | – |
1617
| `SortedMap` | `ImmutableSortedDictionary<'Key, 'Value>` | – |
1718
| `HashSet` | `ImmutableHashSet<'T>` | – |
1819
| `SortedSet` | `ImmutableSortedSet<'T>` | – |

0 commit comments

Comments
 (0)