Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Value Task compilation flags #570

Merged
merged 1 commit into from
Nov 25, 2023
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
6 changes: 3 additions & 3 deletions src/FSharpPlus/Control/Applicative.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Apply =
#if !FABLE_COMPILER
static member ``<*>`` (f: Task<_> , x: Task<'T> , [<Optional>]_output: Task<'U> , [<Optional>]_mthd: Apply) = Task.apply f x : Task<'U>
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member ``<*>`` (f: ValueTask<_> , x: ValueTask<'T> , [<Optional>]_output: ValueTask<'U> , [<Optional>]_mthd: Apply) = ValueTask.apply f x : ValueTask<'U>
#endif
static member ``<*>`` (f: Async<_> , x: Async<'T> , [<Optional>]_output: Async<'U> , [<Optional>]_mthd: Apply) = Async.apply f x : Async<'U>
Expand Down Expand Up @@ -104,7 +104,7 @@ type Lift2 =
#if !FABLE_COMPILER
static member Lift2 (f, (x: Task<'T> , y: Task<'U> ), _mthd: Lift2) = Task.map2 f x y
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Lift2 (f, (x: ValueTask<'T> , y: ValueTask<'U> ), _mthd: Lift2) = ValueTask.map2 f x y
#endif
static member Lift2 (f, (x , y ), _mthd: Lift2) = Async.map2 f x y
Expand Down Expand Up @@ -151,7 +151,7 @@ type Lift3 =
#if !FABLE_COMPILER
static member Lift3 (f, (x: Task<'T> , y: Task<'U> , z: Task<'V> ), _mthd: Lift3) = Task.map3 f x y z
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Lift3 (f, (x: ValueTask<'T> , y: ValueTask<'U> , z: ValueTask<'V> ), _mthd: Lift3) = ValueTask.map3 f x y z
#endif
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Async.map3 f x y z
Expand Down
4 changes: 2 additions & 2 deletions src/FSharpPlus/Control/Comonad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Extract =
#if !FABLE_COMPILER
static member Extract (f: Task<'T> ) = f.Result
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Extract (f: ValueTask<'T> ) = f.Result
#endif
static member inline Invoke (x: '``Comonad<'T>``) : 'T =
Expand Down Expand Up @@ -66,7 +66,7 @@ type Extend =
tcs.Task
#endif

#if NETSTANDARD2_1 && !FABLE_COMPILER
#if (!NET45 && !NETSTANDARD2_0) && !FABLE_COMPILER
static member (=>>) (g: ValueTask<'T> , f: ValueTask<'T> -> 'U ) : ValueTask<'U> =
if g.IsCompletedSuccessfully then
try
Expand Down
6 changes: 3 additions & 3 deletions src/FSharpPlus/Control/Functor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Map =
#if !FABLE_COMPILER
static member Map ((x: Task<'T> , f: 'T->'U), _mthd: Map) = Task.map f x : Task<'U>
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Map ((x: ValueTask<'T> , f: 'T->'U), _mthd: Map) = ValueTask.map f x : ValueTask<'U>
#endif
static member Map ((x: option<_> , f: 'T->'U), _mthd: Map) = Option.map f x
Expand Down Expand Up @@ -152,7 +152,7 @@ type Unzip =
#if !FABLE_COMPILER
static member Unzip ((source: Task<'T * 'U> , _output: Task<'T> * Task<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Unzip ((source: ValueTask<'T * 'U> , _output: ValueTask<'T> * ValueTask<'U> ) , _mthd: Unzip ) = Map.Invoke fst source, Map.Invoke snd source
#endif
static member Unzip ((source: option<'T * 'U> , _output: option<'T> * option<'U> ) , _mthd: Unzip ) = Option.unzip source
Expand Down Expand Up @@ -222,7 +222,7 @@ type Zip =
#if !FABLE_COMPILER
static member Zip ((x: Task<'T> , y: Task<'U> , _output: Task<'T*'U> ), _mthd: Zip) = Task.zip x y
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Zip ((x: ValueTask<'T> , y: ValueTask<'U> , _output: ValueTask<'T*'U> ), _mthd: Zip) = ValueTask.zip x y
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/FSharpPlus/Control/Monad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Bind =
static member (>>=) (source: Task<'T> , f: 'T -> Task<'U> ) = Task.bind f source : Task<'U>
static member (>>=) (source , f: 'T -> _ ) = Nullable.bind f source : Nullable<'U>
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member (>>=) (source: ValueTask<'T> , f: 'T -> ValueTask<'U> ) = ValueTask.bind f source : ValueTask<'U>
#endif

Expand Down Expand Up @@ -83,7 +83,7 @@ type Join =
#if !FABLE_COMPILER
static member Join (x: Task<Task<_>> , [<Optional>]_output: Task<'T> , [<Optional>]_mthd: Join ) = Task.join x : Task<'T>
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Join (x: ValueTask<ValueTask<_>> , [<Optional>]_output: ValueTask<'T> , [<Optional>]_mthd: Join ) = ValueTask.join x : ValueTask<'T>
#endif
static member Join (x , [<Optional>]_output: option<'T> , [<Optional>]_mthd: Join ) = Option.flatten x : option<'T>
Expand Down Expand Up @@ -144,7 +144,7 @@ type Return =
#if !FABLE_COMPILER
static member Return (_: 'T Task , _: Return ) = fun x -> Task.FromResult x : 'T Task
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Return (_: 'T ValueTask , _: Return ) = fun (x: 'T) -> ValueTask<'T> x : 'T ValueTask
#endif
static member Return (_: option<'a> , _: Return ) = fun x -> Some x : option<'a>
Expand Down Expand Up @@ -195,7 +195,7 @@ type Delay =

#endif

#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member Delay (_mthd: Delay , x: unit-> ValueTask<_> , _ ) = x () : ValueTask<'T>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/FSharpPlus/Control/Monoid.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type Plus with
static member inline ``+`` (x: 'a Task, y: 'a Task, [<Optional>]_mthd: Plus) = Task.map2 Plus.Invoke x y
#endif

#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
type Plus with

static member inline ``+`` (x: 'a ValueTask, y: 'a ValueTask, [<Optional>]_mthd: Plus) = ValueTask.map2 Plus.Invoke x y
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpPlus/Control/Numeric.fs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ type Zero with
s.SetResult v
s.Task
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
static member inline Zero (_: ValueTask<'a>, _: Zero) : ValueTask<'a> =
let (v: 'a) = Zero.Invoke ()
ValueTask<'a>(v)
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpPlus/Extensions/ValueTask.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace FSharpPlus

#if NETSTANDARD2_1_OR_GREATER && !FABLE_COMPILER
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER

/// Additional operations on ValueTask<'T>
[<RequireQualifiedAccess>]
Expand Down
2 changes: 2 additions & 0 deletions tests/FSharpPlus.Tests/ValueTask.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace FSharpPlus.Tests

#if !NET462 && !NETSTANDARD2_0

module ValueTask =

Expand Down Expand Up @@ -114,3 +115,4 @@ module ValueTask =
let r09 = ValueTask.bind (binding true) (x1 ())
r09.AsTask().Exception.InnerExceptions |> areEquivalent [TestException "I was told to fail"]

#endif