Skip to content

Commit 776cca3

Browse files
[v5] Fantomas Updates (#288)
* Updated fantomas * Update fantomasignore * Ran fantomas * Updated checkFormatCode build target --------- Co-authored-by: Jimmy Byrd <[email protected]>
1 parent 256efdb commit 776cca3

25 files changed

+812
-799
lines changed

.config/dotnet-tools.json

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
{
2-
"version": 1,
3-
"isRoot": true,
4-
"tools": {
5-
"paket": {
6-
"version": "8.0.3",
7-
"commands": [
8-
"paket"
9-
]
10-
},
11-
"fable": {
12-
"version": "4.4.0",
13-
"commands": [
14-
"fable"
15-
]
16-
},
17-
"fantomas": {
18-
"version": "6.0.0-alpha-010",
19-
"commands": [
20-
"fantomas"
21-
]
22-
},
23-
"femto": {
24-
"version": "0.19.0",
25-
"commands": [
26-
"femto"
27-
]
28-
}
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"paket": {
6+
"version": "8.0.3",
7+
"commands": [
8+
"paket"
9+
],
10+
"rollForward": false
11+
},
12+
"fable": {
13+
"version": "4.4.0",
14+
"commands": [
15+
"fable"
16+
],
17+
"rollForward": false
18+
},
19+
"fantomas": {
20+
"version": "6.3.16",
21+
"commands": [
22+
"fantomas"
23+
],
24+
"rollForward": false
25+
},
26+
"femto": {
27+
"version": "0.19.0",
28+
"commands": [
29+
"femto"
30+
],
31+
"rollForward": false
2932
}
33+
}
3034
}

.fantomasignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
AssemblyInfo.fs
2+
tests/FsToolkit.ErrorHandling.AsyncSeq.Tests/Main.fs
3+
tests/FsToolkit.ErrorHandling.Tests/Main.fs

benchmarks/Benchmarks.fs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,8 @@ type ResultBuilder() =
304304
member this.Zero() : Result<unit, 'TError> = this.Return()
305305

306306
member _.Bind
307-
(
308-
result: Result<'T, 'TError>,
309-
binder: 'T -> Result<'U, 'TError>
310-
) : Result<'U, 'TError> =
307+
(result: Result<'T, 'TError>, binder: 'T -> Result<'U, 'TError>)
308+
: Result<'U, 'TError> =
311309
Result.bind binder result
312310

313311

@@ -319,10 +317,8 @@ type ResultBuilderInlined() =
319317
member inline this.Zero() : Result<unit, 'TError> = this.Return()
320318

321319
member inline _.Bind
322-
(
323-
result: Result<'T, 'TError>,
324-
binder: 'T -> Result<'U, 'TError>
325-
) : Result<'U, 'TError> =
320+
(result: Result<'T, 'TError>, binder: 'T -> Result<'U, 'TError>)
321+
: Result<'U, 'TError> =
326322
Result.Inlined.bind binder result
327323

328324
type ResultBuilderInlinedLambda() =
@@ -331,10 +327,8 @@ type ResultBuilderInlinedLambda() =
331327
member inline this.Zero() : Result<unit, 'TError> = this.Return()
332328

333329
member inline _.Bind
334-
(
335-
result: Result<'T, 'TError>,
336-
[<InlineIfLambda>] binder: 'T -> Result<'U, 'TError>
337-
) : Result<'U, 'TError> =
330+
(result: Result<'T, 'TError>, [<InlineIfLambda>] binder: 'T -> Result<'U, 'TError>)
331+
: Result<'U, 'TError> =
338332
Result.Alt.InlinedLambda.bind binder result
339333

340334

build/build.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ let checkFormatCode _ =
152152
elif result.ExitCode = 99 then
153153
failwith "Some files need formatting, check output for more info"
154154
else
155-
Trace.logf "Errors while formatting: %A" result.Errors
155+
let msg = sprintf "Errors while formatting: %A" result.Errors
156+
Trace.log msg
157+
failwith msg
156158

157159

158160
let clean _ =

playground.fsx

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let inline id x = x
55
open FsToolkit.ErrorHandling
66

77
Result.ofChoice
8+
89
module Operators =
910

1011
let inline bindM builder m ([<InlineIfLambda>] f) =
@@ -167,7 +168,6 @@ module AsyncResult =
167168
}
168169

169170

170-
171171
module DisposableOptionThings =
172172
open System
173173
open System.Threading.Tasks
@@ -177,16 +177,23 @@ module DisposableOptionThings =
177177
[<CompilationRepresentation(CompilationRepresentationFlags.UseNullAsTrueValue)>]
178178
[<StructuralEquality; StructuralComparison>]
179179
type DisposableOption<'a when 'a :> IDisposable> =
180-
| None
181-
| Some of 'a
180+
| None
181+
| Some of 'a
182+
182183
interface IDisposable with
183184
member this.Dispose() =
184185
match this with
185186
| None -> ()
186187
| Some x -> x.Dispose()
187188

188-
static member inline OfObj<'a when 'a :> IDisposable> (x: 'a) =
189-
if box x |> isNull then None else Some x
189+
static member inline OfObj<'a when 'a :> IDisposable>(x: 'a) =
190+
if
191+
box x
192+
|> isNull
193+
then
194+
None
195+
else
196+
Some x
190197

191198
static member inline ToOption(x: DisposableOption<'a>) =
192199
match x with
@@ -198,30 +205,25 @@ module DisposableOptionThings =
198205
| None -> ValueOption.None
199206
| Some x -> ValueOption.Some x
200207

201-
static member inline OfOption (x: 'a Option) =
208+
static member inline OfOption(x: 'a Option) =
202209
match x with
203210
| Option.None -> None
204211
| Option.Some x -> Some x
205212

206-
static member inline OfValueOption (x: 'a ValueOption) =
213+
static member inline OfValueOption(x: 'a ValueOption) =
207214
match x with
208215
| ValueNone -> None
209216
| ValueSome x -> Some x
210217

211-
static member inline op_Implicit (x: 'a) =
212-
DisposableOption.OfObj x
218+
static member inline op_Implicit(x: 'a) = DisposableOption.OfObj x
213219

214-
static member inline op_Implicit (x: 'a DisposableOption) =
215-
DisposableOption.ToOption x
220+
static member inline op_Implicit(x: 'a DisposableOption) = DisposableOption.ToOption x
216221

217-
static member inline op_Implicit (x: 'a DisposableOption) =
218-
DisposableOption.ToValueOption x
222+
static member inline op_Implicit(x: 'a DisposableOption) = DisposableOption.ToValueOption x
219223

220-
static member inline op_Implicit (x: 'a Option) =
221-
DisposableOption.OfOption x
224+
static member inline op_Implicit(x: 'a Option) = DisposableOption.OfOption x
222225

223-
static member inline op_Imp licit (x: 'a ValueOption) =
224-
DisposableOption.OfValueOption x
226+
static member inline op_Imp licit (x: 'a ValueOption) = DisposableOption.OfValueOption x
225227

226228

227229
[<RequireQualifiedAccess>]
@@ -230,10 +232,12 @@ module DisposableOptionThings =
230232
match x with
231233
| DisposableOption.Some x -> f x
232234
| DisposableOption.None -> None
235+
233236
let inline map f x =
234237
match x with
235-
| DisposableOption.Some x -> Some (f x)
238+
| DisposableOption.Some x -> Some(f x)
236239
| DisposableOption.None -> None
240+
237241
let inline iter f x =
238242
match x with
239243
| DisposableOption.Some x -> f x
@@ -242,16 +246,23 @@ module DisposableOptionThings =
242246

243247
[<RequireQualifiedAccess>]
244248
type AsyncDisposableOption<'a when 'a :> IAsyncDisposable> =
245-
| Some of 'a
246-
| None
249+
| Some of 'a
250+
| None
251+
247252
interface IAsyncDisposable with
248253
member this.DisposeAsync() =
249254
match this with
250255
| Some x -> x.DisposeAsync()
251256
| None -> ValueTask()
252257

253-
static member inline ofObj (x: 'a) =
254-
if box x |> isNull then None else Some x
258+
static member inline ofObj(x: 'a) =
259+
if
260+
box x
261+
|> isNull
262+
then
263+
None
264+
else
265+
Some x
255266

256267
member inline x.toOption() =
257268
match x with
@@ -263,43 +274,47 @@ module DisposableOptionThings =
263274
| Some x -> ValueOption.Some x
264275
| None -> ValueOption.None
265276

266-
static member inline ofOption (x: 'a Option) =
277+
static member inline ofOption(x: 'a Option) =
267278
match x with
268279
| Option.Some x -> Some x
269280
| Option.None -> None
270281

271-
static member inline ofValueOption (x: 'a ValueOption) =
282+
static member inline ofValueOption(x: 'a ValueOption) =
272283
match x with
273284
| ValueOption.ValueSome x -> Some x
274285
| ValueOption.ValueNone -> None
275286

276-
static member inline op_Implicit (x: 'a) =
277-
AsyncDisposableOption.ofObj x
287+
static member inline op_Implicit(x: 'a) = AsyncDisposableOption.ofObj x
278288

279-
static member inline op_Implicit (x: 'a AsyncDisposableOption) =
280-
x.toOption()
289+
static member inline op_Implicit(x: 'a AsyncDisposableOption) = x.toOption ()
281290

282-
static member inline op_Implicit (x: 'a AsyncDisposableOption) =
283-
x.toValueOption()
291+
static member inline op_Implicit(x: 'a AsyncDisposableOption) = x.toValueOption ()
284292

285-
static member inline op_Implicit (x: 'a Option) =
286-
AsyncDisposableOption.ofOption x
293+
static member inline op_Implicit(x: 'a Option) = AsyncDisposableOption.ofOption x
287294

288-
static member inline op_Implicit (x: 'a ValueOption) =
289-
AsyncDisposableOption.ofValueOption x
295+
static member inline op_Implicit(x: 'a ValueOption) = AsyncDisposableOption.ofValueOption x
290296

291297
module Examples =
292298
open DisposableOptionThings
293299
open System.Diagnostics
294300

295-
let inline implicitConv (x: ^T) : ^U = ((^T or ^U) : (static member op_Implicit : ^T -> ^U) (x))
301+
let inline implicitConv (x: ^T) : ^U =
302+
((^T or ^U): (static member op_Implicit: ^T -> ^U) (x))
303+
296304
let inline (!>) x = implicitConv x
297-
let inline (|!>) x f = f (!> x)
305+
let inline (|!>) x f = f (!>x)
298306

299307
let activitySource = new ActivitySource("Playground.App")
300308

301309
let example () =
302-
use a = activitySource.StartActivity("lol") |> DisposableOption.OfObj
303-
a |!> Option.iter(fun a -> a.AddTag("hello", "world") |> ignore)
304-
()
310+
use a =
311+
activitySource.StartActivity("lol")
312+
|> DisposableOption.OfObj
305313

314+
a
315+
|!> Option.iter (fun a ->
316+
a.AddTag("hello", "world")
317+
|> ignore
318+
)
319+
320+
()

src/FsToolkit.ErrorHandling.AsyncSeq/Library.fs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,13 @@ module AsyncSeqCE =
4141

4242

4343
member this.For
44-
(
45-
xs: AsyncSeq<Result<'T, 'TError>>,
46-
binder: 'T -> Async<Result<unit, 'TError>>
47-
) : Async<Result<unit, 'TError>> =
44+
(xs: AsyncSeq<Result<'T, 'TError>>, binder: 'T -> Async<Result<unit, 'TError>>)
45+
: Async<Result<unit, 'TError>> =
4846
this.Using(xs.GetEnumerator(), (fun enum -> this.While(enum.MoveNext, binder)))
4947

5048
member this.For
51-
(
52-
xs: AsyncSeq<'T>,
53-
binder: 'T -> Async<Result<unit, 'TError>>
54-
) : Async<Result<unit, 'TError>> =
49+
(xs: AsyncSeq<'T>, binder: 'T -> Async<Result<unit, 'TError>>)
50+
: Async<Result<unit, 'TError>> =
5551
this.Using(
5652
xs.GetEnumerator(),
5753
fun enum ->

0 commit comments

Comments
 (0)