Skip to content

Commit 7240145

Browse files
committed
Merge branch 'master' into v1.6
2 parents 5c6db4c + 547874e commit 7240145

28 files changed

+1419
-396
lines changed

.github/workflows/dotnetcore.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
name: nupkg
7171
path: ./bin/nupkg/*.nupkg
7272
- name: Push to GitHub Feed
73+
continue-on-error: true
7374
shell: bash
7475
run: |
7576
for f in ./bin/nupkg/*.nupkg
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build release package
2+
3+
env:
4+
# Stop wasting time caching packages
5+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
6+
# Disable sending usage data to Microsoft
7+
DOTNET_CLI_TELEMETRY_OPTOUT: true
8+
9+
on:
10+
push:
11+
tags: ['v**']
12+
jobs:
13+
package:
14+
runs-on: windows-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup .NET Core
21+
uses: actions/setup-dotnet@v3
22+
with:
23+
dotnet-version: |
24+
8.0.x
25+
7.0.x
26+
6.0.x
27+
- name: Restore
28+
run: git submodule update --init --recursive
29+
- name: Package
30+
run: dotnet pack build.proj
31+
- name: Upload Artifacts
32+
uses: actions/upload-artifact@v2
33+
with:
34+
name: nupkg
35+
path: ./bin/nupkg/*.nupkg
36+
- name: Push to GitHub Feed
37+
shell: bash
38+
run: |
39+
for f in ./bin/nupkg/*.nupkg
40+
do
41+
echo $f
42+
dotnet nuget push $f -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
43+
done

src/FSharpPlus/Control/Applicative.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ type Apply =
7777

7878
// End Compatibility members
7979

80-
static member ``<*>`` (struct (f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , [<Optional>]_mthd: Default2) = ValueTask.apply f x : ValueTask<'U>
80+
static member ``<*>`` (struct (f: ValueTask<_> , x: ValueTask<'T> ), _output: ValueTask<'U> , [<Optional>]_mthd: Apply) : ValueTask<'U> = ValueTask.apply f x
81+
static member ``<*>`` (struct (_: DmStruct1<_> , _: DmStruct1<'T> ), _output: DmStruct1<'U> , [<Optional>]_mthd: Apply) : DmStruct1<'U> = Unchecked.defaultof<DmStruct1<'U>>
8182
#endif
8283
static member ``<*>`` (struct (f: Async<_> , x: Async<'T> ), _output: Async<'U> , [<Optional>]_mthd: Apply) = Async.apply f x : Async<'U>
8384
static member ``<*>`` (struct (f: option<_> , x: option<'T> ), _output: option<'U> , [<Optional>]_mthd: Apply) = Option.apply f x : option<'U>

src/FSharpPlus/Control/Comonad.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ open System.Runtime.InteropServices
55
open System.Threading.Tasks
66

77
open FSharpPlus
8+
open FSharpPlus.Extensions
89
open FSharpPlus.Internals
910
#if !FABLE_COMPILER4
1011

1112
// Comonad class ----------------------------------------------------------
1213

1314
type Extract =
14-
static member Extract (x: Async<'T> ) =
15+
static member Extract (x: Async<'T>) =
1516
#if FABLE_COMPILER_3 || FABLE_COMPILER_4
1617
Async.RunSynchronously x
1718
#else
18-
Async.StartImmediateAsTask(x).Result
19+
Async.AsTask(x).Result
1920
#endif
2021
static member Extract (x: Lazy<'T> ) = x.Value
2122
static member Extract ((_: 'W, a: 'T) ) = a
@@ -66,7 +67,7 @@ type Extend =
6667
tcs.Task
6768
#endif
6869

69-
#if (!NET45 && !NETSTANDARD2_0) && !FABLE_COMPILER
70+
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
7071
static member (=>>) (g: ValueTask<'T> , f: ValueTask<'T> -> 'U ) : ValueTask<'U> =
7172
if g.IsCompletedSuccessfully then
7273
try

src/FSharpPlus/Control/Functor.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open Microsoft.FSharp.Quotations
1111
open FSharpPlus.Internals
1212
open FSharpPlus.Internals.Prelude
1313
open FSharpPlus
14+
open FSharpPlus.Extensions
1415
open FSharpPlus.Data
1516

1617
#if (!FABLE_COMPILER || FABLE_COMPILER_3) && ! FABLE_COMPILER_4
@@ -21,7 +22,7 @@ type Iterate =
2122
static member Iterate (x: Lazy<'T> , action) = action x.Value : unit
2223
static member Iterate (x: seq<'T> , action) = Seq.iter action x
2324
static member Iterate (x: option<'T> , action) = match x with Some x -> action x | _ -> ()
24-
static member Iterate (x: voption<'T> , action) = match x with ValueSome x -> action x | _ -> ()
25+
static member Iterate (x: voption<'T>, action) = match x with ValueSome x -> action x | _ -> ()
2526
static member Iterate (x: list<'T> , action) = List.iter action x
2627
static member Iterate ((_: 'W, a: 'T), action) = action a :unit
2728
static member Iterate (x: 'T [] , action) = Array.iter action x
@@ -35,10 +36,10 @@ type Iterate =
3536
for l = 0 to Array4D.length4 x - 1 do
3637
action x.[i,j,k,l]
3738
#endif
38-
#if !FABLE_COMPILER
39+
#if FABLE_COMPILER
3940
static member Iterate (x: Async<'T> , action) = action (Async.RunSynchronously x) : unit
4041
#else
41-
static member Iterate (x: Async<'T> , action) = action (x |> Async.Ignore |> Async.StartImmediate) : unit
42+
static member Iterate (x: Async<'T> , action: 'T -> unit) = (x |> Async.map action |> Async.AsTask).Wait ()
4243
#endif
4344
static member Iterate (x: Result<'T, 'E> , action) = match x with Ok x -> action x | _ -> ()
4445
static member Iterate (x: Choice<'T, 'E> , action) = match x with Choice1Of2 x -> action x | _ -> ()

src/FSharpPlus/Control/Monad.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ type Return =
146146
#endif
147147
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
148148
static member Return (_: 'T ValueTask , _: Return ) = fun (x: 'T) -> ValueTask<'T> x : 'T ValueTask
149+
static member Return (_: 'T DmStruct1 , _: Return ) = fun (_: 'T) -> Unchecked.defaultof<_> : 'T DmStruct1
149150
#endif
150151
static member Return (_: option<'a> , _: Return ) = fun x -> Some x : option<'a>
151152
static member Return (_ : voption<'a> , _: Return ) = fun x -> ValueSome x : voption<'a>

src/FSharpPlus/Control/Monoid.fs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ type Plus =
3131
#if !FABLE_COMPILER
3232
static member ``+`` (x: StringBuilder , y: StringBuilder , [<Optional>]_mthd: Plus ) = StringBuilder().Append(x).Append(y)
3333
static member ``+`` (_: Id0 , _: Id0 , [<Optional>]_mthd: Plus ) = Id0 ""
34-
static member ``+`` (x: AggregateException, y: AggregateException, [<Optional>]_mthd: Plus ) = new AggregateException (seq {yield! x.InnerExceptions; yield! y.InnerExceptions})
35-
static member ``+`` (x: exn , y: exn , [<Optional>]_mthd: Plus ) =
36-
let f (e: exn) = match e with :? AggregateException as a -> a.InnerExceptions :> seq<_> | _ -> Seq.singleton e
37-
let left = f x
38-
new AggregateException (seq { yield! left; yield! Seq.except left (f y) }) :> exn
34+
static member ``+`` (x: AggregateException, y: AggregateException, [<Optional>]_mthd: Plus ) = Exception.add x y
35+
static member ``+`` (x: exn , y: exn , [<Optional>]_mthd: Plus ) = Exception.add x y :> exn
3936
#else
4037
static member ``+`` (x: StringBuilder , y: StringBuilder , [<Optional>]_mthd: Plus ) = StringBuilder().Append(string x).Append(string y)
4138
static member ``+`` (_: Id0 , _: Id0 , [<Optional>]_mthd: Plus ) = Id0 ""

src/FSharpPlus/Control/Traversable.fs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ type Traverse =
9090
return seq {
9191
use enum = t.GetEnumerator ()
9292
while enum.MoveNext() do
93-
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) }}
93+
yield Async.AsTask(f enum.Current, cancellationToken = ct).Result }}
9494
#endif
9595

9696
#if !FABLE_COMPILER
@@ -103,7 +103,7 @@ type Traverse =
103103
return seq {
104104
use enum = t.GetEnumerator ()
105105
while enum.MoveNext() do
106-
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq.unsafeOfSeq }
106+
yield Async.AsTask(f enum.Current, cancellationToken = ct).Result } |> NonEmptySeq.unsafeOfSeq }
107107
#endif
108108

109109
static member Traverse (t: Id<'t>, f: 't -> option<'u>, [<Optional>]_output: option<Id<'u>>, [<Optional>]_impl: Traverse) =
@@ -193,26 +193,26 @@ type Sequence with
193193
static member inline Sequence (t: seq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<seq<'T>>`` , [<Optional>]_impl: Default4) : '``Applicative<seq<'T>>`` =
194194
Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, List.toSeq)
195195

196-
static member Sequence (t: seq<option<'t>> , [<Optional>]_output: option<seq<'t>> , [<Optional>]_impl: Default3) : option<seq<'t>> = Option.Sequence t
196+
static member Sequence (t: seq<option<'t>> , [<Optional>]_output: option<seq<'t>> , [<Optional>]_impl: Default3) : option<seq<'t>> = Option.Sequential t
197197
#if !FABLE_COMPILER
198-
static member Sequence (t: seq<voption<'t>> , [<Optional>]_output: voption<seq<'t>> , [<Optional>]_impl: Default3) : voption<seq<'t>> = ValueOption.Sequence t
198+
static member Sequence (t: seq<voption<'t>> , [<Optional>]_output: voption<seq<'t>> , [<Optional>]_impl: Default3) : voption<seq<'t>> = ValueOption.Sequential t
199199
#endif
200-
static member Sequence (t: seq<Result<'t,'e>>, [<Optional>]_output: Result<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<seq<'t>, 'e> = Result.Sequence t
201-
static member Sequence (t: seq<Choice<'t,'e>>, [<Optional>]_output: Choice<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<seq<'t>, 'e> = Choice.Sequence t
200+
static member Sequence (t: seq<Result<'t,'e>>, [<Optional>]_output: Result<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<seq<'t>, 'e> = Result.Sequential t
201+
static member Sequence (t: seq<Choice<'t,'e>>, [<Optional>]_output: Choice<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<seq<'t>, 'e> = Choice.Sequential t
202202
static member Sequence (t: seq<list<'t>> , [<Optional>]_output: list<seq<'t>> , [<Optional>]_impl: Default3) : list<seq<'t>> = Sequence.ForInfiniteSequences (t, List.isEmpty, List.toSeq)
203203
static member Sequence (t: seq<'t []> , [<Optional>]_output: seq<'t> [] , [<Optional>]_impl: Default3) : seq<'t> [] = Sequence.ForInfiniteSequences (t, Array.isEmpty, List.toSeq)
204204

205205
#if !FABLE_COMPILER
206-
static member Sequence (t: seq<Async<'t>> , [<Optional>]_output: Async<seq<'t>> , [<Optional>]_impl: Default3) : Async<seq<'t>> = Async.Sequence t
206+
static member Sequence (t: seq<Async<'t>> , [<Optional>]_output: Async<seq<'t>> , [<Optional>]_impl: Default3) : Async<seq<'t>> = Async.SequentialLazy t
207207
#endif
208208
static member inline Sequence (t: NonEmptySeq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<NonEmptySeq<'T>>`` , [<Optional>]_impl: Default4) : '``Applicative<NonEmptySeq<'T>>`` = Sequence.ForInfiniteSequences (t, IsLeftZero.Invoke, NonEmptySeq.ofList)
209-
static member Sequence (t: NonEmptySeq<option<'t>> , [<Optional>]_output: option<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : option<NonEmptySeq<'t>> = Option.Sequence t |> Option.map NonEmptySeq.unsafeOfSeq
210-
static member Sequence (t: NonEmptySeq<Result<'t,'e>>, [<Optional>]_output: Result<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<NonEmptySeq<'t>, 'e> = Result.Sequence t |> Result.map NonEmptySeq.unsafeOfSeq
211-
static member Sequence (t: NonEmptySeq<Choice<'t,'e>>, [<Optional>]_output: Choice<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<NonEmptySeq<'t>, 'e> = Choice.Sequence t |> Choice.map NonEmptySeq.unsafeOfSeq
209+
static member Sequence (t: NonEmptySeq<option<'t>> , [<Optional>]_output: option<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : option<NonEmptySeq<'t>> = Option.Sequential t |> Option.map NonEmptySeq.unsafeOfSeq
210+
static member Sequence (t: NonEmptySeq<Result<'t,'e>>, [<Optional>]_output: Result<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<NonEmptySeq<'t>, 'e> = Result.Sequential t |> Result.map NonEmptySeq.unsafeOfSeq
211+
static member Sequence (t: NonEmptySeq<Choice<'t,'e>>, [<Optional>]_output: Choice<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<NonEmptySeq<'t>, 'e> = Choice.Sequential t |> Choice.map NonEmptySeq.unsafeOfSeq
212212
static member Sequence (t: NonEmptySeq<list<'t>> , [<Optional>]_output: list<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : list<NonEmptySeq<'t>> = Sequence.ForInfiniteSequences(t, List.isEmpty , NonEmptySeq.ofList)
213213
static member Sequence (t: NonEmptySeq<'t []> , [<Optional>]_output: NonEmptySeq<'t> [] , [<Optional>]_impl: Default3) : NonEmptySeq<'t> [] = Sequence.ForInfiniteSequences(t, Array.isEmpty, NonEmptySeq.ofList)
214214
#if !FABLE_COMPILER
215-
static member Sequence (t: NonEmptySeq<Async<'t>> , [<Optional>]_output: Async<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) = Async.Sequence t |> Async.map NonEmptySeq.unsafeOfSeq : Async<NonEmptySeq<'t>>
215+
static member Sequence (t: NonEmptySeq<Async<'t>> , [<Optional>]_output: Async<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) = Async.SequentialLazy t |> Async.map NonEmptySeq.unsafeOfSeq : Async<NonEmptySeq<'t>>
216216
#endif
217217

218218
static member inline Sequence (t: ^a , [<Optional>]_output: 'R, [<Optional>]_impl: Default2) : 'R = Traverse.InvokeOnInstance id t
@@ -341,7 +341,7 @@ type Gather =
341341
return seq {
342342
use enum = t.GetEnumerator ()
343343
while enum.MoveNext() do
344-
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) }}
344+
yield Async.AsTask(f enum.Current, cancellationToken = ct).Result }}
345345
#endif
346346

347347
#if !FABLE_COMPILER
@@ -354,7 +354,7 @@ type Gather =
354354
return seq {
355355
use enum = t.GetEnumerator ()
356356
while enum.MoveNext() do
357-
yield Async.RunSynchronously (f enum.Current, cancellationToken = ct) } |> NonEmptySeq.unsafeOfSeq }
357+
yield Async.AsTask(f enum.Current, cancellationToken = ct).Result } |> NonEmptySeq.unsafeOfSeq }
358358
#endif
359359

360360
static member Gather (t: Id<'t>, f: 't -> option<'u>, [<Optional>]_output: option<Id<'u>>, [<Optional>]_impl: Gather) =
@@ -440,9 +440,9 @@ type Transpose with
440440
static member inline Transpose (t: seq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<seq<'T>>`` , [<Optional>]_impl: Default4) : '``Applicative<seq<'T>>`` =
441441
Transpose.ForInfiniteSequences (t, IsZipLeftZero.Invoke, List.toSeq, Pure.Invoke)
442442

443-
static member Transpose (t: seq<option<'t>> , [<Optional>]_output: option<seq<'t>> , [<Optional>]_impl: Default3) : option<seq<'t>> = Option.Sequence t
443+
static member Transpose (t: seq<option<'t>> , [<Optional>]_output: option<seq<'t>> , [<Optional>]_impl: Default3) : option<seq<'t>> = Option.Sequential t
444444
#if !FABLE_COMPILER
445-
static member Transpose (t: seq<voption<'t>> , [<Optional>]_output: voption<seq<'t>> , [<Optional>]_impl: Default3) : voption<seq<'t>> = ValueOption.Sequence t
445+
static member Transpose (t: seq<voption<'t>> , [<Optional>]_output: voption<seq<'t>> , [<Optional>]_impl: Default3) : voption<seq<'t>> = ValueOption.Sequential t
446446
#endif
447447
static member inline Transpose (t: seq<Result<'t,'e>>, [<Optional>]_output: Result<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<seq<'t>, 'e> = Result.Parallel ((++), t)
448448
static member inline Transpose (t: seq<Choice<'t,'e>>, [<Optional>]_output: Choice<seq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<seq<'t>, 'e> = Choice.Parallel ((++), t)
@@ -452,7 +452,7 @@ type Transpose with
452452
static member Transpose (t: seq<Async<'t>> , [<Optional>]_output: Async<seq<'t>> , [<Optional>]_impl: Default3) : Async<seq<'t>> = Async.Parallel t |> Async.map Array.toSeq
453453
#endif
454454
static member inline Transpose (t: NonEmptySeq<'``Applicative<'T>``>, [<Optional>]_output: '``Applicative<NonEmptySeq<'T>>``, [<Optional>]_impl: Default4) : '``Applicative<NonEmptySeq<'T>>`` = Transpose.ForInfiniteSequences (t, IsZipLeftZero.Invoke, NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>)
455-
static member Transpose (t: NonEmptySeq<option<'t>> , [<Optional>]_output: option<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : option<NonEmptySeq<'t>> = Option.Sequence t |> Option.map NonEmptySeq.unsafeOfSeq
455+
static member Transpose (t: NonEmptySeq<option<'t>> , [<Optional>]_output: option<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : option<NonEmptySeq<'t>> = Option.Sequential t |> Option.map NonEmptySeq.unsafeOfSeq
456456
static member inline Transpose (t: NonEmptySeq<Result<'t,'e>>, [<Optional>]_output: Result<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Result<NonEmptySeq<'t>, 'e> = Result.Parallel ((++), t) |> Result.map NonEmptySeq.unsafeOfSeq
457457
static member inline Transpose (t: NonEmptySeq<Choice<'t,'e>>, [<Optional>]_output: Choice<NonEmptySeq<'t>, 'e>, [<Optional>]_impl: Default3) : Choice<NonEmptySeq<'t>, 'e> = Choice.Parallel ((++), t) |> Choice.map NonEmptySeq.unsafeOfSeq
458458
static member Transpose (t: NonEmptySeq<list<'t>> , [<Optional>]_output: list<NonEmptySeq<'t>> , [<Optional>]_impl: Default3) : list<NonEmptySeq<'t>> = Transpose.ForInfiniteSequences (t, List.isEmpty , NonEmptySeq.ofList, fun _ -> Unchecked.defaultof<_>)

src/FSharpPlus/Control/ZipApplicative.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Pure =
3838
#if !FABLE_COMPILER
3939
static member Pure (_: 'T Task , _: Pure) = fun x -> Task.FromResult x : 'T Task
4040
#endif
41-
#if NETSTANDARD2_1 && !FABLE_COMPILER
41+
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
4242
static member Pure (_: 'T ValueTask , _: Pure) = fun (x: 'T) -> ValueTask<'T> x : 'T ValueTask
4343
#endif
4444
static member Pure (x: option<'a> , _: Pure) = Return.Return (x, Unchecked.defaultof<Return>)
@@ -147,7 +147,7 @@ type Map2 =
147147
#if !FABLE_COMPILER && !NET45
148148
static member Map2 (f, (x: Task<'T> , y: Task<'U> ), _mthd: Map2) = Task.map2 f x y
149149
#endif
150-
#if NETSTANDARD2_1 && !FABLE_COMPILER
150+
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
151151
static member Map2 (f, (x: ValueTask<'T> , y: ValueTask<'U> ), _mthd: Map2) = ValueTask.map2 f x y
152152
#endif
153153
static member Map2 (f, (x , y ), _mthd: Map2) = Async.map2 f x y
@@ -194,7 +194,7 @@ type Map3 =
194194
#if !FABLE_COMPILER && !NET45
195195
static member Map3 (f, (x: Task<'T> , y: Task<'U> , z: Task<'V> ), _mthd: Map3) = Task.map3 f x y z
196196
#endif
197-
#if NETSTANDARD2_1 && !FABLE_COMPILER
197+
#if !NET45 && !NETSTANDARD2_0 && !FABLE_COMPILER
198198
static member Map3 (f, (x: ValueTask<'T> , y: ValueTask<'U> , z: ValueTask<'V> ), _mthd: Map3) = ValueTask.map3 f x y z
199199
#endif
200200
static member Map3 (f, (x , y , z ), _mthd: Map3) = Async.map3 f x y z

0 commit comments

Comments
 (0)