Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c6200cb
+ Failing test with expectations
gusty Dec 26, 2025
dd208ee
Fix
gusty Dec 26, 2025
6d311d0
Assert Taskbuilder tests
gusty Dec 27, 2025
140a26c
Retry test 3 times to avoid "sleep blocked caller" failure
gusty Dec 27, 2025
0d70701
Reduce allocations
gusty Dec 27, 2025
0926e4f
Stack increases, there's little we can do about it
gusty Dec 27, 2025
bf49501
Use a delayed run for TaskBuilderTests
gusty Dec 29, 2025
e658508
Avoid sync optimization
gusty Dec 29, 2025
4bf5d2f
Try fix vtask
gusty Dec 29, 2025
2e51811
Consider sync in Task.bind
gusty Dec 29, 2025
c645fbd
More changes
gusty Dec 29, 2025
eb91d17
Use task CE
gusty Dec 29, 2025
0acbee4
Increase sleep time in ValueTask tests
gusty Dec 29, 2025
08c02a3
Change type of TCS
gusty Dec 29, 2025
51a423e
Use backgroundTask
gusty Dec 29, 2025
d788f36
Small improvements in test code
gusty Dec 29, 2025
e550a85
Add warm-up for vtask tests
gusty Dec 29, 2025
0b37194
Use normal monad'
gusty Dec 30, 2025
316ae04
Experiment
gusty Dec 30, 2025
acd2df8
Experiment
gusty Dec 30, 2025
011d82a
Revert experiments
gusty Dec 30, 2025
e3ea691
Add compensation tests
gusty Dec 30, 2025
9400c63
Revert "Use normal monad'"
gusty Dec 30, 2025
9c0596d
Revert "Use a delayed run for TB Tests"
gusty Dec 30, 2025
e462543
Revert "Add warm-up for vtask tests"
gusty Dec 30, 2025
4307480
Revert "Increase sleep time in ValueTask tests"
gusty Dec 30, 2025
27a6820
Blocking tests adapted
gusty Dec 30, 2025
2b382bc
Revert "Change type of TCS"
gusty Dec 30, 2025
bff7135
Use FromExceptions, update raise and ignore
gusty Dec 31, 2025
756ef78
Apply completed checks immediately
gusty Dec 31, 2025
d0df4a7
Use TaskCreationOptions.RunContinuationsAsynchronously
gusty Dec 31, 2025
024b1da
Add sync check
gusty Jan 1, 2026
8f4c16d
Remove continueWith and harmonize code
gusty Jan 1, 2026
8b7799d
Remove sync path from continueTask
gusty Jan 1, 2026
b98d2f4
Add roundtrip test
gusty Jan 1, 2026
607ae8f
Fix extract operation
gusty Jan 1, 2026
76164c6
Add test with empty AggregateExn
gusty Jan 1, 2026
f3da3be
Fix handling of empty AggregateExn
gusty Jan 1, 2026
edd3596
Add test case for AggregateExn
gusty Jan 1, 2026
5c75dd3
Re-use task DU internally
gusty Jan 1, 2026
db2712a
Revert "Use TaskCreationOptions.RunContinuationsAsynchronously"
gusty Jan 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/FSharpPlus/Control/Comonad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Extract =
#if FABLE_COMPILER
Async.RunSynchronously x
#else
Async.AsTask(x).Result
Async.AsTask(x).GetAwaiter().GetResult ()
#endif
static member Extract (x: Lazy<'T> ) = x.Value
static member Extract ((_: 'W, a: 'T) ) = a
Expand All @@ -28,10 +28,8 @@ type Extract =
static member inline Extract (f: 'Monoid -> 'T) = f (LanguagePrimitives.GenericZero)
#endif
#if !FABLE_COMPILER
static member Extract (f: Task<'T> ) = f.Result
#endif
#if !FABLE_COMPILER
static member Extract (f: ValueTask<'T> ) = f.Result
static member Extract (f: Task<'T> ) = f.GetAwaiter().GetResult ()
static member Extract (f: ValueTask<'T>) = f.GetAwaiter().GetResult ()
#endif
static member inline Invoke (x: '``Comonad<'T>``) : 'T =
let inline call_2 (_mthd: ^M, x: ^I) = ((^M or ^I) : (static member Extract : _ -> _) x)
Expand Down Expand Up @@ -82,10 +80,10 @@ type Extend =
| ValueTask.Canceled -> tcs.SetCanceled ()
// nowarn here, this case has been handled already if g.IsCompleted
else
ValueTask.continueTask tcs g (fun _ ->
g |> ValueTask.continueTask tcs (fun _ ->
try tcs.SetResult (f g)
with e -> tcs.SetException e)
tcs.Task |> ValueTask<'U>
ValueTask<'U> tcs.Task

#endif

Expand Down
15 changes: 5 additions & 10 deletions src/FSharpPlus/Extensions/Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ module Extensions =
open System.Threading.Tasks
open FSharp.Core.CompilerServices

let private (|Canceled|Faulted|Completed|) (t: Task<'a>) =
if t.IsCanceled then Canceled
else if t.IsFaulted then Faulted (Unchecked.nonNull t.Exception)
else Completed t.Result

type Task<'t> with
static member WhenAll (tasks: Task<'a>[], ?cancellationToken: CancellationToken) =
let tcs = TaskCompletionSource<'a[]> ()
Expand All @@ -53,9 +48,9 @@ module Extensions =
tasks
|> Seq.iteri (fun i t ->
let continuation = function
| Canceled -> tcs.TrySetCanceled () |> ignore
| Faulted e -> tcs.TrySetException e |> ignore
| Completed r ->
| Task.Canceled -> tcs.TrySetCanceled () |> ignore
| Task.Faulted e -> tcs.TrySetException e |> ignore
| Task.Succeeded r ->
results.[i] <- r
if Interlocked.Decrement pending = 0 then
tcs.SetResult results
Expand Down Expand Up @@ -132,7 +127,7 @@ module Extensions =
computation,
ts.SetResult,
(function
| :? AggregateException as agg -> ts.SetException agg.InnerExceptions
| :? AggregateException as aex when aex.InnerExceptions.Count > 0 -> ts.SetException aex.InnerExceptions
| exn -> ts.SetException exn),
(fun _ -> ts.SetCanceled ()),
cancellationToken)
Expand Down Expand Up @@ -198,7 +193,7 @@ module Extensions =
/// Similar to Async.Sequential but the returned Async contains a sequence, which is lazily evaluated.
static member SequentialLazy (t: seq<Async<'T>>) : Async<seq<_>> = async {
let! ct = Async.CancellationToken
return Seq.map (fun t -> Async.AsTask(t, ct).Result) t }
return Seq.map (fun t -> Async.AsTask(t, ct).GetAwaiter().GetResult ()) t }

#endif

Expand Down
Loading
Loading