Skip to content

Commit 7fca839

Browse files
xperiandriclaude
andcommitted
refactor: the Tuple and Option modules of IStack and Stack call the default modules by their short names
Each of these files opens `FSharp.Collections.Immutable`, and inside `FSharp.Collections.Immutable.Tuple.IStack` the name `IStack` 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 e005058 commit 7fca839

4 files changed

Lines changed: 40 additions & 71 deletions

File tree

‎src/FSharp.Collections.Immutable/Stack/IStackOption.fs‎

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,20 @@ open FSharp.Collections.Immutable
99
// ---- Access ----
1010

1111
[<CompiledName "TryExactlyOne">]
12-
let tryExactlyOne (stack : IStack<'T>) =
13-
FSharp.Collections.Immutable.IStack.tryExactlyOne stack
14-
|> ValueOption.toOption
12+
let tryExactlyOne (stack : IStack<'T>) = IStack.tryExactlyOne stack |> ValueOption.toOption
1513

1614
[<CompiledName "TryPeek">]
17-
let tryHead (stack : IStack<'T>) =
18-
FSharp.Collections.Immutable.IStack.tryHead stack
19-
|> ValueOption.toOption
15+
let tryHead (stack : IStack<'T>) = IStack.tryHead stack |> ValueOption.toOption
2016

2117
[<CompiledName "TryLast">]
22-
let tryLast (stack : IStack<'T>) =
23-
FSharp.Collections.Immutable.IStack.tryLast stack
24-
|> ValueOption.toOption
18+
let tryLast (stack : IStack<'T>) = IStack.tryLast stack |> ValueOption.toOption
2519

2620
[<CompiledName "TryPop">]
27-
let tryTail (stack : IStack<'T>) =
28-
FSharp.Collections.Immutable.IStack.tryTail stack
29-
|> ValueOption.toOption
21+
let tryTail (stack : IStack<'T>) = IStack.tryTail stack |> ValueOption.toOption
3022

3123
[<CompiledName "TryPeekPop">]
3224
let tryUncons (stack : IStack<'T>) =
33-
match FSharp.Collections.Immutable.IStack.tryUncons stack with
25+
match IStack.tryUncons stack with
3426
| ValueSome (struct (head, tail)) -> Some (head, tail)
3527
| ValueNone -> None
3628

@@ -40,36 +32,29 @@ let (|Cons|_|) (stack : IStack<'T>) = tryUncons stack
4032
// ---- Search ----
4133

4234
[<CompiledName "Pick">]
43-
let pick (chooser : 'T -> 'U option) (stack : IStack<'T>) =
44-
FSharp.Collections.Immutable.IStack.pick (fun item -> chooser item |> ValueOption.ofOption) stack
35+
let pick (chooser : 'T -> 'U option) (stack : IStack<'T>) = IStack.pick (fun item -> chooser item |> ValueOption.ofOption) stack
4536

4637
[<CompiledName "TryFind">]
47-
let tryFind predicate (stack : IStack<'T>) =
48-
FSharp.Collections.Immutable.IStack.tryFind predicate stack
49-
|> ValueOption.toOption
38+
let tryFind predicate (stack : IStack<'T>) = IStack.tryFind predicate stack |> ValueOption.toOption
5039

5140
[<CompiledName "TryFindBack">]
52-
let tryFindBack predicate (stack : IStack<'T>) =
53-
FSharp.Collections.Immutable.IStack.tryFindBack predicate stack
54-
|> ValueOption.toOption
41+
let tryFindBack predicate (stack : IStack<'T>) = IStack.tryFindBack predicate stack |> ValueOption.toOption
5542

5643
[<CompiledName "TryFindIndex">]
57-
let tryFindIndex predicate (stack : IStack<'T>) =
58-
FSharp.Collections.Immutable.IStack.tryFindIndex predicate stack
59-
|> ValueOption.toOption
44+
let tryFindIndex predicate (stack : IStack<'T>) = IStack.tryFindIndex predicate stack |> ValueOption.toOption
6045

6146
[<CompiledName "TryFindIndexBack">]
6247
let tryFindIndexBack predicate (stack : IStack<'T>) =
63-
FSharp.Collections.Immutable.IStack.tryFindIndexBack predicate stack
48+
IStack.tryFindIndexBack predicate stack
6449
|> ValueOption.toOption
6550

6651
[<CompiledName "TryPick">]
6752
let tryPick (chooser : 'T -> 'U option) (stack : IStack<'T>) =
68-
FSharp.Collections.Immutable.IStack.tryPick (fun item -> chooser item |> ValueOption.ofOption) stack
53+
IStack.tryPick (fun item -> chooser item |> ValueOption.ofOption) stack
6954
|> ValueOption.toOption
7055

7156
// ---- Transformation ----
7257

7358
[<CompiledName "Choose">]
7459
let choose (chooser : 'T -> 'U option) (stack : IStack<'T>) =
75-
FSharp.Collections.Immutable.IStack.choose (fun item -> chooser item |> ValueOption.ofOption) stack
60+
IStack.choose (fun item -> chooser item |> ValueOption.ofOption) stack

‎src/FSharp.Collections.Immutable/Stack/IStackTuple.fs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ open FSharp.Collections.Immutable.StackConstruction
1111

1212
[<CompiledName "TryPeekPop">]
1313
let tryUncons (stack : IStack<'T>) =
14-
match FSharp.Collections.Immutable.IStack.tryUncons stack with
14+
match IStack.tryUncons stack with
1515
| ValueSome (struct (head, tail)) -> ValueSome (head, tail)
1616
| ValueNone -> ValueNone
1717

1818
[<CompiledName "PeekPop">]
1919
let uncons (stack : IStack<'T>) =
20-
let struct (head, tail) = FSharp.Collections.Immutable.IStack.uncons stack
20+
let struct (head, tail) = IStack.uncons stack
2121
head, tail
2222

2323
[<return : Struct>]
@@ -80,7 +80,7 @@ let mapFold (mapping : 'State -> 'T -> 'Result * 'State) (state : 'State) (stack
8080
let result, next = mapping state item
8181
struct (result, next)
8282

83-
let struct (results, final) = FSharp.Collections.Immutable.IStack.mapFold mapStruct state stack
83+
let struct (results, final) = IStack.mapFold mapStruct state stack
8484
results, final
8585

8686
[<CompiledName "MapFoldBack">]
@@ -89,7 +89,7 @@ let mapFoldBack (mapping : 'T -> 'State -> 'Result * 'State) (stack : IStack<'T>
8989
let result, next = mapping item state
9090
struct (result, next)
9191

92-
let struct (results, final) = FSharp.Collections.Immutable.IStack.mapFoldBack mapStruct stack state
92+
let struct (results, final) = IStack.mapFoldBack mapStruct stack state
9393
results, final
9494

9595
// ---- Partitioning and grouping ----
@@ -106,15 +106,15 @@ let groupBy (projection : 'T -> 'Key) (stack : IStack<'T>) =
106106

107107
[<CompiledName "Partition">]
108108
let partition predicate (stack : IStack<'T>) =
109-
let struct (accepted, rejected) = FSharp.Collections.Immutable.IStack.partition predicate stack
109+
let struct (accepted, rejected) = IStack.partition predicate stack
110110
accepted, rejected
111111

112112
[<CompiledName "PartitionWith">]
113113
let partitionWith (partitioner : 'T -> Choice<'T1, 'T2>) (stack : IStack<'T>) =
114-
let struct (first, second) = FSharp.Collections.Immutable.IStack.partitionWith partitioner stack
114+
let struct (first, second) = IStack.partitionWith partitioner stack
115115
first, second
116116

117117
[<CompiledName "SplitAt">]
118118
let splitAt index (stack : IStack<'T>) =
119-
let struct (before, after) = FSharp.Collections.Immutable.IStack.splitAt index stack
119+
let struct (before, after) = IStack.splitAt index stack
120120
before, after

‎src/FSharp.Collections.Immutable/Stack/StackOption.fs‎

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,25 @@ let unfold (generator : 'State -> ('T * 'State) option) (state : 'State) =
1515
| Some (item, next) -> ValueSome (struct (item, next))
1616
| None -> ValueNone
1717

18-
FSharp.Collections.Immutable.Stack.unfold generateStruct state
18+
Stack.unfold generateStruct state
1919

2020
// ---- Access ----
2121

2222
[<CompiledName "TryExactlyOne">]
23-
let tryExactlyOne (stack : Stack<'T>) =
24-
FSharp.Collections.Immutable.Stack.tryExactlyOne stack
25-
|> ValueOption.toOption
23+
let tryExactlyOne (stack : Stack<'T>) = Stack.tryExactlyOne stack |> ValueOption.toOption
2624

2725
[<CompiledName "TryPeek">]
28-
let tryHead (stack : Stack<'T>) =
29-
FSharp.Collections.Immutable.Stack.tryHead stack
30-
|> ValueOption.toOption
26+
let tryHead (stack : Stack<'T>) = Stack.tryHead stack |> ValueOption.toOption
3127

3228
[<CompiledName "TryLast">]
33-
let tryLast (stack : Stack<'T>) =
34-
FSharp.Collections.Immutable.Stack.tryLast stack
35-
|> ValueOption.toOption
29+
let tryLast (stack : Stack<'T>) = Stack.tryLast stack |> ValueOption.toOption
3630

3731
[<CompiledName "TryPop">]
38-
let tryTail (stack : Stack<'T>) =
39-
FSharp.Collections.Immutable.Stack.tryTail stack
40-
|> ValueOption.toOption
32+
let tryTail (stack : Stack<'T>) = Stack.tryTail stack |> ValueOption.toOption
4133

4234
[<CompiledName "TryPeekPop">]
4335
let tryUncons (stack : Stack<'T>) =
44-
match FSharp.Collections.Immutable.Stack.tryUncons stack with
36+
match Stack.tryUncons stack with
4537
| ValueSome (struct (head, tail)) -> Some (head, tail)
4638
| ValueNone -> None
4739

@@ -51,36 +43,28 @@ let (|Cons|_|) (stack : Stack<'T>) = tryUncons stack
5143
// ---- Search ----
5244

5345
[<CompiledName "Pick">]
54-
let pick (chooser : 'T -> 'U option) (stack : Stack<'T>) =
55-
FSharp.Collections.Immutable.Stack.pick (fun item -> chooser item |> ValueOption.ofOption) stack
46+
let pick (chooser : 'T -> 'U option) (stack : Stack<'T>) = Stack.pick (fun item -> chooser item |> ValueOption.ofOption) stack
5647

5748
[<CompiledName "TryFind">]
58-
let tryFind predicate (stack : Stack<'T>) =
59-
FSharp.Collections.Immutable.Stack.tryFind predicate stack
60-
|> ValueOption.toOption
49+
let tryFind predicate (stack : Stack<'T>) = Stack.tryFind predicate stack |> ValueOption.toOption
6150

6251
[<CompiledName "TryFindBack">]
63-
let tryFindBack predicate (stack : Stack<'T>) =
64-
FSharp.Collections.Immutable.Stack.tryFindBack predicate stack
65-
|> ValueOption.toOption
52+
let tryFindBack predicate (stack : Stack<'T>) = Stack.tryFindBack predicate stack |> ValueOption.toOption
6653

6754
[<CompiledName "TryFindIndex">]
68-
let tryFindIndex predicate (stack : Stack<'T>) =
69-
FSharp.Collections.Immutable.Stack.tryFindIndex predicate stack
70-
|> ValueOption.toOption
55+
let tryFindIndex predicate (stack : Stack<'T>) = Stack.tryFindIndex predicate stack |> ValueOption.toOption
7156

7257
[<CompiledName "TryFindIndexBack">]
7358
let tryFindIndexBack predicate (stack : Stack<'T>) =
74-
FSharp.Collections.Immutable.Stack.tryFindIndexBack predicate stack
59+
Stack.tryFindIndexBack predicate stack
7560
|> ValueOption.toOption
7661

7762
[<CompiledName "TryPick">]
7863
let tryPick (chooser : 'T -> 'U option) (stack : Stack<'T>) =
79-
FSharp.Collections.Immutable.Stack.tryPick (fun item -> chooser item |> ValueOption.ofOption) stack
64+
Stack.tryPick (fun item -> chooser item |> ValueOption.ofOption) stack
8065
|> ValueOption.toOption
8166

8267
// ---- Transformation ----
8368

8469
[<CompiledName "Choose">]
85-
let choose (chooser : 'T -> 'U option) (stack : Stack<'T>) =
86-
FSharp.Collections.Immutable.Stack.choose (fun item -> chooser item |> ValueOption.ofOption) stack
70+
let choose (chooser : 'T -> 'U option) (stack : Stack<'T>) = Stack.choose (fun item -> chooser item |> ValueOption.ofOption) stack

‎src/FSharp.Collections.Immutable/Stack/StackTuple.fs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ let unfold (generator : 'State -> ('T * 'State) voption) (state : 'State) =
1616
| ValueSome (item, next) -> ValueSome (struct (item, next))
1717
| ValueNone -> ValueNone
1818

19-
FSharp.Collections.Immutable.Stack.unfold generateStruct state
19+
Stack.unfold generateStruct state
2020

2121
// ---- Access ----
2222

2323
[<CompiledName "TryPeekPop">]
2424
let tryUncons (stack : Stack<'T>) =
25-
match FSharp.Collections.Immutable.Stack.tryUncons stack with
25+
match Stack.tryUncons stack with
2626
| ValueSome (struct (head, tail)) -> ValueSome (head, tail)
2727
| ValueNone -> ValueNone
2828

2929
[<CompiledName "PeekPop">]
3030
let uncons (stack : Stack<'T>) =
31-
let struct (head, tail) = FSharp.Collections.Immutable.Stack.uncons stack
31+
let struct (head, tail) = Stack.uncons stack
3232
head, tail
3333

3434
[<return : Struct>]
@@ -91,7 +91,7 @@ let mapFold (mapping : 'State -> 'T -> 'Result * 'State) (state : 'State) (stack
9191
let result, next = mapping state item
9292
struct (result, next)
9393

94-
let struct (results, final) = FSharp.Collections.Immutable.Stack.mapFold mapStruct state stack
94+
let struct (results, final) = Stack.mapFold mapStruct state stack
9595
results, final
9696

9797
[<CompiledName "MapFoldBack">]
@@ -100,7 +100,7 @@ let mapFoldBack (mapping : 'T -> 'State -> 'Result * 'State) (stack : Stack<'T>)
100100
let result, next = mapping item state
101101
struct (result, next)
102102

103-
let struct (results, final) = FSharp.Collections.Immutable.Stack.mapFoldBack mapStruct stack state
103+
let struct (results, final) = Stack.mapFoldBack mapStruct stack state
104104
results, final
105105

106106
// ---- Partitioning and grouping ----
@@ -117,15 +117,15 @@ let groupBy (projection : 'T -> 'Key) (stack : Stack<'T>) =
117117

118118
[<CompiledName "Partition">]
119119
let partition predicate (stack : Stack<'T>) =
120-
let struct (accepted, rejected) = FSharp.Collections.Immutable.Stack.partition predicate stack
120+
let struct (accepted, rejected) = Stack.partition predicate stack
121121
accepted, rejected
122122

123123
[<CompiledName "PartitionWith">]
124124
let partitionWith (partitioner : 'T -> Choice<'T1, 'T2>) (stack : Stack<'T>) =
125-
let struct (first, second) = FSharp.Collections.Immutable.Stack.partitionWith partitioner stack
125+
let struct (first, second) = Stack.partitionWith partitioner stack
126126
first, second
127127

128128
[<CompiledName "SplitAt">]
129129
let splitAt index (stack : Stack<'T>) =
130-
let struct (before, after) = FSharp.Collections.Immutable.Stack.splitAt index stack
130+
let struct (before, after) = Stack.splitAt index stack
131131
before, after

0 commit comments

Comments
 (0)