-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.fs
More file actions
98 lines (77 loc) · 3.05 KB
/
example.fs
File metadata and controls
98 lines (77 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//[*] example 1 ////////////////////////////////////////
let test arg1 =
let added = 1 + arg1
let multi = added * 10
multi / 2
//[*] example 2 ////////////////////////////////////////
let inlineTest arg1 =
let inlineMe = 1 + arg1
inlineMe * 2 / (3 - inlineMe)
//[*] example 3 ////////////////////////////////////////
let anotherInlineTest arg1 =
let inlineMe = 1 + arg1
let dontInline = 12345
inlineMe * 2 / (3 - inlineMe) + dontInline
//some use case examples from https://github.com/ionide/ionide-vscode-fsharp/issues/172
//[*] example 4 ////////////////////////////////////////
let extractLet chars =
let noSpaces = chars |> Array.filter ((<>) ' ')
noSpaces
//[*] example 5 ////////////////////////////////////////
let extractLambda o =
let res = (o |> Array.fold (fun acc n -> (n |> Array.toList) @ acc ) []).Head
res
//should refactor to:
// let collectSignatures acc n =
// (n |> Array.toList) @ acc
// let res = (o |> Array.fold collectSignatures []).Head
//[x] example 6 ////////////////////////////////////////
let stringToExtract = "/usr/bin/bash"
//should refactor to:
// let prefix = "/usr/bin/"
// let stringToExtract = prefix + "bash"
//[] example 7 ////////////////////////////////////////
let bashPath = "/usr/bin/bash"
let zshPath = "/usr/bin/zsh"
//should refactor to:
// let prefix = "/usr/bin/"
// let bashPath = prefix + "bash"
// let zshPath = prefix + "zsh"
//[x] example 8 ////////////////////////////////////////
let inlineTestSimilarName arg1 =
let inlineMe = 1 + arg1
let inlineMeWithSimilarName = inlineMe * 2 / (3 - inlineMe)
inlineMeWithSimilarName
//[x] example 9 ////////////////////////////////////////
let inlineTestSimilarName2 arg1 =
let inlineMe = 1 + arg1
let inlineMeWithSimilarName = inlineMe * 2 / (3 - inlineMe)
inlineMeWithSimilarName
//[x] issue #1 ////////////////////////////////////////
//Extracting a snippet with a string closing string lteral symbol at the end mangles the refactored let expression
let commaJoin = Array.map string >> String.concat ", "
//should refactor to:
// let extracted = Array.map id >> String.concat ", "
// let str = extracted
//[x] issue #4 ////////////////////////////////////////
// I cannot inline the expectedEvents let-binding, but if I remove the empty line between the definition and its usage, I can inline it.
test "Y" {
let expectedEvents = []
equal [] expectedEvents ""
}
//[x] example #10 ////////////////////////////////////////
// Inlining a let binding on an outer scope with empty lines between
let expectedEvents = []
let inlineScope initialEvents =
initialEvents = expectedEvents
//[x] issue #5 ////////////////////////////////////////
// inline with type annotations
let expectedEvents :int list = []
let checkCurrent evts =
evts = expectedEvents
//[x] issue #6 ////////////////////////////////////////
// extracting let binding when selection contains a lambda and other expressions
let getter() = [1;2]
let extractLambda =
let res = getter() |> List.map (fun a -> a * 2) |> List.sum
res