Skip to content

Commit b38b9eb

Browse files
xperiandriclaude
andcommitted
feat: IndexedList and IIndexedList modules with the vocabulary of the FSharp.Core List module
`IndexedList` (`ImmutableList<'T>`) replaces the `ImmutableList` module. It has every function of `List` that applies to an immutable list, with the parameter names, the checks and the exceptions of `List` and with stable sorts, plus the extras of ADR 0001: `add`, `binarySearch`, `blit`, `cons`, `uncons`, `tryUncons`, the struct partial patterns `Cons` and `Nil`, `indexOf`, `lastIndexOf`, `skipLast`, `takeLast`, `tryTail` and `sortWithComparer`. `IIndexedList` has the same functions for `IImmutableList<'T>` without creation, builder, `binarySearch` and `blit`, plus `clear`; a result with the element type of the input keeps the implementation of the input. The `Option` and `Tuple` namespaces repeat the functions that use value options or struct tuples, `IndexedListBuilder` works on the builder of an indexed list, and `indexedList { }` builds one. `Helper.fs` gains three internal modules for the modules that mirror `List`: `ListChecks` throws the exceptions of `List` for lengths and indices with the parameter names that the caller passes, `ListArrays` runs the functions of two and three lists over arrays and checks the lengths after the common prefix, as `List` does, and `Snapshot` copies a collection into an array. The `ImmutableList` and `IndexedSeq` modules, the `ReadOnlyList` alias and the `IIndexedSeq<'T>` abbreviation are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2b5179a commit b38b9eb

19 files changed

Lines changed: 6445 additions & 372 deletions

‎src/FSharp.Collections.Immutable/ComputationExpressions.fs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,17 @@ module ComputationExpressions =
1717
/// Evaluates to a flat list of 0, 1, 4, 9, 100 and 200.
1818
/// </example>
1919
let flatList = FlatListCE ()
20+
21+
/// <summary>Builds an indexed list.</summary>
22+
/// <example id="indexedList-1">
23+
/// <code lang="fsharp">
24+
/// let squares = indexedList {
25+
/// yield 0
26+
/// for i in 1..3 do
27+
/// yield i * i
28+
/// yield! [ 100; 200 ]
29+
/// }
30+
/// </code>
31+
/// Evaluates to an indexed list of 0, 1, 4, 9, 100 and 200.
32+
/// </example>
33+
let indexedList = IndexedListCE ()

‎src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,22 @@
2929
<Compile Include="FlatList\FlatListTuple.fs" />
3030
<Compile Include="FlatList\FlatListBuilder.fs" />
3131
<Compile Include="FlatList\FlatListCE.fs" />
32+
<Compile Include="IndexedList\IndexedList.fsi" />
33+
<Compile Include="IndexedList\IndexedList.fs" />
34+
<Compile Include="IndexedList\IndexedListOption.fsi" />
35+
<Compile Include="IndexedList\IndexedListOption.fs" />
36+
<Compile Include="IndexedList\IndexedListTuple.fsi" />
37+
<Compile Include="IndexedList\IndexedListTuple.fs" />
38+
<Compile Include="IndexedList\IIndexedList.fsi" />
39+
<Compile Include="IndexedList\IIndexedList.fs" />
40+
<Compile Include="IndexedList\IIndexedListOption.fsi" />
41+
<Compile Include="IndexedList\IIndexedListOption.fs" />
42+
<Compile Include="IndexedList\IIndexedListTuple.fsi" />
43+
<Compile Include="IndexedList\IIndexedListTuple.fs" />
44+
<Compile Include="IndexedList\IndexedListBuilder.fs" />
45+
<Compile Include="IndexedList\IndexedListCE.fs" />
3246
<Compile Include="Stack.fs" />
33-
<Compile Include="ImmutableList.fs" />
3447
<Compile Include="Queue.fs" />
35-
<Compile Include="IndexedSeq.fs" />
3648
<Compile Include="Maps.fs" />
3749
<Compile Include="Sets.fs" />
3850
<Compile Include="ComputationExpressions.fs" />

‎src/FSharp.Collections.Immutable/Helper.fs‎

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.

‎src/FSharp.Collections.Immutable/ImmutableList.fs‎

Lines changed: 0 additions & 353 deletions
This file was deleted.

0 commit comments

Comments
 (0)