Skip to content

Commit 929208c

Browse files
committed
Fantomas formatting
1 parent 732ab1f commit 929208c

Some content is hidden

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

86 files changed

+10799
-8999
lines changed

src/FsToolkit.ErrorHandling.JobResult/Job.fs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ open Hopac.Infixes
66
[<RequireQualifiedAccess>]
77
module Job =
88
let singleton = Job.result
9-
let apply' x f = Job.apply f x
10-
let map2 f x y =
11-
(apply' (apply' (singleton f) x) y)
9+
let apply' x f = Job.apply f x
10+
let map2 f x y = (apply' (apply' (singleton f) x) y)
1211

13-
let map3 f x y z =
14-
apply' (map2 f x y) z
12+
let map3 f x y z = apply' (map2 f x y) z
1513

16-
let zip j1 j2 = j1 <&> j2
14+
let zip j1 j2 = j1 <&> j2

src/FsToolkit.ErrorHandling.JobResult/JobOption.fs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ open Hopac
44
open Hopac.Infixes
55

66
[<RequireQualifiedAccess>]
7-
module JobOption =
8-
9-
let inline map f ar =
10-
Job.map (Option.map f) ar
11-
12-
let bind f (ar: Job<_>) = job {
13-
let! opt = ar
14-
let t =
15-
match opt with
16-
| Some x -> f x
17-
| None -> job { return None }
18-
return! t
19-
}
20-
21-
let retn x =
22-
job { return Some x }
7+
module JobOption =
8+
9+
let inline map f ar = Job.map (Option.map f) ar
10+
11+
let bind f (ar: Job<_>) =
12+
job {
13+
let! opt = ar
14+
15+
let t =
16+
match opt with
17+
| Some x -> f x
18+
| None -> job { return None }
19+
20+
return! t
21+
}
22+
23+
let retn x = job { return Some x }
2324

