Skip to content

Commit a2ef397

Browse files
committed
Rename TaskSeq.toSeqCached -> toSeq and remove TaskSeq.toSeqCachedAsync, which simply didn't make much sense
1 parent e721d51 commit a2ef397

12 files changed

+63
-63
lines changed

src/FSharp.Control.TaskSeq.Test/TaskSeq.Append.Tests.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ open System.Collections.Generic
1717

1818
let validateSequence ts =
1919
ts
20-
|> TaskSeq.toSeqCachedAsync
21-
|> Task.map (Seq.map string)
20+
|> TaskSeq.toListAsync
21+
|> Task.map (List.map string)
2222
|> Task.map (String.concat "")
2323
|> Task.map (should equal "1234567891012345678910")
2424

src/FSharp.Control.TaskSeq.Test/TaskSeq.Cast.Tests.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ open FSharp.Control
1717
/// Asserts that a sequence contains the char values 'A'..'J'.
1818
let validateSequence ts =
1919
ts
20-
|> TaskSeq.toSeqCachedAsync
21-
|> Task.map (Seq.map string)
20+
|> TaskSeq.toListAsync
21+
|> Task.map (List.map string)
2222
|> Task.map (String.concat "")
2323
|> Task.map (should equal "12345678910")
2424

src/FSharp.Control.TaskSeq.Test/TaskSeq.Collect.Tests.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ module Immutable =
102102

103103
let validateSequence ts =
104104
ts
105-
|> TaskSeq.toSeqCachedAsync
106-
|> Task.map (Seq.map string)
105+
|> TaskSeq.toListAsync
106+
|> Task.map (List.map string)
107107
|> Task.map (String.concat "")
108108
|> Task.map (should equal "ABBCCDDEEFFGGHHIIJJK")
109109

src/FSharp.Control.TaskSeq.Test/TaskSeq.Concat.Tests.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ open System.Collections.Generic
1515

1616
let validateSequence ts =
1717
ts
18-
|> TaskSeq.toSeqCachedAsync
19-
|> Task.map (Seq.map string)
18+
|> TaskSeq.toListAsync
19+
|> Task.map (List.map string)
2020
|> Task.map (String.concat "")
2121
|> Task.map (should equal "123456789101234567891012345678910")
2222

src/FSharp.Control.TaskSeq.Test/TaskSeq.Delay.Tests.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ open System.Collections.Generic
1515

1616
let validateSequence ts =
1717
ts
18-
|> TaskSeq.toSeqCachedAsync
19-
|> Task.map (Seq.map string)
18+
|> TaskSeq.toListAsync
19+
|> Task.map (List.map string)
2020
|> Task.map (String.concat "")
2121
|> Task.map (should equal "12345678910")
2222

src/FSharp.Control.TaskSeq.Test/TaskSeq.Empty.Tests.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open FSharp.Control
1010

1111
[<Fact>]
1212
let ``TaskSeq-empty returns an empty sequence`` () = task {
13-
let! sq = TaskSeq.empty<string> |> TaskSeq.toSeqCachedAsync
13+
let! sq = TaskSeq.empty<string> |> TaskSeq.toListAsync
1414
Seq.isEmpty sq |> should be True
1515
Seq.length sq |> should equal 0
1616
}

src/FSharp.Control.TaskSeq.Test/TaskSeq.Map.Tests.fs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ open FSharp.Control
1616
/// Asserts that a sequence contains the char values 'A'..'J'.
1717
let validateSequence ts =
1818
ts
19-
|> TaskSeq.toSeqCachedAsync
20-
|> Task.map (Seq.map string)
19+
|> TaskSeq.toListAsync
20+
|> Task.map (List.map string)
2121
|> Task.map (String.concat "")
2222
|> Task.map (should equal "ABCDEFGHIJ")
2323

@@ -29,8 +29,8 @@ let validateSequenceWithOffset offset ts =
2929
|> String.concat ""
3030

3131
ts
32-
|> TaskSeq.toSeqCachedAsync
33-
|> Task.map (Seq.map string)
32+
|> TaskSeq.toListAsync
33+
|> Task.map (List.map string)
3434
|> Task.map (String.concat "")
3535
|> Task.map (should equal expected)
3636

src/FSharp.Control.TaskSeq.Test/TaskSeq.ToXXX.Tests.fs

+4-27
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ module EmptySeq =
3535
results |> should be Empty
3636
}
3737

38-
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
39-
let ``TaskSeq-toSeqCachedAsync with empty`` variant = task {
40-
let tq = Gen.getEmptyVariant variant
41-
let! (results: seq<_>) = tq |> TaskSeq.toSeqCachedAsync
42-
results |> Seq.toArray |> should be Empty
43-
}
44-
4538
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
4639
let ``TaskSeq-toIListAsync with empty`` variant = task {
4740
let tq = Gen.getEmptyVariant variant
@@ -71,7 +64,7 @@ module EmptySeq =
7164
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
7265
let ``TaskSeq-toSeqCached with empty`` variant =
7366
let tq = Gen.getEmptyVariant variant
74-
let (results: seq<_>) = tq |> TaskSeq.toSeqCached
67+
let (results: seq<_>) = tq |> TaskSeq.toSeq
7568
results |> Seq.toArray |> should be Empty
7669

7770
module Immutable =
@@ -90,13 +83,6 @@ module Immutable =
9083
results |> should equal [ 1..10 ]
9184
}
9285

