Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 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_3 || FABLE_COMPILER_4
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,10 @@ type Extract =
static member inline Extract (f: 'Monoid -> 'T) = f (LanguagePrimitives.GenericZero)
#endif
#if !FABLE_COMPILER
static member Extract (f: Task<'T> ) = f.Result
static member Extract (f: Task<'T> ) = f.GetAwaiter().GetResult ()
#endif
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Extract (f: ValueTask<'T> ) = f.Result
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 +82,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 }
[<Obsolete("Renamed to Async.Sequential or Async.SequentialLazy")>]static member Sequence (t: seq<Async<_>>) = Async.SequentialLazy t
#endif

Expand Down
Loading
Loading