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

Add support for ValueTask #523

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d27d7d2
First try for value task
rodriguestiago0 Nov 23, 2022
6993db9
Some code clean up
rodriguestiago0 Nov 23, 2022
7ddfc04
added one unit test and code clean up
rodriguestiago0 Nov 23, 2022
f943840
Added more unit tests
rodriguestiago0 Nov 23, 2022
98bd22c
fixed unit tests
rodriguestiago0 Nov 23, 2022
0e93581
code clean up
rodriguestiago0 Nov 23, 2022
48dd1a2
Added ValueTask Overloads
rodriguestiago0 Nov 24, 2022
56f5240
convert from task CE to backgroundTask CE
rodriguestiago0 Nov 24, 2022
b9a0712
Update to dotnet 7.0.100 sdk
rodriguestiago0 Nov 24, 2022
1df6f0a
fixed build
rodriguestiago0 Nov 24, 2022
1d59084
fixed build
rodriguestiago0 Nov 24, 2022
86de024
Revert to task CE and dotnet 6 sdk
rodriguestiago0 Nov 24, 2022
b5a8e1b
Fixed tests
rodriguestiago0 Nov 24, 2022
8974e22
Changed to backgroundTask
rodriguestiago0 Nov 24, 2022
0491d56
Update to dotnet SDK7 to use the backgroundTask CE
rodriguestiago0 Nov 24, 2022
93fbced
Updated documentarion
rodriguestiago0 Nov 24, 2022
0ee5773
Use slash instead of back slash
rodriguestiago0 Nov 24, 2022
06eaca7
Update workflow dotnet version
rodriguestiago0 Nov 24, 2022
27d7afc
Update to dotnet 7
rodriguestiago0 Nov 24, 2022
b50fb4b
Update to dotnet 7.0
rodriguestiago0 Nov 24, 2022
215b03a
Update to dotnet 7.0
rodriguestiago0 Nov 24, 2022
fed8b30
Remove DivRem for build porpuse
rodriguestiago0 Nov 25, 2022
ea57139
Trying to fix the build
rodriguestiago0 Nov 25, 2022
851d161
Update docTool to dotnet 7
rodriguestiago0 Nov 25, 2022
3e1bd63
Merge branch 'master' into rodrigues/first_try_to_add_valuetask
wallymathieu Nov 27, 2022
fa911b4
Merge changes
wallymathieu Nov 27, 2022
4f743b4
net7 only for dotnet subset of fable
wallymathieu Nov 27, 2022
7aedeac
rm subfolder global json
wallymathieu Nov 27, 2022
9c1912c
+ reference in Comonad docs
gusty Nov 28, 2022
60bc944
Syntax
gusty Nov 28, 2022
03ec920
Fix merge error and minimize diff
gusty Nov 28, 2022
5fa3f0e
Merge branch 'master' into rodrigues/first_try_to_add_valuetask
gusty Nov 28, 2022
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 .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
dotnet-version: 7.0.100
- name: Restore
run: git submodule update --init --recursive
- name: Build with dotnet
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
dotnet-version: 7.0.100
- name: Restore
run: git submodule update --init --recursive

Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Setup .NET Core 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
dotnet-version: 7.0.100
- name: Setup .NET Core 5
uses: actions/setup-dotnet@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
dotnet-version: 7.0.100
- name: Restore
run: git submodule update --init --recursive
- name: Restore tools
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.201
dotnet-version: 7.0.100
- name: Restore
run: git submodule update --init --recursive
- name: Restore tools
Expand Down
11 changes: 11 additions & 0 deletions FSharpPlus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpPlusFable.Tests", "te
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Benchmarks", "tests\benchmarks\Benchmarks.fsproj", "{EEFF08EB-8B0C-4F63-9425-4281EFF12087}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "docsTool", "docsrc\tools\docsTool.fsproj", "{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -168,6 +170,14 @@ Global
{EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable|Any CPU.Build.0 = Debug|Any CPU
{EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable3|Any CPU.ActiveCfg = Debug|Any CPU
{EEFF08EB-8B0C-4F63-9425-4281EFF12087}.Fable3|Any CPU.Build.0 = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Release|Any CPU.Build.0 = Release|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable|Any CPU.ActiveCfg = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable|Any CPU.Build.0 = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable3|Any CPU.ActiveCfg = Debug|Any CPU
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2}.Fable3|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -181,6 +191,7 @@ Global
{7A5B766E-8141-4D8A-B3EB-91422FDBDF71} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{1CCD1BFB-60E4-40AA-B534-3C5EEE5E1E83} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{EEFF08EB-8B0C-4F63-9425-4281EFF12087} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
{ACBBD11E-0746-4B9D-9CED-A90FE5824CE2} = {83F16175-43B1-4C90-A1EE-8E351C33435D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {789B5FFA-7891-4F60-831E-42C3C5ED2C51}
Expand Down
1 change: 1 addition & 0 deletions docsrc/content/abstraction-applicative.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ From F#
- ``KeyValuePair<'Key,'T>``
- ``'Monoid * 'T``
- ``Task<'T>``
- ``ValueTask<'T>``
- ``'R->'T``
- ``Expr<'T>``
- ``ResizeArray<'T>``
Expand Down
1 change: 1 addition & 0 deletions docsrc/content/abstraction-functor.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ From F#
- ``Map<'Key,'T>``
- ``'Monoid * 'T``
- ``Task<'T>``
- ``ValueTask<'T>``
- ``'R->'T``
- ``Expr<'T>``
- ``Dictionary<'Key,'T>``
Expand Down
1 change: 1 addition & 0 deletions docsrc/content/abstraction-monad.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ From F#
- ``Choice<'T,'U>``
- ``'Monoid * 'T``
- ``Task<'T>``
- ``ValueTask<'T>``
- ``'R->'T``
- ``ResizeArray<'T>``

Expand Down
1 change: 1 addition & 0 deletions docsrc/content/abstraction-monoid.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ From .Net/F#
- ``Tuple<'Monoid1* ... *'MonoidN>``
- ``'Monoid1* ... *'MonoidN``
- ``Task<'T>``
- ``ValueTask<'T>``
- ``'T->'Monoid``
- ``Async<'T>``
- ``Expr<'T>``
Expand Down
1 change: 1 addition & 0 deletions docsrc/content/abstraction-semigroup.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ From .Net/F#
- ``Tuple<*>``
- ``'T1* ... *'Tn``
- ``Task<'T>``
- ``ValueTask<'T>``
- ``'T->'Semigroup``
- ``Async<'T>``
- ``Expr<'T>``
Expand Down
8 changes: 7 additions & 1 deletion docsrc/content/extensions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,20 @@ Collections / Traversable types:
* zip, unzip,
* unionWith, union, intersectWith, intersect

Async and Tasks:
Async, Tasks and ValueTasks:
================
* [ Task ](reference/fsharpplus-task.html)
* map, map2, map3
* apply
* zip
* join
* ignore
* [ ValueTask ](reference/fsharpplus-valueTask.html)
* map, map2, map3
* apply
* zip
* join
* ignore
* [ Async ](reference/fsharpplus-async.html)
* map, map2
* zip
Expand Down
2 changes: 1 addition & 1 deletion docsrc/tools/docsTool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.200",
"version": "7.0.100",
"rollForward": "latestFeature"
},

Expand Down
2 changes: 1 addition & 1 deletion src/FSharpPlus.Docs/FSharpPlus.Docs.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<Configurations>Debug;Release;Fable</Configurations>
<Platforms>AnyCPU</Platforms>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/FSharpPlus/Control/Applicative.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ 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
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>
static member ``<*>`` (f: option<_> , x: option<'T> , [<Optional>]_output: option<'U> , [<Optional>]_mthd: Apply) = Option.apply f x : option<'U>
static member ``<*>`` (f: Result<_,'E> , x: Result<'T,'E> , [<Optional>]_output: Result<'b,'E> , [<Optional>]_mthd: Apply) = Result.apply f x : Result<'U,'E>
Expand Down Expand Up @@ -81,6 +84,9 @@ 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
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
static member Lift2 (f, (x , y ), _mthd: Lift2) = Option.map2 f x y
static member Lift2 (f, (x: Result<'T,'Error> , y: Result<'U,'Error> ), _mthd: Lift2) = Result.map2 f x y
Expand Down Expand Up @@ -119,6 +125,9 @@ 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
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
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Option.map3 f x y z
static member Lift3 (f, (x: Result<'T,'Error> , y: Result<'U,'Error> , z: Result<'V, 'Error> ), _mthd: Lift3) = Result.map3 f x y z
Expand Down
11 changes: 11 additions & 0 deletions src/FSharpPlus/Control/Comonad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Extract =
#if !FABLE_COMPILER
static member Extract (f: Task<'T> ) = f.Result
#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
static member Extract (f: ValueTask<'T> ) = f.Result
#endif
static member inline Invoke (x: '``Comonad<'T>``) : 'T =
let inline call_2 (_mthd: ^M, x: ^I) = ((^M or ^I) : (static member Extract : _ -> _) x)
call_2 (Unchecked.defaultof<Extract>, x)
Expand Down Expand Up @@ -57,6 +60,14 @@ type Extend =
elif k.Status = TaskStatus.Canceled then tcs.SetCanceled ()
elif k.Status = TaskStatus.Faulted then tcs.SetException k.Exception.InnerExceptions) |> ignore
tcs.Task


#endif
#if NETSTANDARD2_1 && !FABLE_COMPILER
static member (=>>) (g: ValueTask<'T> , f: ValueTask<'T> -> 'U ) : ValueTask<'U> =
backgroundTask {
return! f g
} |> ValueTask<'U>
#endif

// Restricted Comonads
Expand Down
9 changes: 9 additions & 0 deletions src/FSharpPlus/Control/Functor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ 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
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
static member Map ((x: list<_> , f: 'T->'U), _mthd: Map) = List.map f x : list<'U>
static member Map ((g: 'R->'T , f: 'T->'U), _mthd: Map) = (>>) g f
Expand Down Expand Up @@ -144,6 +147,9 @@ 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
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

static member Unzip ((source: list<'T * 'U> , _output: list<'T> * list<'U> ) , _mthd: Unzip ) = List.unzip source
Expand Down Expand Up @@ -208,6 +214,9 @@ 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
static member Zip ((x: ValueTask<'T> , y: ValueTask<'U> , _output: ValueTask<'T*'U> ), _mthd: Zip) = ValueTask.zip x y
#endif

static member inline Invoke (source1: '``ZipFunctor<'T1>``) (source2: '``ZipFunctor<'T2>``) =
let inline call_4 (a: ^a, b: ^b, c: ^c, d: ^d) = ((^a or ^b or ^c or ^d) : (static member Zip : (_*_*_)*_ -> _) (b, c, d), a)
Expand Down
Loading