Skip to content

Commit b49d1e2

Browse files
committed
Formatting
1 parent 8a6c9c9 commit b49d1e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+463
-949
lines changed

src/FsToolkit.ErrorHandling.AsyncSeq/Library.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module AsyncSeqCE =
99
type private AsyncSeq<'t> = FSharp.Control.AsyncSeq<'t>
1010

1111
type AsyncResultBuilder with
12+
1213
member inline this.While
1314
(
1415
[<InlineIfLambda>] guard: unit -> Async<option<Result<'T, 'TError>>>,

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace FsToolkit.ErrorHandling
22

33

4-
54
[<AutoOpen>]
65
module CancellableTaskResultCE =
76

@@ -53,7 +52,6 @@ module CancellableTaskResultCE =
5352
ResumableCode<CancellableTaskResultStateMachineData<'TOverall, 'Error>, 'T>
5453

5554

56-
5755
module CancellableTaskResultBuilderBase =
5856

5957
let rec WhileDynamic
@@ -126,7 +124,6 @@ module CancellableTaskResultCE =
126124
true)
127125

128126

129-
130127
static member inline CombineDynamic
131128
(
132129
sm: byref<CancellableTaskResultStateMachine<_, _>>,
@@ -182,7 +179,6 @@ module CancellableTaskResultCE =
182179
CancellableTaskResultBuilderBase.CombineDynamic(&sm, task1, task2))
183180

184181

