From b27847a28334be451f51b2aad2f1e945544bd4c9 Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Tue, 30 Jan 2024 22:26:33 -0500 Subject: [PATCH] Remove Ply and update to FSharp 6 (#248) * remove Ply and update to FSharp 6 * Cleanup dependencies * Fix fsharp.core warning * Don't build so much --- .github/workflows/build.yml | 9 +- paket.dependencies | 34 +- paket.lock | 65 +-- .../paket.references | 7 +- .../CancellableTaskResultCE.fs | 6 +- .../CancellableTaskValidationCE.fs | 4 +- .../FsToolkit.ErrorHandling.IcedTasks.fsproj | 39 +- .../paket.references | 6 +- .../paket.references | 7 +- .../List.fs | 3 - .../Result.fs | 3 - .../Task.fs | 8 +- .../TaskOption.fs | 4 +- .../TaskOptionCE.fs | 435 +--------------- .../TaskResult.fs | 3 - .../TaskResultCE.fs | 481 +----------------- .../TaskResultOptionCE.fs | 48 +- .../paket.references | 4 +- .../FsToolkit.ErrorHandling.fsproj | 93 ++-- src/FsToolkit.ErrorHandling/Shims.fs | 22 - src/FsToolkit.ErrorHandling/paket.references | 7 +- .../paket.references | 1 - .../BackgroundTaskOptionCE.fs | 4 - .../BackgroundTaskResultCE.fs | 3 - ...lkit.ErrorHandling.TaskResult.Tests.fsproj | 66 ++- .../List.fs | 5 - .../Result.fs | 3 - .../TaskOption.fs | 3 - .../TaskOptionCE.fs | 3 - .../TaskResult.fs | 4 - .../TaskResultCE.fs | 33 -- .../paket.references | 1 - tests/FsToolkit.ErrorHandling.Tests/Expect.fs | 5 - .../paket.references | 1 - tools/FunctionMap/paket.references | 3 +- 35 files changed, 159 insertions(+), 1264 deletions(-) delete mode 100644 src/FsToolkit.ErrorHandling/Shims.fs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0491abba..d4c438bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,13 @@ name: Build master -on: [push, pull_request] +on: + # Runs only on pushes to the default branch or pull requests to the default branch + push: + branches: + - master + pull_request: + branches: + - master jobs: diff --git a/paket.dependencies b/paket.dependencies index 162993e7..9afb8e55 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -2,39 +2,16 @@ source https://api.nuget.org/v3/index.json storage: none - -nuget Microsoft.SourceLink.GitHub prerelease copy_local: true - - - - -group NetStandard2 -source https://api.nuget.org/v3/index.json lowest_matching: true strategy: min -nuget FSharp.Core >= 4.7.2 -nuget Ply -nuget Hopac -nuget FSharp.Control.AsyncSeq +nuget FSharp.Core >= 6.0.1 +nuget Hopac >= 0.5.1 +nuget FSharp.Control.AsyncSeq >= 3.2.1 nuget Fable.Core >= 4.2.0 -framework: netstandard2.0, net6.0 -storage: none -condition: netstandard2_0 - - +nuget IcedTasks >= 0.10.2 +nuget Microsoft.SourceLink.GitHub prerelease copy_local: true -group NetStandard2_1 -source https://api.nuget.org/v3/index.json -lowest_matching: true -strategy: min -nuget FSharp.Core >= 7.0.0 -nuget Hopac -nuget FSharp.Control.AsyncSeq -nuget IcedTasks >= 0.7.0 -framework: netstandard2.1, net7.0 -storage: none -condition: netstandard2_1 group Test source https://api.nuget.org/v3/index.json @@ -50,7 +27,6 @@ nuget Fable.Core nuget Fable.Mocha nuget Fable.Python nuget Fable.Pyxpecto -nuget Ply group Benchmarks source https://api.nuget.org/v3/index.json diff --git a/paket.lock b/paket.lock index 12d8f404..b5222558 100644 --- a/paket.lock +++ b/paket.lock @@ -1,11 +1,27 @@ STORAGE: NONE +STRATEGY: MIN +LOWEST_MATCHING: TRUE NUGET remote: https://api.nuget.org/v3/index.json + Fable.Core (4.2) + FSharp.Control.AsyncSeq (3.2.1) + FSharp.Core (>= 4.7.2) - restriction: >= netstandard2.0 + Microsoft.Bcl.AsyncInterfaces (>= 5.0) - restriction: >= netstandard2.0 + FSharp.Core (6.0.1) + Hopac (0.5.1) + FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 + IcedTasks (0.10.2) + FSharp.Core (>= 6.0.1) - restriction: >= netstandard2.0 + Microsoft.Bcl.AsyncInterfaces (5.0) - restriction: >= netstandard2.0 + System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net461) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) Microsoft.Build.Tasks.Git (8.0) - copy_local: true Microsoft.SourceLink.Common (8.0) - copy_local: true Microsoft.SourceLink.GitHub (8.0) - copy_local: true Microsoft.Build.Tasks.Git (>= 8.0) Microsoft.SourceLink.Common (>= 8.0) + System.Runtime.CompilerServices.Unsafe (4.5.3) - restriction: || (&& (< monoandroid) (< netstandard1.0) (>= netstandard2.0) (< win8)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netstandard2.0)) (&& (< netstandard1.0) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= wp8)) + System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (>= net461) (>= netstandard2.0)) (&& (< netcoreapp2.1) (>= netstandard2.0) (< netstandard2.1)) + System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8) GROUP Benchmarks STORAGE: NONE @@ -851,48 +867,6 @@ NUGET System.Windows.Extensions (6.0) - restriction: >= netcoreapp3.1 System.Drawing.Common (>= 6.0) - restriction: >= netcoreapp3.1 -GROUP NetStandard2 -STORAGE: NONE -STRATEGY: MIN -LOWEST_MATCHING: TRUE -CONDITION: NETSTANDARD2_0 -RESTRICTION: || (== net6.0) (== netstandard2.0) -NUGET - remote: https://api.nuget.org/v3/index.json - Fable.Core (4.2) - FSharp.Control.AsyncSeq (3.2.1) - FSharp.Core (>= 4.7.2) - Microsoft.Bcl.AsyncInterfaces (>= 5.0) - FSharp.Core (4.7.2) - Hopac (0.5.1) - FSharp.Core (>= 4.5.2) - Microsoft.Bcl.AsyncInterfaces (6.0) - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (== netstandard2.0) - Ply (0.3.1) - FSharp.Core (>= 4.6.2) - System.Threading.Tasks.Extensions (>= 4.5.4) - System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (== netstandard2.0) - System.Threading.Tasks.Extensions (4.5.4) - System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (== netstandard2.0) - -GROUP NetStandard2_1 -STORAGE: NONE -STRATEGY: MIN -LOWEST_MATCHING: TRUE -CONDITION: NETSTANDARD2_1 -RESTRICTION: || (== net7.0) (== netstandard2.1) -NUGET - remote: https://api.nuget.org/v3/index.json - FSharp.Control.AsyncSeq (3.2.1) - FSharp.Core (>= 4.7.2) - Microsoft.Bcl.AsyncInterfaces (>= 5.0) - FSharp.Core (7.0.300) - Hopac (0.5.1) - FSharp.Core (>= 4.5.2) - IcedTasks (0.7) - FSharp.Core (>= 7.0) - Microsoft.Bcl.AsyncInterfaces (6.0) - GROUP Test STORAGE: NONE STRATEGY: MIN @@ -932,9 +906,6 @@ NUGET Mono.Cecil (0.11.5) - restriction: >= net6.0 Newtonsoft.Json (13.0.3) - restriction: >= netcoreapp3.1 NuGet.Frameworks (6.8) - restriction: >= netcoreapp3.1 - Ply (0.3.1) - FSharp.Core (>= 4.6.2) - restriction: >= netstandard2.0 - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: >= netstandard2.0 System.Buffers (4.5.1) - restriction: || (&& (>= monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= monotouch) (>= netcoreapp3.1)) (&& (>= net45) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= net461) (>= netcoreapp3.1)) (&& (>= net462) (>= netcoreapp3.1)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinios)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinmac)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarintvos)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinwatchos)) (&& (< netcoreapp2.0) (>= netcoreapp3.1)) (&& (>= netcoreapp3.1) (< netstandard1.1) (>= win8)) (&& (>= netcoreapp3.1) (< netstandard2.0) (>= wpa81)) System.Collections.Immutable (8.0) - restriction: >= netcoreapp3.1 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netstandard2.0)) @@ -944,9 +915,7 @@ NUGET System.Reflection.Metadata (8.0) - restriction: >= netcoreapp3.1 System.Collections.Immutable (>= 8.0) - restriction: || (>= net462) (>= netstandard2.0) System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (>= monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (< netcoreapp2.1) (>= netcoreapp3.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard2.0)) (&& (< monoandroid) (< netstandard1.0) (>= netstandard2.0) (< win8)) (&& (>= monotouch) (>= netcoreapp3.1)) (&& (>= net45) (>= netcoreapp3.1) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netcoreapp3.1)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= net6.0)) (&& (>= net462) (>= netcoreapp3.1)) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinios)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinmac)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarintvos)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinwatchos)) (&& (< netcoreapp2.0) (>= netcoreapp3.1)) (&& (>= netcoreapp3.1) (< netstandard1.1) (>= win8)) (&& (>= netcoreapp3.1) (< netstandard2.0) (>= wpa81)) (&& (>= netcoreapp3.1) (>= uap10.1)) (&& (< netstandard1.0) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= wp8)) - System.Threading.Tasks.Extensions (4.5.4) - restriction: >= netstandard2.0 - System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8) + System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (>= monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (< netcoreapp2.1) (>= netcoreapp3.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard1.1)) (&& (< monoandroid) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= monotouch) (>= netcoreapp3.1)) (&& (>= net45) (>= netcoreapp3.1) (< netstandard2.0)) (&& (>= net461) (>= netcoreapp3.1)) (&& (>= net462) (>= net6.0)) (&& (>= net462) (>= netcoreapp3.1)) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinios)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinmac)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarintvos)) (&& (< net6.0) (>= netcoreapp3.1) (>= xamarinwatchos)) (&& (< netcoreapp2.0) (>= netcoreapp3.1)) (&& (>= netcoreapp3.1) (< netstandard1.1) (>= win8)) (&& (>= netcoreapp3.1) (< netstandard2.0) (>= wpa81)) (&& (>= netcoreapp3.1) (>= uap10.1)) YoloDev.Expecto.TestSdk (0.14.3) Expecto (>= 10.0 < 11.0) - restriction: >= net6.0 FSharp.Core (>= 7.0.200) - restriction: >= net6.0 diff --git a/src/FsToolkit.ErrorHandling.AsyncSeq/paket.references b/src/FsToolkit.ErrorHandling.AsyncSeq/paket.references index 1e2b033b..3320bac5 100644 --- a/src/FsToolkit.ErrorHandling.AsyncSeq/paket.references +++ b/src/FsToolkit.ErrorHandling.AsyncSeq/paket.references @@ -1,6 +1,3 @@ Microsoft.SourceLink.GitHub - -group NetStandard2 - FSharp.Control.AsyncSeq -group NetStandard2_1 - FSharp.Control.AsyncSeq \ No newline at end of file +FSharp.Core +FSharp.Control.AsyncSeq diff --git a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs index c8648c2e..e5d2fa05 100644 --- a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs +++ b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs @@ -177,6 +177,7 @@ module CancellableTaskResultCE = ) ) +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline internal this.TryFinallyAsync ( body: CancellableTaskResultCode<'TOverall, 'Error, 'T>, @@ -238,7 +239,7 @@ module CancellableTaskResultCE = ValueTask() ) ) - +#endif member inline this.Source (ctr: CancellableTaskResult<'T, 'Error>) : CancellableTaskResult<'T, 'Error> = @@ -257,9 +258,10 @@ module CancellableTaskResultCE = |> Async.map Result.ofChoice |> this.Source +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline _.Source(t: ValueTask>) : CancellableTaskResult<'T, 'Error> = cancellableTask { return! t } - +#endif member inline _.Source(result: Result<_, _>) : CancellableTaskResult<_, _> = CancellableTask.singleton result diff --git a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs index 208879fd..08ff4bed 100644 --- a/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs +++ b/src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskValidationCE.fs @@ -175,7 +175,7 @@ module CancellableTaskValidationCE = ) ) ) - +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline internal this.TryFinallyAsync ( [] body: CancellableTaskValidationCode<'TOverall, 'Error, 'T>, @@ -238,7 +238,7 @@ module CancellableTaskValidationCE = ValueTask() ) ) - +#endif [] static member inline BindDynamic diff --git a/src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj b/src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj index a06ce42a..d04c2fdb 100644 --- a/src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj +++ b/src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj @@ -1,21 +1,22 @@  - - Library - netstandard2.1 - preview - portable - FS3511;FS3513 - - - - - - - - - - - - - \ No newline at end of file + + Library + netstandard2.0;netstandard2.1 + preview + portable + FS3511;FS3513 + + + + + + + + + + + + + diff --git a/src/FsToolkit.ErrorHandling.IcedTasks/paket.references b/src/FsToolkit.ErrorHandling.IcedTasks/paket.references index 992c1aac..e9b80506 100644 --- a/src/FsToolkit.ErrorHandling.IcedTasks/paket.references +++ b/src/FsToolkit.ErrorHandling.IcedTasks/paket.references @@ -1,6 +1,4 @@ Microsoft.SourceLink.GitHub - -group NetStandard2_1 - FSharp.Core - IcedTasks \ No newline at end of file +FSharp.Core +IcedTasks diff --git a/src/FsToolkit.ErrorHandling.JobResult/paket.references b/src/FsToolkit.ErrorHandling.JobResult/paket.references index 5646e552..8bbf3f25 100644 --- a/src/FsToolkit.ErrorHandling.JobResult/paket.references +++ b/src/FsToolkit.ErrorHandling.JobResult/paket.references @@ -1,6 +1,3 @@ Microsoft.SourceLink.GitHub - -group NetStandard2 - Hopac -group NetStandard2_1 - Hopac \ No newline at end of file +FSharp.Core +Hopac diff --git a/src/FsToolkit.ErrorHandling.TaskResult/List.fs b/src/FsToolkit.ErrorHandling.TaskResult/List.fs index 275659c4..7ce81bc0 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/List.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/List.fs @@ -2,9 +2,6 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks open FsToolkit.ErrorHandling -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine -#endif [] module List = diff --git a/src/FsToolkit.ErrorHandling.TaskResult/Result.fs b/src/FsToolkit.ErrorHandling.TaskResult/Result.fs index 68827ed0..1f24c35b 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/Result.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/Result.fs @@ -1,9 +1,6 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine -#endif module Result = diff --git a/src/FsToolkit.ErrorHandling.TaskResult/Task.fs b/src/FsToolkit.ErrorHandling.TaskResult/Task.fs index 9fda2cc5..1e08b46b 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/Task.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/Task.fs @@ -2,9 +2,6 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine -#endif [] module Task = @@ -18,12 +15,13 @@ module Task = return! f x } +#if NETSTANDARD2_1 || NET6_0_OR_GREATER let inline bindV ([] f: 'a -> Task<'b>) (x: ValueTask<'a>) = task { let! x = x return! f x } - +#endif let inline apply f x = bind (fun f' -> bind (fun x' -> singleton (f' x')) x) f @@ -34,12 +32,14 @@ module Task = >> singleton ) +#if NETSTANDARD2_1 || NET6_0_OR_GREATER let inline mapV ([] f) x = x |> bindV ( f >> singleton ) +#endif let inline map2 ([] f) x y = (apply (apply (singleton f) x) y) diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskOption.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskOption.fs index a154a71c..f3a30649 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskOption.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskOption.fs @@ -1,9 +1,7 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine -#endif + [] module TaskOption = diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs index 9bd7ee9b..c52fbdbd 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskOptionCE.fs @@ -4,430 +4,6 @@ open System open System.Threading.Tasks -#if NETSTANDARD2_0 -open Ply -open System.Runtime.CompilerServices - -[] -module TaskOptionCE = - type TaskOptionBuilder() = - member val SomeUnit = Some() - - member inline _.Return(value: 'T) : Ply<_ option> = - option.Return value - |> FSharp.Control.Tasks.Affine.Unsafe.uply.Return - - member inline _.ReturnFrom(taskResult: Task<_ option>) : Ply<_ option> = - FSharp.Control.Tasks.Affine.Unsafe.uply.ReturnFrom taskResult - - member inline _.Zero() : Ply<_ option> = - option.Zero() - |> FSharp.Control.Tasks.Affine.Unsafe.uply.Return - - member inline _.Bind - ( - taskResult: Task<_ option>, - [] binder: 'T -> Ply<_ option> - ) : Ply<_ option> = - let binder' r = - match r with - | Some x -> binder x - | None -> FSharp.Control.Tasks.Affine.Unsafe.uply.Return None - - FSharp.Control.Tasks.Affine.Unsafe.uply.Bind(taskResult, binder') - - member inline _.Delay([] generator: unit -> Ply<_ option>) = - FSharp.Control.Tasks.Affine.Unsafe.uply.Delay(generator) - - member inline _.Combine - ( - computation1: Ply<'T option>, - [] computation2: unit -> Ply<'U option> - ) : Ply<'U option> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - match! computation1 with - | None -> return None - | Some _ -> return! computation2 () - } - - member inline _.TryWith - ( - [] computation: unit -> Ply<_ option>, - [] handler: exn -> Ply<_ option> - ) : Ply<_ option> = - FSharp.Control.Tasks.Affine.Unsafe.uply.TryWith(computation, handler) - - member inline _.TryFinally - ( - [] computation: unit -> Ply<_ option>, - [] compensation: unit -> unit - ) : Ply<_ option> = - FSharp.Control.Tasks.Affine.Unsafe.uply.TryFinally(computation, compensation) - - member inline _.Using - ( - resource: 'T :> IDisposable, - [] binder: 'T -> Ply<_ option> - ) : Ply<_ option> = - FSharp.Control.Tasks.Affine.Unsafe.uply.Using(resource, binder) - - member inline _.While - ( - [] guard: unit -> bool, - [] computation: unit -> Ply<'U option> - ) : Ply<'U option> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - let mutable fin, result = false, None - - while not fin - && guard () do - match! computation () with - | Some _ as o -> result <- o - | None -> - result <- None - fin <- true - - return result - } - - member inline _.For(sequence: #seq<'T>, binder: 'T -> Ply<'U option>) : Ply<'U option> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - use enumerator = sequence.GetEnumerator() - let mutable fin, result = false, None - - while not fin - && enumerator.MoveNext() do - match! binder enumerator.Current with - | Some _ as o -> result <- o - | None -> - result <- None - fin <- true - - return result - } - - member inline this.BindReturn(x: Task<'T option>, [] f) = - this.Bind(x, (fun x -> this.Return(f x))) - - member inline _.MergeSources(t1: Task<'T option>, t2: Task<'T1 option>) = - TaskOption.zip t1 t2 - - member inline _.Run([] f: unit -> Ply<'m>) = - FSharp.Control.Tasks.Affine.task.Run f - - /// - /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type. - /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder - /// - member inline _.Source(task: Task<_ option>) : Task<_ option> = task - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask<_ option>) : Task<_ option> = - FSharp.Control.Tasks.Affine.task { return! t } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(async: Async<_ option>) : Task<_ option> = - async - |> Async.StartImmediateAsTask - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply<_ option>) : Task<_ option> = - FSharp.Control.Tasks.Affine.task { return! p } - - let taskOption = TaskOptionBuilder() - - type BackgroundTaskOptionBuilder() = - member val SomeUnit = Some() - - member inline _.Return(value: 'T) : Ply<_ option> = - option.Return value - |> FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return - - member inline _.ReturnFrom(taskResult: Task<_ option>) : Ply<_ option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.ReturnFrom taskResult - - member inline _.Zero() : Ply<_ option> = - option.Zero() - |> FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return - - member inline _.Bind - ( - taskResult: Task<_ option>, - [] binder: 'T -> Ply<_ option> - ) : Ply<_ option> = - let binder' r = - match r with - | Some x -> binder x - | None -> FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return None - - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Bind(taskResult, binder') - - member inline _.Delay([] generator: unit -> Ply<_ option>) = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Delay(generator) - - member inline _.Combine - ( - computation1: Ply<'T option>, - [] computation2: unit -> Ply<'U option> - ) : Ply<'U option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - match! computation1 with - | None -> return None - | Some _ -> return! computation2 () - } - - member inline _.TryWith - ( - [] computation: unit -> Ply<_ option>, - [] handler: exn -> Ply<_ option> - ) : Ply<_ option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.TryWith(computation, handler) - - member inline _.TryFinally - ( - [] computation: unit -> Ply<_ option>, - [] compensation: unit -> unit - ) : Ply<_ option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.TryFinally(computation, compensation) - - member inline _.Using - ( - resource: 'T :> IDisposable, - [] binder: 'T -> Ply<_ option> - ) : Ply<_ option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Using(resource, binder) - - member inline _.While - ( - [] guard: unit -> bool, - [] computation: unit -> Ply<'U option> - ) : Ply<'U option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - let mutable fin, result = false, None - - while not fin - && guard () do - match! computation () with - | Some _ as o -> result <- o - | None -> - result <- None - fin <- true - - return result - } - - member inline _.For(sequence: #seq<'T>, binder: 'T -> Ply<'U option>) : Ply<'U option> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - use enumerator = sequence.GetEnumerator() - let mutable fin, result = false, None - - while not fin - && enumerator.MoveNext() do - match! binder enumerator.Current with - | Some _ as o -> result <- o - | None -> - result <- None - fin <- true - - return result - } - - member inline this.BindReturn(x: Task<'T option>, [] f) = - this.Bind(x, (fun x -> this.Return(f x))) - - member inline _.MergeSources(t1: Task<'T option>, t2: Task<'T1 option>) = - FSharp.Control.Tasks.NonAffine.task { - let! o1 = t1 - let! o2 = t2 - return Option.zip o1 o2 - } - - member inline _.Run([] f: unit -> Ply<'m>) = - FSharp.Control.Tasks.NonAffine.task.Run f - - /// - /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type. - /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder - /// - member inline _.Source(task: Task<_ option>) : Task<_ option> = task - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask<_ option>) : Task<_ option> = - FSharp.Control.Tasks.NonAffine.task { return! t } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(async: Async<_ option>) : Task<_ option> = - async - |> Async.StartImmediateAsTask - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply<_ option>) : Task<_ option> = - FSharp.Control.Tasks.NonAffine.task { return! p } - - let backgroundTaskOption = BackgroundTaskOptionBuilder() - - -[] -// Having members as extensions gives them lower priority in -// overload resolution and allows skipping more type annotations. -module TaskOptionCEExtensionsLower = - - type TaskOptionBuilder with - - member inline this.Source(t: ^TaskLike) : Task<'T option> = - FSharp.Control.Tasks.Affine.task { - let! r = t - return Some r - } - - type BackgroundTaskOptionBuilder with - - member inline this.Source(t: ^TaskLike) : Task<'T option> = - FSharp.Control.Tasks.NonAffine.task { - let! r = t - return Some r - } - -[] -// Having members as extensions gives them lower priority in -// overload resolution and allows skipping more type annotations. -module TaskOptionCEExtensions = - - type TaskOptionBuilder with - - /// - /// Needed to allow `for..in` and `for..do` functionality - /// - member inline _.Source(s: #seq<_>) = s - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(r: 't option) = Task.singleton r - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: Task<'T>) = - FSharp.Control.Tasks.Affine.task { - let! o = a - return Some o - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline x.Source(a: Task) = - FSharp.Control.Tasks.Affine.task { - do! a - return x.SomeUnit - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: ValueTask<'T>) = - FSharp.Control.Tasks.Affine.task { - let! o = a - return Some o - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline x.Source(a: ValueTask) = - FSharp.Control.Tasks.Affine.task { - do! a - return x.SomeUnit - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: Async<'t>) = - FSharp.Control.Tasks.Affine.task { - let! o = - a - |> Async.StartImmediateAsTask - - return Some o - } - - - type BackgroundTaskOptionBuilder with - - /// - /// Needed to allow `for..in` and `for..do` functionality - /// - member inline _.Source(s: #seq<_>) = s - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(r: 't option) = Task.singleton r - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: Task<'T>) = - FSharp.Control.Tasks.NonAffine.task { - let! o = a - return Some o - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline x.Source(a: Task) = - FSharp.Control.Tasks.NonAffine.task { - do! a - return x.SomeUnit - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: ValueTask<'T>) = - FSharp.Control.Tasks.NonAffine.task { - let! o = a - return Some o - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline x.Source(a: ValueTask) = - FSharp.Control.Tasks.NonAffine.task { - do! a - return x.SomeUnit - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(a: Async<'t>) = - FSharp.Control.Tasks.NonAffine.task { - let! o = - a - |> Async.StartImmediateAsTask - - return Some o - } - - -#else open System open System.Runtime.CompilerServices @@ -577,6 +153,7 @@ type TaskOptionBuilderBase() = ) ) +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline internal this.TryFinallyAsync ( body: TaskOptionCode<'TOverall, 'T>, @@ -636,6 +213,7 @@ type TaskOptionBuilderBase() = ValueTask() ) ) +#endif member inline this.Source(computation: Async<'T option>) : TaskOption<'T> = computation @@ -643,9 +221,12 @@ type TaskOptionBuilderBase() = member inline this.Source(taskOption: TaskOption<'T>) : TaskOption<'T> = taskOption + +#if NETSTANDARD2_1 || NET6_0_OR_GREATER + member inline this.Source(taskOption: ValueTask<'T option>) : TaskOption<'T> = taskOption.AsTask() - +#endif type TaskOptionBuilder() = @@ -1026,6 +607,7 @@ module TaskOptionCEExtensionsMediumPriority = return Some() } +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline this.Source(t: ValueTask<'T>) : TaskOption<'T> = t |> Task.mapV Some @@ -1035,6 +617,7 @@ module TaskOptionCEExtensionsMediumPriority = do! t return Some() } +#endif member inline this.Source(opt: Option<'T>) : TaskOption<'T> = Task.FromResult opt @@ -1042,5 +625,3 @@ module TaskOptionCEExtensionsMediumPriority = computation |> Async.map Some |> Async.StartImmediateAsTask - -#endif diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs index fe42be3f..18530b58 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskResult.fs @@ -1,9 +1,6 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine -#endif [] module TaskResult = diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs index ce024913..966fe4fc 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultCE.fs @@ -4,480 +4,6 @@ open System open System.Threading.Tasks -#if NETSTANDARD2_0 -// open FSharp.Control.Tasks -open Ply - -[] -module TaskResultCE = - - type TaskResultBuilder() = - - member inline _.Return(value: 'T) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply.Return(result.Return value) - - member inline _.ReturnFrom - (taskResult: Task>) - : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply.ReturnFrom taskResult - - member inline _.Zero() : Ply> = - result.Zero() - |> FSharp.Control.Tasks.Affine.Unsafe.uply.Return - - member inline _.Bind - ( - taskResult: Task>, - [] binder: 'T -> Ply> - ) : Ply> = - let binder' r = - match r with - | Ok x -> binder x - | Error x -> - Error x - |> FSharp.Control.Tasks.Affine.Unsafe.uply.Return - - FSharp.Control.Tasks.Affine.Unsafe.uply.Bind(taskResult, binder') - - member inline _.Delay([] generator: unit -> Ply>) = - FSharp.Control.Tasks.Affine.Unsafe.uply.Delay(generator) - - member inline _.Combine - ( - computation1: Ply>, - [] computation2: unit -> Ply> - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - match! computation1 with - | Error e -> return Error e - | Ok _ -> return! computation2 () - } - - member inline _.TryWith - ( - [] computation: unit -> Ply>, - [] handler: exn -> Ply> - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply.TryWith(computation, handler) - - member inline _.TryFinally - ( - [] computation: unit -> Ply>, - [] compensation: unit -> unit - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply.TryFinally(computation, compensation) - - member inline _.Using - ( - resource: 'T :> IDisposable, - [] binder: 'T -> Ply> - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply.Using(resource, binder) - - member inline _.While - ( - [] guard: unit -> bool, - [] computation: unit -> Ply> - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - let mutable fin, result = false, Ok() - - while not fin - && guard () do - match! computation () with - | Ok x -> x - | Error _ as e -> - result <- e - fin <- true - - return result - } - - member inline _.For - ( - sequence: #seq<'T>, - [] binder: 'T -> Ply> - ) : Ply> = - FSharp.Control.Tasks.Affine.Unsafe.uply { - use enumerator = sequence.GetEnumerator() - let mutable fin, result = false, Ok() - - while not fin - && enumerator.MoveNext() do - match! binder enumerator.Current with - | Ok x -> x - | Error _ as e -> - result <- e - fin <- true - - return result - } - - member inline this.BindReturn(x: Task>, [] f) = - this.Bind(x, (fun x -> this.Return(f x))) - - member inline _.MergeSources(t1: Task>, t2: Task>) = - TaskResult.zip t1 t2 - - member inline _.Run([] f: unit -> Ply<'m>) = - FSharp.Control.Tasks.Affine.task.Run f - - /// - /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type. - /// - /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder - /// - member inline _.Source(task: Task>) : Task> = task - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask>) : Task> = - FSharp.Control.Tasks.Affine.task { return! t } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(result: Async>) : Task> = - result - |> Async.StartImmediateAsTask - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply>) : Task> = - FSharp.Control.Tasks.Affine.task { return! p } - - let taskResult = TaskResultBuilder() - - - type BackgroundTaskResultBuilder() = - - member inline _.Return(value: 'T) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return(result.Return value) - - member inline _.ReturnFrom - (taskResult: Task>) - : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.ReturnFrom taskResult - - member inline _.Zero() : Ply> = - result.Zero() - |> FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return - - - member inline _.Bind - ( - taskResult: Task>, - [] binder: 'T -> Ply> - ) : Ply> = - let binder' r = - match r with - | Ok x -> binder x - | Error x -> - Error x - |> FSharp.Control.Tasks.NonAffine.Unsafe.uply.Return - - - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Bind(taskResult, binder') - - member inline _.Delay([] generator: unit -> Ply>) = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Delay(generator) - - member inline _.Combine - ( - computation1: Ply>, - [] computation2: unit -> Ply> - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - match! computation1 with - | Error e -> return Error e - | Ok _ -> return! computation2 () - } - - member inline _.TryWith - ( - [] computation: unit -> Ply>, - [] handler: exn -> Ply> - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.TryWith(computation, handler) - - member inline _.TryFinally - ( - [] computation: unit -> Ply>, - [] compensation: unit -> unit - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.TryFinally(computation, compensation) - - member inline _.Using - ( - resource: 'T :> IDisposable, - [] binder: 'T -> Ply> - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply.Using(resource, binder) - - member inline _.While - ( - [] guard: unit -> bool, - [] computation: unit -> Ply> - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - let mutable fin, result = false, Ok() - - while not fin - && guard () do - match! computation () with - | Ok x -> x - | Error _ as e -> - result <- e - fin <- true - - return result - } - - member inline _.For - ( - sequence: #seq<'T>, - [] binder: 'T -> Ply> - ) : Ply> = - FSharp.Control.Tasks.NonAffine.Unsafe.uply { - use enumerator = sequence.GetEnumerator() - let mutable fin, result = false, Ok() - - while not fin - && enumerator.MoveNext() do - match! binder enumerator.Current with - | Ok x -> x - | Error _ as e -> - result <- e - fin <- true - - return result - } - - member inline this.BindReturn(x: Task>, [] f) = - this.Bind(x, (fun x -> this.Return(f x))) - - member inline _.MergeSources(t1: Task>, t2: Task>) = - FSharp.Control.Tasks.NonAffine.task { - let! r1 = t1 - let! r2 = t2 - return Result.zip r1 r2 - } - - member inline _.Run([] f: unit -> Ply<'m>) = - FSharp.Control.Tasks.NonAffine.task.Run f - - /// - /// Method lets us transform data types into our internal representation. This is the identity method to recognize the self type. - /// - /// See https://stackoverflow.com/questions/35286541/why-would-you-use-builder-source-in-a-custom-computation-expression-builder - /// - member inline _.Source(task: Task>) : Task> = task - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask>) : Task> = - FSharp.Control.Tasks.NonAffine.task { return! t } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(result: Async>) : Task> = - result - |> Async.StartImmediateAsTask - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply>) : Task> = - FSharp.Control.Tasks.NonAffine.task { return! p } - - - let backgroundTaskResult = BackgroundTaskResultBuilder() - -[] -// Having members as extensions gives them lower priority in -// overload resolution and allows skipping more type annotations. -module TaskResultCEExtensionsLower = - - type TaskResultBuilder with - - member inline this.Source(t: ^TaskLike) : Task> = - FSharp.Control.Tasks.Affine.task { - let! r = t - return Ok r - } - - type BackgroundTaskResultBuilder with - - member inline this.Source(t: ^TaskLike) : Task> = - FSharp.Control.Tasks.NonAffine.task { - let! r = t - return Ok r - } - -// Having members as extensions gives them lower priority in -// overload resolution between Task<_> and Task>. -[] -module TaskResultCEExtensions = - type TaskResultBuilder with - - /// - /// Needed to allow `for..in` and `for..do` functionality - /// - member inline _.Source(s: #seq<_>) = s - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(result: Result<_, _>) : Task> = Task.singleton result - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(choice: Choice<_, _>) : Task> = - choice - |> Result.ofChoice - |> Task.singleton - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(asyncComputation: Async<_>) : Task> = - FSharp.Control.Tasks.Affine.task { - let! r = - asyncComputation - |> Async.StartImmediateAsTask - - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(task: Task<_>) : Task> = - FSharp.Control.Tasks.Affine.task { - let! r = task - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: Task) : Task> = - FSharp.Control.Tasks.Affine.task { - do! t - return Ok() - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(task: ValueTask<_>) : Task> = - FSharp.Control.Tasks.Affine.task { - let! r = task - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask) : Task> = - FSharp.Control.Tasks.Affine.task { - do! t - return Ok() - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply<_>) : Task> = - FSharp.Control.Tasks.Affine.task { - let! p = p - return Ok p - } - - type BackgroundTaskResultBuilder with - - /// - /// Needed to allow `for..in` and `for..do` functionality - /// - member inline _.Source(s: #seq<_>) = s - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(result: Result<_, _>) : Task> = Task.singleton result - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(choice: Choice<_, _>) : Task> = - choice - |> Result.ofChoice - |> Task.singleton - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(asyncComputation: Async<_>) : Task> = - FSharp.Control.Tasks.NonAffine.task { - let! r = - asyncComputation - |> Async.StartImmediateAsTask - - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(task: Task<_>) : Task> = - FSharp.Control.Tasks.NonAffine.task { - let! r = task - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: Task) : Task> = - FSharp.Control.Tasks.NonAffine.task { - do! t - return Ok() - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(task: ValueTask<_>) : Task> = - FSharp.Control.Tasks.NonAffine.task { - let! r = task - return Ok r - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(t: ValueTask) : Task> = - FSharp.Control.Tasks.NonAffine.task { - do! t - return Ok() - } - - /// - /// Method lets us transform data types into our internal representation. - /// - member inline _.Source(p: Ply<_>) : Task> = - FSharp.Control.Tasks.NonAffine.task { - let! p = p - return Ok p - } - -#else - open System open System.Runtime.CompilerServices @@ -627,6 +153,7 @@ type TaskResultBuilderBase() = ) ) +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline internal this.TryFinallyAsync ( body: TaskResultCode<'TOverall, 'Error, 'T>, @@ -688,7 +215,7 @@ type TaskResultBuilderBase() = ValueTask() ) ) - +#endif member inline this.Source(taskResult: TaskResult<'T, 'Error>) : TaskResult<'T, 'Error> = taskResult @@ -697,7 +224,9 @@ type TaskResultBuilderBase() = result |> Async.StartImmediateAsTask +#if NETSTANDARD2_1 || NET6_0_OR_GREATER member inline _.Source(t: ValueTask>) : Task> = task { return! t } +#endif member inline _.Source(result: Result<_, _>) : Task> = Task.singleton result member inline _.Source(result: Choice<_, _>) : Task> = @@ -1065,5 +594,3 @@ module TaskResultCEExtensionsMediumPriority = computation |> Async.map Ok |> Async.StartImmediateAsTask - -#endif diff --git a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultOptionCE.fs b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultOptionCE.fs index d4dbae49..e80d0513 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/TaskResultOptionCE.fs +++ b/src/FsToolkit.ErrorHandling.TaskResult/TaskResultOptionCE.fs @@ -2,54 +2,10 @@ namespace FsToolkit.ErrorHandling open System.Threading.Tasks open FsToolkit.ErrorHandling -#if NETSTANDARD2_0 -open FSharp.Control.Tasks.Affine.Unsafe -open FSharp.Control.Tasks.Affine -open Ply -#endif + [] module TaskResultOptionCE = -#if NETSTANDARD2_0 - type TaskResultOptionBuilder() = - member inline _.Return(value: 'T) : Ply> = - result.Return(Some value) - |> uply.Return - - member inline _.ReturnFrom - (taskResult: Task>) - : Ply> = - uply.ReturnFrom taskResult - - member inline _.Bind - ( - taskResult: Task>, - [] binder: 'T -> Ply> - ) : Ply> = - let binder' r = - match r with - | Ok(Some x) -> binder x - | Ok None -> - Ok None - |> uply.Return - | Error x -> - Error x - |> uply.Return - - uply.Bind(taskResult, binder') - - member inline _.Combine(tro1, tro2) = - tro1 - |> TaskResultOption.bind (fun _ -> tro2) - |> uply.ReturnFrom - - member inline _.Delay([] f) = uply.Delay f - - member inline _.Run([] f: unit -> Ply<'m>) = task.Run f - - let taskResultOption = TaskResultOptionBuilder() - -#else open System open System.Runtime.CompilerServices @@ -292,5 +248,3 @@ module TaskResultOptionCE = TaskResultOptionBuilder.RunDynamic(code) let taskResultOption = TaskResultOptionBuilder() - -#endif diff --git a/src/FsToolkit.ErrorHandling.TaskResult/paket.references b/src/FsToolkit.ErrorHandling.TaskResult/paket.references index 2d9b38d1..53cac18a 100644 --- a/src/FsToolkit.ErrorHandling.TaskResult/paket.references +++ b/src/FsToolkit.ErrorHandling.TaskResult/paket.references @@ -1,4 +1,2 @@ +FSharp.Core Microsoft.SourceLink.GitHub - -group NetStandard2 - Ply \ No newline at end of file diff --git a/src/FsToolkit.ErrorHandling/FsToolkit.ErrorHandling.fsproj b/src/FsToolkit.ErrorHandling/FsToolkit.ErrorHandling.fsproj index 7e5f981d..f9ca841f 100644 --- a/src/FsToolkit.ErrorHandling/FsToolkit.ErrorHandling.fsproj +++ b/src/FsToolkit.ErrorHandling/FsToolkit.ErrorHandling.fsproj @@ -1,51 +1,50 @@  - - Library - netstandard2.1;netstandard2.0 - preview - portable + + Library + netstandard2.1;netstandard2.0 + preview + portable - $(PackageTags), fable-library, fable-dotnet, fable-javascript, fable-python - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + $(PackageTags), fable-library, fable-dotnet, fable-javascript, fable-python + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FsToolkit.ErrorHandling/Shims.fs b/src/FsToolkit.ErrorHandling/Shims.fs deleted file mode 100644 index b7d0c719..00000000 --- a/src/FsToolkit.ErrorHandling/Shims.fs +++ /dev/null @@ -1,22 +0,0 @@ -namespace FsToolkit.ErrorHandling - - -#if NETSTANDARD2_0 -open System - -/// InlineIfLambda doesn't exist until FSharp.Core 6.0. -/// Since we're targeting netstandard2.0 with FSharp.Core 4.7 to keep this libraries' reach -/// we need to create a fake attribute that does nothing instead of having ifdefs in each function argument -[] -[] -type internal InlineIfLambdaAttribute() = - inherit System.Attribute() - -open System.Runtime.CompilerServices - -// Let all the child libraries have access to this shim as well -[] -[] -[] -do () -#endif diff --git a/src/FsToolkit.ErrorHandling/paket.references b/src/FsToolkit.ErrorHandling/paket.references index 3fc2fc72..53cac18a 100644 --- a/src/FsToolkit.ErrorHandling/paket.references +++ b/src/FsToolkit.ErrorHandling/paket.references @@ -1,7 +1,2 @@ - +FSharp.Core Microsoft.SourceLink.GitHub - -group NetStandard2 - FSharp.Core -group NetStandard2_1 - FSharp.Core \ No newline at end of file diff --git a/tests/FsToolkit.ErrorHandling.JobResult.Tests/paket.references b/tests/FsToolkit.ErrorHandling.JobResult.Tests/paket.references index ea4bd68b..0b251f64 100644 --- a/tests/FsToolkit.ErrorHandling.JobResult.Tests/paket.references +++ b/tests/FsToolkit.ErrorHandling.JobResult.Tests/paket.references @@ -5,4 +5,3 @@ group Test YoloDev.Expecto.TestSdk Fable.Mocha Fable.Pyxpecto - Ply diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskOptionCE.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskOptionCE.fs index 9335c0f3..0943892d 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskOptionCE.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskOptionCE.fs @@ -4,10 +4,6 @@ open Expecto open FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -let backgroundTask = FSharp.Control.Tasks.NonAffine.task -#endif - let makeDisposable () = { new System.IDisposable with member this.Dispose() = () diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskResultCE.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskResultCE.fs index caa544e8..1979480c 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskResultCE.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/BackgroundTaskResultCE.fs @@ -7,9 +7,6 @@ open TestData open FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -let backgroundTask = FSharp.Control.Tasks.NonAffine.task -#endif [] let ``BackgroundTaskResultCE return Tests`` = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/FsToolkit.ErrorHandling.TaskResult.Tests.fsproj b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/FsToolkit.ErrorHandling.TaskResult.Tests.fsproj index 154963c0..efb9589f 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/FsToolkit.ErrorHandling.TaskResult.Tests.fsproj +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/FsToolkit.ErrorHandling.TaskResult.Tests.fsproj @@ -1,38 +1,32 @@ - - net7.0;net6.0; - preview - - - - TargetFramework=netstandard2.0 - - - TargetFramework=netstandard2.0 - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + net7.0;net6.0; + preview + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs index 7331c08f..1f582dac 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/List.fs @@ -7,11 +7,6 @@ open TestHelpers open System open FsToolkit.ErrorHandling -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif - - let userId1 = Guid.NewGuid() let userId2 = Guid.NewGuid() let userId3 = Guid.NewGuid() diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Result.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Result.fs index 5840e80b..1a1bbc59 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Result.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/Result.fs @@ -1,8 +1,5 @@ module Result -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif open Expecto open FsToolkit.ErrorHandling diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs index 36cae0e1..452b06cd 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOption.fs @@ -14,9 +14,6 @@ open Expecto open System open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif open TestData open TestHelpers open SampleDomain diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOptionCE.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOptionCE.fs index 0e951873..2efc961b 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOptionCE.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskOptionCE.fs @@ -4,9 +4,6 @@ open Expecto open FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif module TestFuncs = let testFunctionTO<'Dto> () = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs index 8e30d5bb..a6f0c6ae 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResult.fs @@ -10,10 +10,6 @@ open FsToolkit.ErrorHandling.Operator.TaskResult open System open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif - let runTaskSync (task: Task<_>) = task.Result let createPostSuccess = diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultCE.fs b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultCE.fs index 6696225e..69fe8271 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultCE.fs +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/TaskResultCE.fs @@ -7,10 +7,6 @@ open TestData open FsToolkit.ErrorHandling open System.Threading.Tasks -#if NETSTANDARD2_0 || NET6_0 -open FSharp.Control.Tasks -#endif - [] let ``TaskResultCE return Tests`` = @@ -103,16 +99,6 @@ let ``TaskResultCE return! Tests`` = Expect.equal actual (Result.Ok()) "Should be ok" } -#if NETSTANDARD2_0 - testCaseTask "Return Ply" - <| fun () -> - task { - let innerData = "Foo" - let! actual = taskResult { return! Unsafe.uply { return innerData } } - - Expect.equal actual (Result.Ok innerData) "Should be ok" - } -#endif ] @@ -251,21 +237,6 @@ let ``TaskResultCE bind Tests`` = Expect.equal actual (Ok()) "Should be ok" } -#if NETSTANDARD2_0 - testCaseTask "Bind Ply" - <| fun () -> - task { - let innerData = "Foo" - - let! actual = - taskResult { - let! data = Unsafe.uply { return innerData } - return data - } - - Expect.equal actual (Result.Ok innerData) "Should be ok" - } -#endif ] @@ -640,11 +611,7 @@ let ``TaskResultCE applicative tests`` = Expect.equal actual (Ok 5) "Should be ok" } let specialCaseTask returnValue = -#if NETSTANDARD2_0 - Unsafe.uply { return returnValue } -#else Task.FromResult returnValue -#endif testCaseTask "Happy Path Result/Choice/AsyncResult/Ply/ValueTask" <| fun () -> diff --git a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/paket.references b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/paket.references index 0d12decb..a57ca909 100644 --- a/tests/FsToolkit.ErrorHandling.TaskResult.Tests/paket.references +++ b/tests/FsToolkit.ErrorHandling.TaskResult.Tests/paket.references @@ -6,4 +6,3 @@ group Test YoloDev.Expecto.TestSdk Fable.Mocha Fable.Pyxpecto - Ply diff --git a/tests/FsToolkit.ErrorHandling.Tests/Expect.fs b/tests/FsToolkit.ErrorHandling.Tests/Expect.fs index 2688982b..c2571f6a 100644 --- a/tests/FsToolkit.ErrorHandling.Tests/Expect.fs +++ b/tests/FsToolkit.ErrorHandling.Tests/Expect.fs @@ -18,11 +18,6 @@ module Expect = #endif -#if NETSTANDARD2_0 || NET6_0 - open FSharp.Control.Tasks -#endif - - #if FABLE_COMPILER let isOk x message = match x with diff --git a/tests/FsToolkit.ErrorHandling.Tests/paket.references b/tests/FsToolkit.ErrorHandling.Tests/paket.references index ad4a6c5b..61c21fb8 100644 --- a/tests/FsToolkit.ErrorHandling.Tests/paket.references +++ b/tests/FsToolkit.ErrorHandling.Tests/paket.references @@ -1,6 +1,5 @@ group Test FSharp.Core - Ply Expecto Expecto.Hopac Microsoft.NET.Test.Sdk diff --git a/tools/FunctionMap/paket.references b/tools/FunctionMap/paket.references index 1b2c8d6a..6f627f42 100644 --- a/tools/FunctionMap/paket.references +++ b/tools/FunctionMap/paket.references @@ -1,2 +1 @@ -group NetStandard2_1 - FSharp.Core \ No newline at end of file +FSharp.Core