93-
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
94-
let ``TaskSeq-toSeqCachedAsync should succeed`` variant = task {
95-
let tq = Gen.getSeqImmutable variant
96-
let! (results: seq<_>) = tq |> TaskSeq.toSeqCachedAsync
97-
results |> Seq.toArray |> should equal [| 1..10 |]
98-
}
99-
10086
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
10187
let ``TaskSeq-toIListAsync should succeed`` variant = task {
10288
let tq = Gen.getSeqImmutable variant
@@ -126,7 +112,7 @@ module Immutable =
126112
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
127113
let ``TaskSeq-toSeqCached should succeed and be blocking`` variant =
128114
let tq = Gen.getSeqImmutable variant
129-
let (results: seq<_>) = tq |> TaskSeq.toSeqCached
115+
let (results: seq<_>) = tq |> TaskSeq.toSeq
130116
results |> Seq.toArray |> should equal [| 1..10 |]
131117

132118

@@ -159,15 +145,6 @@ module SideEffects =
159145
results2 |> should equal [ 11..20 ]
160146
}
161147

162-
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
163-
let ``TaskSeq-toSeqCachedAsync should execute side effects multiple times`` variant = task {
164-
let tq = Gen.getSeqWithSideEffect variant
165-
let! (results1: seq<_>) = tq |> TaskSeq.toSeqCachedAsync
166-
let! (results2: seq<_>) = tq |> TaskSeq.toSeqCachedAsync
167-
results1 |> Seq.toArray |> should equal [| 1..10 |]
168-
results2 |> Seq.toArray |> should equal [| 11..20 |]
169-
}
170-
171148
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
172149
let ``TaskSeq-toIListAsync should execute side effects multiple times`` variant = task {
173150
let tq = Gen.getSeqWithSideEffect variant
@@ -205,7 +182,7 @@ module SideEffects =
205182
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
206183
let ``TaskSeq-toSeqCached should execute side effects multiple times`` variant =
207184
let tq = Gen.getSeqWithSideEffect variant
208-
let (results1: seq<_>) = tq |> TaskSeq.toSeqCached
209-
let (results2: seq<_>) = tq |> TaskSeq.toSeqCached
185+
let (results1: seq<_>) = tq |> TaskSeq.toSeq
186+
let (results2: seq<_>) = tq |> TaskSeq.toSeq
210187
results1 |> Seq.toArray |> should equal [| 1..10 |]
211188
results2 |> Seq.toArray |> should equal [| 11..20 |]

src/FSharp.Control.TaskSeq.Test/TestUtils.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =
138138
module TestUtils =
139139
let verifyEmpty ts =
140140
ts
141-
|> TaskSeq.toSeqCachedAsync
142-
|> Task.map (Seq.isEmpty >> should be True)
141+
|> TaskSeq.toArrayAsync
142+
|> Task.map (Array.isEmpty >> should be True)
143143

144144
/// Delays (no spin-wait!) between 20 and 70ms, assuming a 15.6ms resolution clock
145145
let longDelay () = task { do! Task.Delay(Random().Next(20, 70)) }

src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj

+31-10
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
<Title>Computation expression 'taskSeq' for processing IAsyncEnumerable sequences and module functions</Title>
99
<Version>$(Version)</Version>
1010
<Authors>Abel Braaksma; Don Syme</Authors>
11-
<Description>Provides the 'taskSeq' computation expression to support performance and statially optimized async sequences using the new F# 6.0 resumable state machines, similar to 'task'.
11+
<Description>This library brings C#'s concept of 'await foreach' to F#.
1212

13-
This library brings C#'s concept of 'await foreach' to F#.</Description>
13+
The 'taskSeq' computation expression adds support for awaitable asyncronous sequences with a similar ease of use and performance as F#'s 'task' CE. TaskSeq brings 'seq' and 'task' together in a safe way.
14+
15+
Generates optimized IL code and comes with a comprehensive set of module functions. See README for more info.</Description>
1416
<Copyright>Copyright 2022</Copyright>
1517
<PackageProjectUrl>https://github.com/fsprojects/FSharp.Control.TaskSeq</PackageProjectUrl>
1618
<RepositoryUrl>https://github.com/fsprojects/FSharp.Control.TaskSeq</RepositoryUrl>
@@ -20,20 +22,39 @@ This library brings C#'s concept of 'await foreach' to F#.</Description>
2022
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
2123
<PackageReadmeFile>nuget-package-readme.md</PackageReadmeFile>
2224
<PackageReleaseNotes>
23-
v.0.2
24-
- moved from NET 6.0, to NetStandard 2.1 for greater compatibility, no functional changes
25-
- move to minimally necessary FSharp.Core version: 6.0.2
26-
- updated readme with progress overview, corrected meta info, added release notes
27-
v.0.1.1
28-
- updated meta info in nuget package and added readme
29-
v.0.1
25+
Release notes:
26+
0.2.2
27+
- removes TaskSeq.toSeqCachedAsync, which was incorrectly named. Use toSeq or toListAsync instead.
28+
- renames TaskSeq.toSeqCached to TaskSeq.toSeq, which was its actual operational behavior.
29+
0.2.1
30+
- fixes an issue with ValueTask on completed iterations.
31+
- adds `TaskSeq.except` and `TaskSeq.exceptOfSeq` async set operations.
32+
0.2
33+
- moved from NET 6.0, to NetStandard 2.1 for greater compatibility, no functional changes.
34+
- move to minimally necessary FSharp.Core version: 6.0.2.
35+
- updated readme with progress overview, corrected meta info, added release notes.
36+
0.1.1
37+
- updated meta info in nuget package and added readme.
38+
0.1
3039
- initial release
40+
- implements taskSeq CE using resumable state machines
41+
- with support for: yield, yield!, let, let!, while, for, try-with, try-finally, use, use!
42+
- and: tasks and valuetasks
43+
- adds toXXX / ofXXX functions
44+
- adds map/mapi/fold/iter/iteri/collect etc with async variants
45+
- adds find/pick/choose/filter etc with async variants and 'try' variants
46+
- adds cast/concat/append/prepend/delay/exactlyOne
47+
- adds empty/isEmpty
48+
- adds findIndex/indexed/init/initInfinite
49+
- adds head/last/tryHead/tryLast/tail/tryTail
50+
- adds zip/length
51+
3152
</PackageReleaseNotes>
3253
</PropertyGroup>
3354

3455
<ItemGroup>
3556
<Content Include="..\..\assets\TaskSeq.ico" Link="TaskSeq.ico" />
36-
<None Include="..\..\taskseq-icon.png">
57+
<None Include="..\..\assets\taskseq-icon.png">
3758
<Pack>True</Pack>
3859
<PackagePath>\</PackagePath>
3960
</None>

src/FSharp.Control.TaskSeq/TaskSeq.fs

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module TaskSeq =
4646
e.DisposeAsync().AsTask().Wait()
4747
|]
4848

