Skip to content

Commit 3f298e0

Browse files
committed
formatting
1 parent 7dbc029 commit 3f298e0

File tree

3 files changed

+86
-62
lines changed

3 files changed

+86
-62
lines changed

src/IcedTasks/CancellableTask.fs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -584,21 +584,21 @@ module MediumPriority =
584584
[<InlineIfLambda>] computation: ColdTask<'TResult1>,
585585
[<InlineIfLambda>] continuation: ('TResult1 -> CancellableTaskCode<'TOverall, 'TResult2>)
586586
) : CancellableTaskCode<'TOverall, 'TResult2> =
587-
this.Bind((fun (_ : CancellationToken) -> computation () ), continuation)
587+
this.Bind((fun (_: CancellationToken) -> computation ()), continuation)
588588

589589
member inline this.ReturnFrom([<InlineIfLambda>] computation: ColdTask<'T>) : CancellableTaskCode<'T, 'T> =
590-
this.ReturnFrom(fun (_ : CancellationToken) -> computation ())
590+
this.ReturnFrom(fun (_: CancellationToken) -> computation ())
591591

592592
member inline this.Bind
593593
(
594594
[<InlineIfLambda>] computation: ColdTask,
595595
[<InlineIfLambda>] continuation: (unit -> CancellableTaskCode<_, _>)
596596
) : CancellableTaskCode<_, _> =
597-
let foo = fun (_ : CancellationToken) -> computation ()
598-
this.Bind(foo, continuation)
597+
let foo = fun (_: CancellationToken) -> computation ()
598+
this.Bind(foo, continuation)
599599

600600
member inline this.ReturnFrom([<InlineIfLambda>] computation: ColdTask) : CancellableTaskCode<_, _> =
601-
this.ReturnFrom(fun (_ : CancellationToken) -> computation ())
601+
this.ReturnFrom(fun (_: CancellationToken) -> computation ())
602602

603603
member inline this.Bind
604604
(
@@ -609,15 +609,16 @@ module MediumPriority =
609609

610610
member inline this.ReturnFrom(computation: Async<'T>) : CancellableTaskCode<'T, 'T> =
611611
this.ReturnFrom(fun ct -> Async.StartAsTask(computation, cancellationToken = ct))
612+
612613
member inline this.Bind
613614
(
614615
computation: Task<'TResult1>,
615616
[<InlineIfLambda>] continuation: ('TResult1 -> CancellableTaskCode<'TOverall, 'TResult2>)
616617
) : CancellableTaskCode<'TOverall, 'TResult2> =
617-
this.Bind((fun (_ : CancellationToken) -> computation ), continuation)
618+
this.Bind((fun (_: CancellationToken) -> computation), continuation)
618619

619620
member inline this.ReturnFrom(computation: Task<'T>) : CancellableTaskCode<'T, 'T> =
620-
this.ReturnFrom(fun (_ : CancellationToken) -> computation)
621+
this.ReturnFrom(fun (_: CancellationToken) -> computation)
621622

622623

623624

@@ -639,12 +640,23 @@ module AsyncExtenions =
639640
}
640641

641642
type Microsoft.FSharp.Control.AsyncBuilder with
642-
member inline this.Bind([<InlineIfLambda>]t: CancellableTask<'T>, [<InlineIfLambda>] binder: ('T -> Async<'U>)) : Async<'U> =
643+
member inline this.Bind
644+
(
645+
[<InlineIfLambda>] t: CancellableTask<'T>,
646+
[<InlineIfLambda>] binder: ('T -> Async<'U>)
647+
) : Async<'U> =
643648
this.Bind(Async.AwaitCancellableTask t, binder)
649+
644650
member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask<'T>) : Async<'T> =
645651
this.ReturnFrom(Async.AwaitCancellableTask t)
646-
member inline this.Bind([<InlineIfLambda>] t: CancellableTask, [<InlineIfLambda>] binder: (unit -> Async<'U>)) : Async<'U> =
652+
653+
member inline this.Bind
654+
(
655+
[<InlineIfLambda>] t: CancellableTask,
656+
[<InlineIfLambda>] binder: (unit -> Async<'U>)
657+
) : Async<'U> =
647658
this.Bind(Async.AwaitCancellableTask t, binder)
659+
648660
member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask) : Async<unit> =
649661
this.ReturnFrom(Async.AwaitCancellableTask t)
650662

src/IcedTasks/ColdTask.fs

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ and ColdTaskCode<'TOverall, 'T> = ResumableCode<ColdTaskStateMachineData<'TOvera
4040

4141
type ColdTaskBuilderBase() =
4242

43-
member inline _.Delay([<InlineIfLambda>] generator: unit -> ColdTaskCode<'TOverall, 'T>) : ColdTaskCode<'TOverall, 'T> =
43+
member inline _.Delay
44+
([<InlineIfLambda>] generator: unit -> ColdTaskCode<'TOverall, 'T>)
45+
: ColdTaskCode<'TOverall, 'T> =
4446
ColdTaskCode<'TOverall, 'T>(fun sm -> (generator ()).Invoke(&sm))
4547

4648
/// Used to represent no-ops like the implicit empty "else" branch of an "if" expression.
@@ -57,8 +59,8 @@ type ColdTaskBuilderBase() =
5759
/// This prevents constructs like `task { return 1; return 2; }`.
5860
member inline _.Combine
5961
(
60-
[<InlineIfLambda>]task1: ColdTaskCode<'TOverall, unit>,
61-
[<InlineIfLambda>]task2: ColdTaskCode<'TOverall, 'T>
62+
[<InlineIfLambda>] task1: ColdTaskCode<'TOverall, unit>,
63+
[<InlineIfLambda>] task2: ColdTaskCode<'TOverall, 'T>
6264
) : ColdTaskCode<'TOverall, 'T> =
6365
ResumableCode.Combine(task1, task2)
6466

@@ -477,7 +479,8 @@ module HighPriority =
477479
member inline this.ReturnFrom(task: Task<'T>) : ColdTaskCode<'T, 'T> =
478480
this.Bind(task, (fun v -> this.Return v))
479481

480-
member inline this.ReturnFrom([<InlineIfLambda>] task: ColdTask<'T>) : ColdTaskCode<'T, 'T> = this.ReturnFrom(task ())
482+
member inline this.ReturnFrom([<InlineIfLambda>] task: ColdTask<'T>) : ColdTaskCode<'T, 'T> =
483+
this.ReturnFrom(task ())
481484

482485
[<AutoOpen>]
483486
module MediumPriority =
@@ -506,35 +509,47 @@ module AsyncExtenions =
506509

507510
type Microsoft.FSharp.Control.AsyncBuilder with
508511

509-
member inline this.Bind([<InlineIfLambda>]coldTask: ColdTask<'T>, [<InlineIfLambda>]binder: ('T -> Async<'U>)) : Async<'U> =
512+
member inline this.Bind
513+
(
514+
[<InlineIfLambda>] coldTask: ColdTask<'T>,
515+
[<InlineIfLambda>] binder: ('T -> Async<'U>)
516+
) : Async<'U> =
510517
this.Bind(Async.AwaitColdTask coldTask, binder)
511-
member inline this.ReturnFrom([<InlineIfLambda>]coldTask: ColdTask<'T>) : Async<'T> =
518+
519+
member inline this.ReturnFrom([<InlineIfLambda>] coldTask: ColdTask<'T>) : Async<'T> =
512520
this.ReturnFrom(Async.AwaitColdTask coldTask)
513-
member inline this.Bind([<InlineIfLambda>]coldTask: ColdTask,[<InlineIfLambda>] binder: (unit -> Async<'U>)) : Async<'U> =
521+
522+
member inline this.Bind
523+
(
524+
[<InlineIfLambda>] coldTask: ColdTask,
525+
[<InlineIfLambda>] binder: (unit -> Async<'U>)
526+
) : Async<'U> =
514527
this.Bind(Async.AwaitColdTask coldTask, binder)
515-
member inline this.ReturnFrom([<InlineIfLambda>]coldTask: ColdTask) : Async<unit> =
528+
529+
member inline this.ReturnFrom([<InlineIfLambda>] coldTask: ColdTask) : Async<unit> =
516530
this.ReturnFrom(Async.AwaitColdTask coldTask)
517531

518532

519533
type Microsoft.FSharp.Control.TaskBuilderBase with
520-
member inline this.Bind([<InlineIfLambda>]coldTask: ColdTask<'T>, [<InlineIfLambda>]binder: ('T -> _)) =
534+
member inline this.Bind([<InlineIfLambda>] coldTask: ColdTask<'T>, [<InlineIfLambda>] binder: ('T -> _)) =
521535
this.Bind(coldTask (), binder)
522-
member inline this.ReturnFrom([<InlineIfLambda>]coldTask: ColdTask<'T>) =
523-
this.ReturnFrom(coldTask ())
524-
member inline this.Bind([<InlineIfLambda>]coldTask: ColdTask, [<InlineIfLambda>]binder: (_ -> _)) =
536+
537+
member inline this.ReturnFrom([<InlineIfLambda>] coldTask: ColdTask<'T>) = this.ReturnFrom(coldTask ())
538+
539+
member inline this.Bind([<InlineIfLambda>] coldTask: ColdTask, [<InlineIfLambda>] binder: (_ -> _)) =
525540
this.Bind(coldTask (), binder)
526-
member inline this.ReturnFrom([<InlineIfLambda>]coldTask: ColdTask) =
527-
this.ReturnFrom(coldTask ())
528-
// this.Bind((coldTask ()), binder)
529-
// member inline this.ReturnFrom(coldTask: ColdTask<'T>) : Async<'T> =
530-
// this.ReturnFrom(Async.AwaitColdTask coldTask)
531-
// member inline this.Bind(coldTask: ColdTask, binder: (unit -> Async<'U>)) : Async<'U> =
532-
// this.Bind(Async.AwaitColdTask coldTask, binder)
533-
// member inline this.ReturnFrom(coldTask: ColdTask) : Async<unit> =
534-
// this.ReturnFrom(Async.AwaitColdTask coldTask)
535-
// member inline _.Source(s: #seq<'value>) : #seq<'value> = s
536-
// member inline _.Source(computation: Task) : Task= computation
537-
// member inline _.Source(computation: Task<'T>) : Task<'T> = computation
538-
539-
// member inline _.Source([<InlineIfLambda>] coldTask: ColdTask<'T>) : Task<'T> = coldTask ()
540-
// member inline _.Source([<InlineIfLambda>] coldTask: ColdTask) : Task = coldTask ()
541+
542+
member inline this.ReturnFrom([<InlineIfLambda>] coldTask: ColdTask) = this.ReturnFrom(coldTask ())
543+
// this.Bind((coldTask ()), binder)
544+
// member inline this.ReturnFrom(coldTask: ColdTask<'T>) : Async<'T> =
545+
// this.ReturnFrom(Async.AwaitColdTask coldTask)
546+
// member inline this.Bind(coldTask: ColdTask, binder: (unit -> Async<'U>)) : Async<'U> =
547+
// this.Bind(Async.AwaitColdTask coldTask, binder)
548+
// member inline this.ReturnFrom(coldTask: ColdTask) : Async<unit> =
549+
// this.ReturnFrom(Async.AwaitColdTask coldTask)
550+
// member inline _.Source(s: #seq<'value>) : #seq<'value> = s
551+
// member inline _.Source(computation: Task) : Task= computation
552+
// member inline _.Source(computation: Task<'T>) : Task<'T> = computation
553+
554+
// member inline _.Source([<InlineIfLambda>] coldTask: ColdTask<'T>) : Task<'T> = coldTask ()
555+
// member inline _.Source([<InlineIfLambda>] coldTask: ColdTask) : Task = coldTask ()

tests/IcedTasks.Tests/Tests.fs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -282,32 +282,29 @@ module SayTests =
282282
do! foo |> Async.AwaitTask
283283
// Compiling is a sufficient Expect
284284
}
285-
testCaseAsync "Multi start task" <| async {
286-
let values = ResizeArray<_>()
287-
let someTask = task {
288-
values.Add("foo")
289-
}
290-
do! someTask |> Async.AwaitTask
291-
do! someTask |> Async.AwaitTask
292-
Expect.hasLength values 1 ""
293-
}
294-
testCaseAsync "Multi start async" <| async {
295-
let values = ResizeArray<_>()
296-
let someTask = async {
297-
values.Add("foo")
298-
}
299-
do! someTask
300-
do! someTask
301-
Expect.hasLength values 2 ""
302-
}
303-
testCaseAsync "Multi start coldTask" <| async {
304-
let values = ResizeArray<_>()
305-
let someTask = coldTask {
306-
values.Add("foo")
307-
}
308-
do! someTask |> Async.AwaitColdTask
309-
do! someTask |> Async.AwaitColdTask
310-
Expect.hasLength values 2 ""
285+
testCaseAsync "Multi start task"
286+
<| async {
287+
let values = ResizeArray<_>()
288+
let someTask = task { values.Add("foo") }
289+
do! someTask |> Async.AwaitTask
290+
do! someTask |> Async.AwaitTask
291+
Expect.hasLength values 1 ""
292+
}
293+
testCaseAsync "Multi start async"
294+
<| async {
295+
let values = ResizeArray<_>()
296+
let someTask = async { values.Add("foo") }
297+
do! someTask
298+
do! someTask
299+
Expect.hasLength values 2 ""
300+
}
301+
testCaseAsync "Multi start coldTask"
302+
<| async {
303+
let values = ResizeArray<_>()
304+
let someTask = coldTask { values.Add("foo") }
305+
do! someTask |> Async.AwaitColdTask
306+
do! someTask |> Async.AwaitColdTask
307+
Expect.hasLength values 2 ""
311308
}
312309

313310
]

0 commit comments

Comments
 (0)