@@ -11,25 +11,43 @@ module JobResult =
1111 let inline mapError ( [<InlineIfLambda>] f ) jr = Job.map ( Result.mapError f) jr
1212
1313 let inline bind ( [<InlineIfLambda>] f : 'a -> Job < Result < 'c , 'b >>) ( jr : Job < Result < 'a , 'b >>) =
14- Job.bind ( Result.either f ( Error >> Job.result)) jr
14+ Job.bind
15+ ( Result.either
16+ f
17+ ( Error
18+ >> Job.result))
19+ jr
1520
1621 let inline foldResult ( [<InlineIfLambda>] onSuccess ) ( [<InlineIfLambda>] onError ) jr =
1722 Job.map ( Result.fold onSuccess onError) jr
1823
1924 let inline ofAsync aAsync =
20- aAsync |> Job.fromAsync |> Job.catch |> Job.map Result.ofChoice
25+ aAsync
26+ |> Job.fromAsync
27+ |> Job.catch
28+ |> Job.map Result.ofChoice
2129
2230 let inline fromTask aTask =
23- aTask |> Job.fromTask |> Job.catch |> Job.map Result.ofChoice
31+ aTask
32+ |> Job.fromTask
33+ |> Job.catch
34+ |> Job.map Result.ofChoice
2435
2536 let inline fromUnitTask aTask =
26- aTask |> Job.fromUnitTask |> Job.catch |> Job.map Result.ofChoice
37+ aTask
38+ |> Job.fromUnitTask
39+ |> Job.catch
40+ |> Job.map Result.ofChoice
2741
28- let inline retn x = Ok x |> Job.result
42+ let inline retn x =
43+ Ok x
44+ |> Job.result
2945
3046 let inline ok x = retn x
3147
32- let inline returnError x = Error x |> Job.result
48+ let inline returnError x =
49+ Error x
50+ |> Job.result
3351
3452 let inline error x = returnError x
3553
@@ -59,7 +77,8 @@ module JobResult =
5977 /// The result if the result is Ok, else returns <paramref name="ifError"/>.
6078 /// </returns>
6179 let inline orElse ( ifError : Job < Result < 'ok , 'error2 >>) ( result : Job < Result < 'ok , 'error >>) =
62- result |> Job.bind ( Result.either ok ( fun _ -> ifError))
80+ result
81+ |> Job.bind ( Result.either ok ( fun _ -> ifError))
6382
6483 /// <summary>
6584 /// Returns <paramref name="result"/> if it is <c>Ok</c>, otherwise executes <paramref name="ifErrorFunc"/> and returns the result.
@@ -84,115 +103,146 @@ module JobResult =
84103 ( [<InlineIfLambda>] ifErrorFunc : 'error -> Job < Result < 'ok , 'error2 >>)
85104 ( result : Job < Result < 'ok , 'error >>)
86105 =
87- result |> Job.bind ( Result.either ok ifErrorFunc)
106+ result
107+ |> Job.bind ( Result.either ok ifErrorFunc)
88108
89109 /// Replaces the wrapped value with unit
90- let inline ignore < 'ok , 'error > ( jr : Job < Result < 'ok , 'error >>) = jr |> map ignore< 'ok>
110+ let inline ignore < 'ok , 'error > ( jr : Job < Result < 'ok , 'error >>) =
111+ jr
112+ |> map ignore< 'ok>
91113
92114 /// Returns the specified error if the job-wrapped value is false.
93115 let inline requireTrue error value =
94- value |> Job.map ( Result.requireTrue error)
116+ value
117+ |> Job.map ( Result.requireTrue error)
95118
96119 /// Returns the specified error if the job-wrapped value is true.
97120 let inline requireFalse error value =
98- value |> Job.map ( Result.requireFalse error)
121+ value
122+ |> Job.map ( Result.requireFalse error)
99123
100124 // Converts an job-wrapped Option to a Result, using the given error if None.
101125 let inline requireSome error option =
102- option |> Job.map ( Result.requireSome error)
126+ option
127+ |> Job.map ( Result.requireSome error)
103128
104129 // Converts an job-wrapped Option to a Result, using the given error if Some.
105130 let inline requireNone error option =
106- option |> Job.map ( Result.requireNone error)
131+ option
132+ |> Job.map ( Result.requireNone error)
107133
108134 /// Returns Ok if the job-wrapped value and the provided value are equal, or the specified error if not.
109135 let inline requireEqual x1 x2 error =
110- x2 |> Job.map ( fun x2' -> Result.requireEqual x1 x2' error)
136+ x2
137+ |> Job.map ( fun x2' -> Result.requireEqual x1 x2' error)
111138
112139 /// Returns Ok if the two values are equal, or the specified error if not.
113140 let inline requireEqualTo other error this =
114- this |> Job.map ( Result.requireEqualTo other error)
141+ this
142+ |> Job.map ( Result.requireEqualTo other error)
115143
116144 /// Returns Ok if the job-wrapped sequence is empty, or the specified error if not.
117145 let inline requireEmpty error xs =
118- xs |> Job.map ( Result.requireEmpty error)
146+ xs
147+ |> Job.map ( Result.requireEmpty error)
119148
120149 /// Returns Ok if the job-wrapped sequence is not-empty, or the specified error if not.
121150 let inline requireNotEmpty error xs =
122- xs |> Job.map ( Result.requireNotEmpty error)
151+ xs
152+ |> Job.map ( Result.requireNotEmpty error)
123153
124154 /// Returns the first item of the job-wrapped sequence if it exists, or the specified
125155 /// error if the sequence is empty
126156 let inline requireHead error xs =
127- xs |> Job.map ( Result.requireHead error)
157+ xs
158+ |> Job.map ( Result.requireHead error)
128159
129160 /// Replaces an error value of an job-wrapped result with a custom error
130161 /// value.
131162 let inline setError error jobResult =
132- jobResult |> Job.map ( Result.setError error)
163+ jobResult
164+ |> Job.map ( Result.setError error)
133165
134166 /// Replaces a unit error value of an job-wrapped result with a custom
135167 /// error value. Safer than setError since you're not losing any information.
136168 let inline withError error jobResult =
137- jobResult |> Job.map ( Result.withError error)
169+ jobResult
170+ |> Job.map ( Result.withError error)
138171
139172 /// Extracts the contained value of an job-wrapped result if Ok, otherwise
140173 /// uses ifError.
141174 let inline defaultValue ifError jobResult =
142- jobResult |> Job.map ( Result.defaultValue ifError)
175+ jobResult
176+ |> Job.map ( Result.defaultValue ifError)
143177
144178 /// Extracts the contained value of an job-wrapped result if Error, otherwise
145179 /// uses ifOk.
146180 let inline defaultError ifOk jobResult =
147- jobResult |> Job.map ( Result.defaultError ifOk)
181+ jobResult
182+ |> Job.map ( Result.defaultError ifOk)
148183
149184 /// Extracts the contained value of an job-wrapped result if Ok, otherwise
150185 /// evaluates ifErrorThunk and uses the result.
151186 let inline defaultWith ifErrorThunk jobResult =
152- jobResult |> Job.map ( Result.defaultWith ifErrorThunk)
187+ jobResult
188+ |> Job.map ( Result.defaultWith ifErrorThunk)
153189
154190 /// Same as defaultValue for a result where the Ok value is unit. The name
155191 /// describes better what is actually happening in this case.
156- let inline ignoreError < 'error > ( jobResult : Job < Result < unit , 'error >>) = defaultValue () jobResult
192+ let inline ignoreError < 'error > ( jobResult : Job < Result < unit , 'error >>) =
193+ defaultValue () jobResult
157194
158195 /// If the job-wrapped result is Ok, executes the function on the Ok value.
159196 /// Passes through the input value.
160- let inline tee ( [<InlineIfLambda>] f ) jobResult = jobResult |> Job.map ( Result.tee f)
197+ let inline tee ( [<InlineIfLambda>] f ) jobResult =
198+ jobResult
199+ |> Job.map ( Result.tee f)
161200
162201 /// If the job-wrapped result is Ok and the predicate returns true, executes
163202 /// the function on the Ok value. Passes through the input value.
164203 let inline teeIf ( [<InlineIfLambda>] predicate ) ( [<InlineIfLambda>] f ) jobResult =
165- jobResult |> Job.map ( Result.teeIf predicate f)
204+ jobResult
205+ |> Job.map ( Result.teeIf predicate f)
166206
167207 /// If the job-wrapped result is Error, executes the function on the Error
168208 /// value. Passes through the input value.
169209 let inline teeError ( [<InlineIfLambda>] f ) jobResult =
170- jobResult |> Job.map ( Result.teeError f)
210+ jobResult
211+ |> Job.map ( Result.teeError f)
171212
172213 /// If the job-wrapped result is Error and the predicate returns true,
173214 /// executes the function on the Error value. Passes through the input value.
174215 let inline teeErrorIf ( [<InlineIfLambda>] predicate ) ( [<InlineIfLambda>] f ) jobResult =
175- jobResult |> Job.map ( Result.teeErrorIf predicate f)
216+ jobResult
217+ |> Job.map ( Result.teeErrorIf predicate f)
176218
177219 /// Takes two results and returns a tuple of the pair
178220 let inline zip j1 j2 =
179- Job.zip j1 j2 |> Job.map ( fun ( r1 , r2 ) -> Result.zip r1 r2)
221+ Job.zip j1 j2
222+ |> Job.map ( fun ( r1 , r2 ) -> Result.zip r1 r2)
180223
181224 /// Takes two results and returns a tuple of the error pair
182225 let inline zipError j1 j2 =
183- Job.zip j1 j2 |> Job.map ( fun ( r1 , r2 ) -> Result.zipError r1 r2)
226+ Job.zip j1 j2
227+ |> Job.map ( fun ( r1 , r2 ) -> Result.zipError r1 r2)
184228
185229 /// Catches exceptions and maps them to the Error case using the provided function.
186230 let inline catch f x =
187231 x
188232 |> Job.catch
189- |> Job.map ( function
233+ |> Job.map (
234+ function
190235 | Choice1Of2 ( Ok v) -> Ok v
191236 | Choice1Of2 ( Error err) -> Error err
192- | Choice2Of2 ex -> Error( f ex))
237+ | Choice2Of2 ex -> Error( f ex)
238+ )
193239
194240 /// Lift Job to JobResult
195- let inline ofJob x = x |> Job.map Ok
241+ let inline ofJob x =
242+ x
243+ |> Job.map Ok
196244
197245 /// Lift Result to JobResult
198- let inline ofResult ( x : Result < _ , _ >) = x |> Job.singleton
246+ let inline ofResult ( x : Result < _ , _ >) =
247+ x
248+ |> Job.singleton
0 commit comments