49-
let toSeqCached (source: taskSeq<'T>) = seq {
49+
let toSeq (source: taskSeq<'T>) = seq {
5050
let e = source.GetAsyncEnumerator(CancellationToken())
5151

5252
try
@@ -66,8 +66,6 @@ module TaskSeq =
6666

6767
let toIListAsync source = Internal.toResizeArrayAndMapAsync (fun x -> x :> IList<_>) source
6868

69-
let toSeqCachedAsync source = Internal.toResizeArrayAndMapAsync (fun x -> x :> seq<_>) source
70-
7169
//
7270
// Convert 'OfXXX' functions
7371
//

src/FSharp.Control.TaskSeq/TaskSeq.fsi

+10-6
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,16 @@ module TaskSeq =
154154
/// Returns taskSeq as an array. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
155155
val toArray: source: taskSeq<'T> -> 'T[]
156156

157-
/// Returns taskSeq as a seq, similar to Seq.cached. This function is blocking until the sequence is exhausted and will properly dispose of the resources.
158-
val toSeqCached: source: taskSeq<'T> -> seq<'T>
157+
/// <summary>
158+
/// Returns the task sequence <paramref name="source" /> as an F# <see cref="seq" />, that is, an
159+
/// <see cref="IEnumerable&lt;'T>" />. This function is blocking at each <see cref="yield" />, but otherwise
160+
/// acts as a normal delay-executed sequence.
161+
/// It will then dispose of the resources.
162+
/// </summary>
163+
///
164+
/// <param name="source">The input task sequence.</param>
165+
/// <returns>The resulting task sequence.</returns>
166+
val toSeq: source: taskSeq<'T> -> seq<'T>
159167

160168
/// Unwraps the taskSeq as a Task<array<_>>. This function is non-blocking.
161169
val toArrayAsync: source: taskSeq<'T> -> Task<'T[]>
@@ -169,10 +177,6 @@ module TaskSeq =
169177
/// Unwraps the taskSeq as a Task<IList<_>>. This function is non-blocking.
170178
val toIListAsync: source: taskSeq<'T> -> Task<IList<'T>>
171179

172-
/// Unwraps the taskSeq as a Task<seq<_>>. This function is non-blocking,
173-
/// exhausts the sequence and caches the results of the tasks in the sequence.
174-
val toSeqCachedAsync: source: taskSeq<'T> -> Task<seq<'T>>
175-
176180
/// Create a taskSeq of an array.
177181
val ofArray: source: 'T[] -> taskSeq<'T>
178182

0 commit comments

Comments
 (0)