185-
186182
/// Builds a step that executes the body while the condition predicate is true.
187183
member inline _.While
188184
(
@@ -194,9 +190,7 @@ module CancellableTaskResultCE =
194190
//-- RESUMABLE CODE START
195191
let mutable __stack_go = true
196192

197-
while __stack_go
198-
&& not sm.Data.IsResultError
199-
&& condition () do
193+
while __stack_go && not sm.Data.IsResultError && condition () do
200194
// NOTE: The body of the state machine code for 'while' may contain await points, so resuming
201195
// the code will branch directly into the expanded 'body', branching directly into the while loop
202196
let __stack_body_fin = body.Invoke(&sm)
@@ -369,8 +363,8 @@ module CancellableTaskResultCE =
369363
assert not (isNull awaiter)
370364
sm.Data.MethodBuilder.AwaitUnsafeOnCompleted(&awaiter, &sm)
371365

372-
with
373-
| exn -> savedExn <- exn
366+
with exn ->
367+
savedExn <- exn
374368
// Run SetException outside the stack unwind, see https://github.com/dotnet/roslyn/issues/26567
375369
match savedExn with
376370
| null -> ()
@@ -405,8 +399,8 @@ module CancellableTaskResultCE =
405399

406400
if __stack_code_fin && not sm.Data.IsTaskCompleted then
407401
sm.Data.MethodBuilder.SetResult(sm.Data.Result)
408-
with
409-
| exn -> __stack_exn <- exn
402+
with exn ->
403+
__stack_exn <- exn
410404
// Run SetException outside the stack unwind, see https://github.com/dotnet/roslyn/issues/26567
411405
match __stack_exn with
412406
| null -> ()
@@ -462,8 +456,7 @@ module CancellableTaskResultCE =
462456

463457
if __stack_code_fin && not sm.Data.IsTaskCompleted then
464458
sm.Data.MethodBuilder.SetResult(sm.Data.Result)
465-
with
466-
| exn ->
459+
with exn ->
467460

468461
// printfn "%A" exn
469462
sm.Data.MethodBuilder.SetException exn
@@ -524,9 +517,11 @@ module CancellableTaskResultCE =
524517
type CancellableTaskResultBuilderBase with
525518

526519
[<NoEagerConstraintApplication>]
527-
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error when ^TaskLike: (member GetAwaiter:
528-
unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
529-
unit -> bool) and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
520+
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
521+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
522+
and ^Awaiter :> ICriticalNotifyCompletion
523+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
524+
and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
530525
(
531526
sm: byref<ResumableStateMachine<CancellableTaskResultStateMachineData<'TOverall, 'Error>>>,
532527
task: CancellationToken -> ^TaskLike,
@@ -557,9 +552,11 @@ module CancellableTaskResultCE =
557552
false
558553

559554
[<NoEagerConstraintApplication>]
560-
member inline _.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error when ^TaskLike: (member GetAwaiter:
561-
unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
562-
unit -> bool) and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
555+
member inline _.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
556+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
557+
and ^Awaiter :> ICriticalNotifyCompletion
558+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
559+
and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)>
563560
(
564561
task: CancellationToken -> ^TaskLike,
565562
continuation: ('TResult1 -> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>)
@@ -603,9 +600,11 @@ module CancellableTaskResultCE =
603600
)
604601

605602
[<NoEagerConstraintApplication>]
606-
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error when ^TaskLike: (member GetAwaiter:
607-
unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
608-
unit -> bool) and ^Awaiter: (member GetResult: unit -> 'TResult1)>
603+
static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
604+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
605+
and ^Awaiter :> ICriticalNotifyCompletion
606+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
607+
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
609608
(
610609
sm: byref<ResumableStateMachine<CancellableTaskResultStateMachineData<'TOverall, 'Error>>>,
611610
task: ^TaskLike,
@@ -630,9 +629,11 @@ module CancellableTaskResultCE =
630629
false
631630

632631
[<NoEagerConstraintApplication>]
633-
member inline this.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error when ^TaskLike: (member GetAwaiter:
634-
unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
635-
unit -> bool) and ^Awaiter: (member GetResult: unit -> 'TResult1)>
632+
member inline this.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error
633+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
634+
and ^Awaiter :> ICriticalNotifyCompletion
635+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
636+
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
636637
(
637638
task: ^TaskLike,
638639
continuation: ('TResult1 -> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>)
@@ -674,9 +675,11 @@ module CancellableTaskResultCE =
674675
)
675676

676677
[<NoEagerConstraintApplication>]
677-
member inline this.ReturnFrom< ^TaskLike, ^Awaiter, 'T, 'Error when ^TaskLike: (member GetAwaiter:
678-
unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
679-
unit -> bool) and ^Awaiter: (member GetResult: unit -> 'T)>
678+
member inline this.ReturnFrom< ^TaskLike, ^Awaiter, 'T, 'Error
679+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
680+
and ^Awaiter :> ICriticalNotifyCompletion
681+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
682+
and ^Awaiter: (member GetResult: unit -> 'T)>
680683
(task: ^TaskLike)
681684
: CancellableTaskResultCode<'T, 'Error, 'T> =
682685

@@ -690,11 +693,10 @@ module CancellableTaskResultCE =
690693
ResumableCode.Using(resource, body)
691694

692695

693-
694-
695696
[<AutoOpen>]
696697
module HighPriority =
697698
type Microsoft.FSharp.Control.Async with
699+
698700
static member inline AwaitCancellableTaskResult([<InlineIfLambda>] t: CancellableTaskResult<'T, 'Error>) = async {
699701
let! ct = Async.CancellationToken
700702
return! t ct |> Async.AwaitTask
@@ -704,13 +706,14 @@ module CancellableTaskResultCE =
704706
fun ct -> Async.StartAsTask(computation, cancellationToken = ct)
705707

706708

707-
708-
709709
type CancellableTaskResultBuilder with
710710

711711
[<NoEagerConstraintApplication>]
712-
member inline this.Source< ^TaskLike, ^Awaiter, 'T when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted:
713-
unit -> bool) and ^Awaiter: (member GetResult: unit -> 'T)>
712+
member inline this.Source< ^TaskLike, ^Awaiter, 'T
713+
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
714+
and ^Awaiter :> ICriticalNotifyCompletion
715+
and ^Awaiter: (member get_IsCompleted: unit -> bool)
716+
and ^Awaiter: (member GetResult: unit -> 'T)>
714717
(t: ^TaskLike)
715718
: CancellableTaskResult<_, _> =
716719
// : CancellableTaskResultCode<_,_,_> =
@@ -807,7 +810,6 @@ module CancellableTaskResultCE =
807810
this.Bind((task), (fun v -> this.Return v))
808811

809812

810-
811813
[<AutoOpen>]
812814
module MediumPriority =
813815
open HighPriority
@@ -853,6 +855,7 @@ module CancellableTaskResultCE =
853855

854856
// Medium priority extensions
855857
type CancellableTaskResultBuilderBase with
858+
856859
member inline this.Source(t: Async<'T>) : CancellableTaskResult<'T, 'Error> =
857860
fun ct ->
858861
let t = t |> Async.map Ok
@@ -862,6 +865,7 @@ module CancellableTaskResultCE =
862865
[<AutoOpen>]
863866
module AsyncExtenions =
864867
type Microsoft.FSharp.Control.AsyncBuilder with
868+
865869
member inline this.Bind
866870
(
867871
[<InlineIfLambda>] t: CancellableTaskResult<'T, 'Error>,
@@ -874,6 +878,7 @@ module CancellableTaskResultCE =
874878

875879

876880
type FsToolkit.ErrorHandling.AsyncResultCE.AsyncResultBuilder with
881+
877882
member inline this.Source([<InlineIfLambda>] t: CancellableTaskResult<'T, 'Error>) : Async<_> =
878883
Async.AwaitCancellableTaskResult t
879884

src/FsToolkit.ErrorHandling.JobResult/JobOptionCE.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module JobOptionCE =
107107
module JobOptionCEExtensions =
108108

109109
type JobOptionBuilder with
110+
110111
/// <summary>
111112
/// Needed to allow `for..in` and `for..do` functionality
112113
/// </summary>

src/FsToolkit.ErrorHandling.JobResult/JobResult.fs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,13 @@ module JobResult =
1717
Job.map (Result.fold onSuccess onError) jr
1818

1919
let inline ofAsync aAsync =
20-
aAsync
21-
|> Job.fromAsync
22-
|> Job.catch
23-
|> Job.map Result.ofChoice
20+
aAsync |> Job.fromAsync |> Job.catch |> Job.map Result.ofChoice
2421

2522
let inline fromTask aTask =
26-
aTask
27-
|> Job.fromTask
28-
|> Job.catch
29-
|> Job.map Result.ofChoice
23+
aTask |> Job.fromTask |> Job.catch |> Job.map Result.ofChoice
3024

3125
let inline fromUnitTask aTask =
32-
aTask
33-
|> Job.fromUnitTask
34-
|> Job.catch
35-
|> Job.map Result.ofChoice
26+
aTask |> Job.fromUnitTask |> Job.catch |> Job.map Result.ofChoice
3627

3728
let inline retn x = Ok x |> Job.result
3829

@@ -68,8 +59,7 @@ module JobResult =
6859
/// The result if the result is Ok, else returns <paramref name="ifError"/>.
6960
/// </returns>
7061
let inline orElse (ifError: Job<Result<'ok, 'error2>>) (result: Job<Result<'ok, 'error>>) =
71-
result
72-
|> Job.bind (Result.either ok (fun _ -> ifError))
62+
result |> Job.bind (Result.either ok (fun _ -> ifError))
7363

7464
/// <summary>
7565
/// Returns <paramref name="result"/> if it is <c>Ok</c>, otherwise executes <paramref name="ifErrorFunc"/> and returns the result.
@@ -117,13 +107,11 @@ module JobResult =
117107

118108
/// Returns Ok if the job-wrapped value and the provided value are equal, or the specified error if not.
119109
let inline requireEqual x1 x2 error =
120-
x2
121-
|> Job.map (fun x2' -> Result.requireEqual x1 x2' error)
110+
x2 |> Job.map (fun x2' -> Result.requireEqual x1 x2' error)
122111

123112
/// Returns Ok if the two values are equal, or the specified error if not.
124113
let inline requireEqualTo other error this =
125-
this
126-
|> Job.map (Result.requireEqualTo other error)
114+
this |> Job.map (Result.requireEqualTo other error)
127115

128116
/// Returns Ok if the job-wrapped sequence is empty, or the specified error if not.
129117
let inline requireEmpty error xs =
@@ -161,8 +149,7 @@ module JobResult =
161149
/// Extracts the contained value of an job-wrapped result if Ok, otherwise
162150
/// evaluates ifErrorThunk and uses the result.
163151
let inline defaultWith ifErrorThunk jobResult =
164-
jobResult
165-
|> Job.map (Result.defaultWith ifErrorThunk)
152+
jobResult |> Job.map (Result.defaultWith ifErrorThunk)
166153

167154
/// Same as defaultValue for a result where the Ok value is unit. The name
168155
/// describes better what is actually happening in this case.
@@ -185,18 +172,15 @@ module JobResult =
185172
/// If the job-wrapped result is Error and the predicate returns true,
186173
/// executes the function on the Error value. Passes through the input value.
187174
let inline teeErrorIf ([<InlineIfLambda>] predicate) ([<InlineIfLambda>] f) jobResult =
188-
jobResult
189-
|> Job.map (Result.teeErrorIf predicate f)
175+
jobResult |> Job.map (Result.teeErrorIf predicate f)
190176

191177
/// Takes two results and returns a tuple of the pair
192178
let inline zip j1 j2 =
193-
Job.zip j1 j2
194-
|> Job.map (fun (r1, r2) -> Result.zip r1 r2)
179+
Job.zip j1 j2 |> Job.map (fun (r1, r2) -> Result.zip r1 r2)
195180

196181
/// Takes two results and returns a tuple of the error pair
197182
let inline zipError j1 j2 =
198-
Job.zip j1 j2
199-
|> Job.map (fun (r1, r2) -> Result.zipError r1 r2)
183+
Job.zip j1 j2 |> Job.map (fun (r1, r2) -> Result.zipError r1 r2)
200184

201185
/// Catches exceptions and maps them to the Error case using the provided function.
202186
let inline catch f x =

src/FsToolkit.ErrorHandling.TaskResult/Task.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ module Task =
4949
try
5050
let! r = x
5151
return Choice1Of2 r
52-
with
53-
| e -> return Choice2Of2 e
52+
with e ->
53+
return Choice2Of2 e
5454
}

src/FsToolkit.ErrorHandling.TaskResult/TaskOption.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ module TaskOption =
2727
bind (fun f' -> bind (fun x' -> retn (f' x')) x) f
2828

2929
let inline zip x1 x2 =
30-
Task.zip x1 x2
31-
|> Task.map (fun (r1, r2) -> Option.zip r1 r2)
30+
Task.zip x1 x2 |> Task.map (fun (r1, r2) -> Option.zip r1 r2)

0 commit comments

Comments
 (0)