Skip to content

Commit c12e4bb

Browse files
xperiandriclaude
andcommitted
refactor: the Tuple and Option modules of HashMap and IMap call the default modules by their short names
Each of these files opens `FSharp.Collections.Immutable`, and inside `FSharp.Collections.Immutable.Tuple.HashMap` the name `HashMap` 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 <noreply@anthropic.com>
1 parent 53d466c commit c12e4bb

4 files changed

Lines changed: 16 additions & 31 deletions

File tree

‎src/FSharp.Collections.Immutable/HashMap/HashMapOption.fs‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,31 @@ open FSharp.Collections.Immutable
99
// ---- Access ----
1010

1111
[<CompiledName "TryFind">]
12-
let tryFind (key : 'Key) (table : HashMap<'Key, 'Value>) =
13-
FSharp.Collections.Immutable.HashMap.tryFind key table
14-
|> ValueOption.toOption
12+
let tryFind (key : 'Key) (table : HashMap<'Key, 'Value>) = HashMap.tryFind key table |> ValueOption.toOption
1513

1614
[<CompiledName "TryGetKey">]
17-
let tryGetKey (key : 'Key) (table : HashMap<'Key, 'Value>) =
18-
FSharp.Collections.Immutable.HashMap.tryGetKey key table
19-
|> ValueOption.toOption
15+
let tryGetKey (key : 'Key) (table : HashMap<'Key, 'Value>) = HashMap.tryGetKey key table |> ValueOption.toOption
2016

2117
// ---- Search ----
2218

2319
[<CompiledName "Pick">]
2420
let pick (chooser : 'Key -> 'Value -> 'U option) (table : HashMap<'Key, 'Value>) =
25-
FSharp.Collections.Immutable.HashMap.pick (fun key value -> chooser key value |> ValueOption.ofOption) table
21+
HashMap.pick (fun key value -> chooser key value |> ValueOption.ofOption) table
2622

2723
[<CompiledName "TryFindKey">]
28-
let tryFindKey predicate (table : HashMap<'Key, 'Value>) =
29-
FSharp.Collections.Immutable.HashMap.tryFindKey predicate table
30-
|> ValueOption.toOption
24+
let tryFindKey predicate (table : HashMap<'Key, 'Value>) = HashMap.tryFindKey predicate table |> ValueOption.toOption
3125

3226
[<CompiledName "TryPick">]
3327
let tryPick (chooser : 'Key -> 'Value -> 'U option) (table : HashMap<'Key, 'Value>) =
34-
FSharp.Collections.Immutable.HashMap.tryPick (fun key value -> chooser key value |> ValueOption.ofOption) table
28+
HashMap.tryPick (fun key value -> chooser key value |> ValueOption.ofOption) table
3529
|> ValueOption.toOption
3630

3731
// ---- Transformation ----
3832

3933
[<CompiledName "Change">]
4034
let change (key : 'Key) (f : 'Value option -> 'Value option) (table : HashMap<'Key, 'Value>) =
41-
FSharp.Collections.Immutable.HashMap.change
42-
key
43-
(fun current -> f (ValueOption.toOption current) |> ValueOption.ofOption)
44-
table
35+
HashMap.change key (fun current -> f (ValueOption.toOption current) |> ValueOption.ofOption) table
4536

4637
[<CompiledName "Choose">]
4738
let choose (chooser : 'Key -> 'Value -> 'U option) (table : HashMap<'Key, 'Value>) =
48-
FSharp.Collections.Immutable.HashMap.choose (fun key value -> chooser key value |> ValueOption.ofOption) table
39+
HashMap.choose (fun key value -> chooser key value |> ValueOption.ofOption) table

‎src/FSharp.Collections.Immutable/HashMap/HashMapTuple.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open FSharp.Collections.Immutable
1010

1111
[<CompiledName "Partition">]
1212
let partition predicate (table : HashMap<'Key, 'Value>) =
13-
let struct (accepted, rejected) = FSharp.Collections.Immutable.HashMap.partition predicate table
13+
let struct (accepted, rejected) = HashMap.partition predicate table
1414
accepted, rejected
1515

1616
// ---- Conversion ----

‎src/FSharp.Collections.Immutable/HashMap/IMapOption.fs‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,31 @@ open FSharp.Collections.Immutable
99
// ---- Access ----
1010

1111
[<CompiledName "TryFind">]
12-
let tryFind (key : 'Key) (table : IMap<'Key, 'Value>) =
13-
FSharp.Collections.Immutable.IMap.tryFind key table
14-
|> ValueOption.toOption
12+
let tryFind (key : 'Key) (table : IMap<'Key, 'Value>) = IMap.tryFind key table |> ValueOption.toOption
1513

1614
[<CompiledName "TryGetKey">]
17-
let tryGetKey (key : 'Key) (table : IMap<'Key, 'Value>) =
18-
FSharp.Collections.Immutable.IMap.tryGetKey key table
19-
|> ValueOption.toOption
15+
let tryGetKey (key : 'Key) (table : IMap<'Key, 'Value>) = IMap.tryGetKey key table |> ValueOption.toOption
2016

2117
// ---- Search ----
2218

2319
[<CompiledName "Pick">]
2420
let pick (chooser : 'Key -> 'Value -> 'U option) (table : IMap<'Key, 'Value>) =
25-
FSharp.Collections.Immutable.IMap.pick (fun key value -> chooser key value |> ValueOption.ofOption) table
21+
IMap.pick (fun key value -> chooser key value |> ValueOption.ofOption) table
2622

2723
[<CompiledName "TryFindKey">]
28-
let tryFindKey predicate (table : IMap<'Key, 'Value>) =
29-
FSharp.Collections.Immutable.IMap.tryFindKey predicate table
30-
|> ValueOption.toOption
24+
let tryFindKey predicate (table : IMap<'Key, 'Value>) = IMap.tryFindKey predicate table |> ValueOption.toOption
3125

3226
[<CompiledName "TryPick">]
3327
let tryPick (chooser : 'Key -> 'Value -> 'U option) (table : IMap<'Key, 'Value>) =
34-
FSharp.Collections.Immutable.IMap.tryPick (fun key value -> chooser key value |> ValueOption.ofOption) table
28+
IMap.tryPick (fun key value -> chooser key value |> ValueOption.ofOption) table
3529
|> ValueOption.toOption
3630

3731
// ---- Transformation ----
3832

3933
[<CompiledName "Change">]
4034
let change (key : 'Key) (f : 'Value option -> 'Value option) (table : IMap<'Key, 'Value>) =
41-
FSharp.Collections.Immutable.IMap.change key (fun current -> f (ValueOption.toOption current) |> ValueOption.ofOption) table
35+
IMap.change key (fun current -> f (ValueOption.toOption current) |> ValueOption.ofOption) table
4236

4337
[<CompiledName "Choose">]
4438
let choose (chooser : 'Key -> 'Value -> 'U option) (table : IMap<'Key, 'Value>) =
45-
FSharp.Collections.Immutable.IMap.choose (fun key value -> chooser key value |> ValueOption.ofOption) table
39+
IMap.choose (fun key value -> chooser key value |> ValueOption.ofOption) table

‎src/FSharp.Collections.Immutable/HashMap/IMapTuple.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open FSharp.Collections.Immutable
1010

1111
[<CompiledName "Partition">]
1212
let partition predicate (table : IMap<'Key, 'Value>) =
13-
let struct (accepted, rejected) = FSharp.Collections.Immutable.IMap.partition predicate table
13+
let struct (accepted, rejected) = IMap.partition predicate table
1414
accepted, rejected
1515

1616
// ---- Conversion ----

0 commit comments

Comments
 (0)