2425
let apply f x =
25-
bind (fun f' ->
26-
bind (fun x' -> retn (f' x')) x) f
26+
bind (fun f' -> bind (fun x' -> retn (f' x')) x) f

src/FsToolkit.ErrorHandling.JobResult/JobOptionCE.fs

Lines changed: 85 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,135 +5,107 @@ open System
55
open Hopac
66

77
[<AutoOpen>]
8-
module JobOptionCE =
9-
10-
type JobOptionBuilder() =
11-
12-
member __.Return (value: 'T) : Job<_ option> =
13-
job.Return <| option.Return value
14-
15-
member __.ReturnFrom
16-
(jobResult: Job<_ option>)
17-
: Job<_ option> =
18-
jobResult
19-
20-
member __.Zero () : Job<_ option> =
21-
job.Return <| option.Zero ()
22-
23-
member __.Bind
24-
(jobResult: Job<_ option>,
25-
binder: 'T -> Job<_ option>)
26-
: Job<_ option> =
27-
job {
28-
let! result = jobResult
29-
match result with
30-
| Some x -> return! binder x
31-
| None -> return None
32-
}
33-
34-
member this.Bind
35-
(taskResult: unit -> Task<_ option>,
36-
binder: 'T -> Job<_ option>)
37-
: Job<_ option> =
38-
this.Bind(Job.fromTask taskResult, binder)
39-
40-
member __.Delay
41-
(generator: unit -> Job<_ option>)
42-
: Job<_ option> =
43-
Job.delay generator
44-
45-
member this.Combine
46-
(computation1: Job<_ option>,
47-
computation2: Job<_ option>)
48-
: Job<_ option> =
49-
this.Bind(computation1, fun () -> computation2)
50-
51-
member __.TryWith
52-
(computation: Job<_ option>,
53-
handler: System.Exception -> Job<_ option>)
54-
: Job<_ option> =
55-
Job.tryWith computation handler
56-
57-
member __.TryWith
58-
(computation: unit -> Job<_ option>,
59-
handler: System.Exception -> Job<_ option>)
60-
: Job<_ option> =
61-
Job.tryWithDelay computation handler
62-
63-
member __.TryFinally
64-
(computation: Job<_ option>,
65-
compensation: unit -> unit)
66-
: Job<_ option> =
67-
Job.tryFinallyFun computation compensation
68-
69-
member __.TryFinally
70-
(computation: unit -> Job<_ option>,
71-
compensation: unit -> unit)
72-
: Job<_ option> =
73-
Job.tryFinallyFunDelay computation compensation
74-
75-
member __.Using
76-
(resource: 'T when 'T :> IDisposable,
77-
binder: 'T -> Job<_ option>)
78-
: Job<_ option> =
79-
job.Using(resource, binder)
80-
81-
member this.While
82-
(guard: unit -> bool, computation: Job<_ option>)
83-
: Job<_ option> =
84-
if not <| guard () then this.Zero ()
85-
else this.Bind(computation, fun () -> this.While (guard, computation))
86-
87-
member this.For
88-
(sequence: #seq<'T>, binder: 'T -> Job<_ option>)
89-
: Job<_ option> =
90-
this.Using(sequence.GetEnumerator (), fun enum ->
91-
this.While(enum.MoveNext,
92-
this.Delay(fun () -> binder enum.Current)))
8+
module JobOptionCE =
9+
10+
type JobOptionBuilder() =
11+
12+
member __.Return(value: 'T) : Job<_ option> = job.Return <| option.Return value
13+
14+
member __.ReturnFrom(jobResult: Job<_ option>) : Job<_ option> = jobResult
15+
16+
member __.Zero() : Job<_ option> = job.Return <| option.Zero()
17+
18+
member __.Bind(jobResult: Job<_ option>, binder: 'T -> Job<_ option>) : Job<_ option> =
19+
job {
20+
let! result = jobResult
21+
22+
match result with
23+
| Some x -> return! binder x
24+
| None -> return None
25+
}
26+
27+
member this.Bind(taskResult: unit -> Task<_ option>, binder: 'T -> Job<_ option>) : Job<_ option> =
28+
this.Bind(Job.fromTask taskResult, binder)
29+
30+
member __.Delay(generator: unit -> Job<_ option>) : Job<_ option> = Job.delay generator
31+
32+
member this.Combine(computation1: Job<_ option>, computation2: Job<_ option>) : Job<_ option> =
33+
this.Bind(computation1, (fun () -> computation2))
34+
35+
member __.TryWith(computation: Job<_ option>, handler: System.Exception -> Job<_ option>) : Job<_ option> =
36+
Job.tryWith computation handler
37+
38+
member __.TryWith
39+
(
40+
computation: unit -> Job<_ option>,
41+
handler: System.Exception -> Job<_ option>
42+
) : Job<_ option> =
43+
Job.tryWithDelay computation handler
44+
45+
member __.TryFinally(computation: Job<_ option>, compensation: unit -> unit) : Job<_ option> =
46+
Job.tryFinallyFun computation compensation
47+
48+
member __.TryFinally(computation: unit -> Job<_ option>, compensation: unit -> unit) : Job<_ option> =
49+
Job.tryFinallyFunDelay computation compensation
50+
51+
member __.Using(resource: 'T :> IDisposable, binder: 'T -> Job<_ option>) : Job<_ option> =
52+
job.Using(resource, binder)
53+
54+
member this.While(guard: unit -> bool, computation: Job<_ option>) : Job<_ option> =
55+
if not <| guard () then
56+
this.Zero()
57+
else
58+
this.Bind(computation, (fun () -> this.While(guard, computation)))
59+
60+
member this.For(sequence: #seq<'T>, binder: 'T -> Job<_ option>) : Job<_ option> =
61+
this.Using(
62+
sequence.GetEnumerator(),
63+
fun enum -> this.While(enum.MoveNext, this.Delay(fun () -> binder enum.Current))
64+
)
9365

9466
/// <summary>
9567
/// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type.
9668
///
9769
/// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder
9870
/// </summary>
99-
member inline _.Source(job : Job<_ option>) : Job<_ option> = job
71+
member inline _.Source(job: Job<_ option>) : Job<_ option> = job
10072

10173
/// <summary>
102-
/// Method lets us transform data types into our internal representation.
74+
/// Method lets us transform data types into our internal representation.
10375
/// </summary>
104-
member inline _.Source(async : Async<_ option>) : Job<_ option> = async |> Job.fromAsync
76+
member inline _.Source(async: Async<_ option>) : Job<_ option> = async |> Job.fromAsync
10577

10678
/// <summary>
107-
/// Method lets us transform data types into our internal representation.
79+
/// Method lets us transform data types into our internal representation.
10880
/// </summary>
109-
member inline _.Source(task : Task<_ option>) : Job<_ option> = task |> Job.awaitTask
81+
member inline _.Source(task: Task<_ option>) : Job<_ option> = task |> Job.awaitTask
11082

111-
let jobOption = JobOptionBuilder()
83+
let jobOption = JobOptionBuilder()
11284

11385
[<AutoOpen>]
11486
// Having members as extensions gives them lower priority in
11587
// overload resolution and allows skipping more type annotations.
11688
module JobOptionCEExtensions =
11789

118-
type JobOptionBuilder with
119-
/// <summary>
120-
/// Needed to allow `for..in` and `for..do` functionality
121-
/// </summary>
122-
member inline __.Source(s: #seq<_>) = s
123-
124-
/// <summary>
125-
/// Method lets us transform data types into our internal representation.
126-
/// </summary>
127-
member inline __.Source(r: 't option) = Job.singleton r
128-
/// <summary>
129-
/// Method lets us transform data types into our internal representation.
130-
/// </summary>
131-
member inline __.Source(a: Job<'t>) = a |> Job.map Some
132-
/// <summary>
133-
/// Method lets us transform data types into our internal representation.
134-
/// </summary>
135-
member inline __.Source(a: Async<'t>) = a |> Job.fromAsync |> Job.map Some
136-
/// <summary>
137-
/// Method lets us transform data types into our internal representation.
138-
/// </summary>
139-
member inline __.Source(a: Task<'t>) = a |> Job.awaitTask |> Job.map Some
90+
type JobOptionBuilder with
91+
/// <summary>
92+
/// Needed to allow `for..in` and `for..do` functionality
93+
/// </summary>
94+
member inline __.Source(s: #seq<_>) = s
95+
96+
/// <summary>
97+
/// Method lets us transform data types into our internal representation.
98+
/// </summary>
99+
member inline __.Source(r: 't option) = Job.singleton r
100+
/// <summary>
101+
/// Method lets us transform data types into our internal representation.
102+
/// </summary>
103+
member inline __.Source(a: Job<'t>) = a |> Job.map Some
104+
/// <summary>
105+
/// Method lets us transform data types into our internal representation.
106+
/// </summary>
107+
member inline __.Source(a: Async<'t>) = a |> Job.fromAsync |> Job.map Some
108+
/// <summary>
109+
/// Method lets us transform data types into our internal representation.
110+
/// </summary>
111+
member inline __.Source(a: Task<'t>) = a |> Job.awaitTask |> Job.map Some

src/FsToolkit.ErrorHandling.JobResult/JobOptionOp.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ namespace FsToolkit.ErrorHandling.Operator.JobOption
33
open FsToolkit.ErrorHandling
44

55
[<AutoOpen>]
6-
module JobOption =
6+
module JobOption =
77

8-
let inline (<!>) f x = JobOption.map f x
9-
let inline (<*>) f x = JobOption.apply f x
10-
let inline (>>=) x f = JobOption.bind f x
8+
let inline (<!>) f x = JobOption.map f x
9+
let inline (<*>) f x = JobOption.apply f x
10+
let inline (>>=) x f = JobOption.bind f x

0 commit comments

Comments
 (0)