Skip to content

Commit e83d194

Browse files
author
Onur Gumus
committed
style: run fantomas on foldWhile refactor
1 parent bbf9125 commit e83d194

3 files changed

Lines changed: 12 additions & 24 deletions

File tree

src/FSharp.Control.TaskSeq.Test/TaskSeq.FoldWhile.Tests.fs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ module EmptySeq =
2121
<| fun () -> TaskSeq.foldWhile (fun _ _ -> true) (fun _ item -> item + 1) 0 null
2222

2323
assertNullArg
24-
<| fun () ->
25-
TaskSeq.foldWhileAsync
26-
(fun _ _ -> Task.fromResult true)
27-
(fun _ item -> Task.fromResult (item + 1))
28-
0
29-
null
24+
<| fun () -> TaskSeq.foldWhileAsync (fun _ _ -> Task.fromResult true) (fun _ item -> Task.fromResult (item + 1)) 0 null
3025

3126
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
3227
let ``TaskSeq-foldWhile returns initial state when empty`` variant = task {
@@ -41,10 +36,7 @@ module EmptySeq =
4136
let ``TaskSeq-foldWhileAsync returns initial state when empty`` variant = task {
4237
let! result =
4338
Gen.getEmptyVariant variant
44-
|> TaskSeq.foldWhileAsync
45-
(fun _ _ -> Task.fromResult true)
46-
(fun _ item -> Task.fromResult (item + 1))
47-
-1
39+
|> TaskSeq.foldWhileAsync (fun _ _ -> Task.fromResult true) (fun _ item -> Task.fromResult (item + 1)) -1
4840

4941
result |> should equal -1
5042
}
@@ -105,10 +97,7 @@ module Functionality =
10597
let ``TaskSeq-foldWhileAsync with always-true predicate behaves like foldAsync`` () = task {
10698
let! result =
10799
TaskSeq.ofList [ 1; 2; 3; 4; 5 ]
108-
|> TaskSeq.foldWhileAsync
109-
(fun _ _ -> Task.fromResult true)
110-
(fun acc item -> Task.fromResult (acc + item))
111-
0
100+
|> TaskSeq.foldWhileAsync (fun _ _ -> Task.fromResult true) (fun acc item -> Task.fromResult (acc + item)) 0
112101

113102
result |> should equal 15
114103
}
@@ -126,10 +115,7 @@ module Functionality =
126115
let ``TaskSeq-foldWhileAsync is left-associative like foldAsync`` () = task {
127116
let! result =
128117
TaskSeq.ofList [ "b"; "c"; "d" ]
129-
|> TaskSeq.foldWhileAsync
130-
(fun _ _ -> Task.fromResult true)
131-
(fun acc item -> Task.fromResult (acc + item))
132-
"a"
118+
|> TaskSeq.foldWhileAsync (fun _ _ -> Task.fromResult true) (fun acc item -> Task.fromResult (acc + item)) "a"
133119

134120
result |> should equal "abcd"
135121
}
@@ -257,10 +243,7 @@ module Halt =
257243

258244
let! _ =
259245
source
260-
|> TaskSeq.foldWhileAsync
261-
(fun _ item -> Task.fromResult (item < 3))
262-
(fun acc item -> Task.fromResult (acc + item))
263-
0
246+
|> TaskSeq.foldWhileAsync (fun _ item -> Task.fromResult (item < 3)) (fun acc item -> Task.fromResult (acc + item)) 0
264247

265248
pulled |> should equal 3
266249
}

src/FSharp.Control.TaskSeq/TaskSeq.fsi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,9 @@ type TaskSeq =
18831883
static member foldWhile:
18841884
predicate: ('State -> 'T -> bool) ->
18851885
folder: ('State -> 'T -> 'State) ->
1886-
state: 'State -> source: TaskSeq<'T> -> Task<'State>
1886+
state: 'State ->
1887+
source: TaskSeq<'T> ->
1888+
Task<'State>
18871889

18881890
/// <summary>
18891891
/// Applies the asynchronous function <paramref name="folder" /> to each element in the task sequence,
@@ -1904,7 +1906,9 @@ type TaskSeq =
19041906
static member foldWhileAsync:
19051907
predicate: ('State -> 'T -> #Task<bool>) ->
19061908
folder: ('State -> 'T -> #Task<'State>) ->
1907-
state: 'State -> source: TaskSeq<'T> -> Task<'State>
1909+
state: 'State ->
1910+
source: TaskSeq<'T> ->
1911+
Task<'State>
19081912

19091913
/// <summary>
19101914
/// Like <see cref="TaskSeq.fold" />, but returns the sequence of intermediate results and the final result.

src/FSharp.Control.TaskSeq/TaskSeqInternal.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ module internal TaskSeqInternal =
444444

445445
if hasNext then
446446
let! keepGoing = predicate result e.Current
447+
447448
if keepGoing then
448449
let! newState = folder result e.Current
449450
result <- newState

0 commit comments

Comments
 (0)