From 2f0a678da7c74e6316780b780d8ba62e25b840e8 Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Wed, 21 Oct 2026 03:49:44 +0200 Subject: [PATCH] refactor: the `Tuple` and `Option` modules of `FlatList` call the default modules by their short names Each of these files opens `FSharp.Collections.Immutable`, and inside `FSharp.Collections.Immutable.Tuple.FlatList` the name `FlatList` reaches the default module, also for the functions that both modules define, so the full namespace in front of it added nothing. The compiled code is the same: the opcodes and the called methods of every method of both builds match one to one. Co-Authored-By: Claude Sonnet 5.5 --- .../FlatList/FlatListOption.fs | 4 +--- .../FlatList/FlatListTuple.fs | 12 ++++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/FSharp.Collections.Immutable/FlatList/FlatListOption.fs b/src/FSharp.Collections.Immutable/FlatList/FlatListOption.fs index 7307fb3a..6d8398fd 100644 --- a/src/FSharp.Collections.Immutable/FlatList/FlatListOption.fs +++ b/src/FSharp.Collections.Immutable/FlatList/FlatListOption.fs @@ -26,9 +26,7 @@ let tryItem index (array : FlatList<'T>) = Array.tryItem index (unwrapArray (nam let tryLast (array : FlatList<'T>) = Array.tryLast (unwrapArray (nameof array) array) [] -let tryTail (array : FlatList<'T>) = - FSharp.Collections.Immutable.FlatList.tryTail array - |> ValueOption.toOption +let tryTail (array : FlatList<'T>) = FlatList.tryTail array |> ValueOption.toOption // ---- Search ---- diff --git a/src/FSharp.Collections.Immutable/FlatList/FlatListTuple.fs b/src/FSharp.Collections.Immutable/FlatList/FlatListTuple.fs index 3cc458b3..35777d25 100644 --- a/src/FSharp.Collections.Immutable/FlatList/FlatListTuple.fs +++ b/src/FSharp.Collections.Immutable/FlatList/FlatListTuple.fs @@ -15,7 +15,7 @@ let unfold (generator : 'State -> ('T * 'State) voption) (state : 'State) = | ValueSome (item, next) -> ValueSome (struct (item, next)) | ValueNone -> ValueNone - FSharp.Collections.Immutable.FlatList.unfold generateStruct state + FlatList.unfold generateStruct state // ---- Transformation ---- @@ -72,7 +72,7 @@ let mapFold (mapping : 'State -> 'T -> 'Result * 'State) (state : 'State) (array let result, next = mapping state item struct (result, next) - let struct (results, final) = FSharp.Collections.Immutable.FlatList.mapFold mapStruct state array + let struct (results, final) = FlatList.mapFold mapStruct state array results, final [] @@ -81,7 +81,7 @@ let mapFoldBack (mapping : 'T -> 'State -> 'Result * 'State) (array : FlatList<' let result, next = mapping item state struct (result, next) - let struct (results, final) = FSharp.Collections.Immutable.FlatList.mapFoldBack mapStruct array state + let struct (results, final) = FlatList.mapFoldBack mapStruct array state results, final // ---- Partitioning and grouping ---- @@ -98,17 +98,17 @@ let groupBy (projection : 'T -> 'Key) (array : FlatList<'T>) = [] let partition predicate (array : FlatList<'T>) = - let struct (accepted, rejected) = FSharp.Collections.Immutable.FlatList.partition predicate array + let struct (accepted, rejected) = FlatList.partition predicate array accepted, rejected [] let partitionWith (partitioner : 'T -> Choice<'T1, 'T2>) (array : FlatList<'T>) = - let struct (first, second) = FSharp.Collections.Immutable.FlatList.partitionWith partitioner array + let struct (first, second) = FlatList.partitionWith partitioner array first, second [] let splitAt index (array : FlatList<'T>) = - let struct (before, after) = FSharp.Collections.Immutable.FlatList.splitAt index array + let struct (before, after) = FlatList.splitAt index array before, after // As in the module above: the functions that build a tuple per element share their algorithm with the default module,