Skip to content

Commit ed33d93

Browse files
feat: add TaskSeq.exists2, forall2, forall2Async, fold2, fold2Async (206 tests)
Implements the next batch of '2'-functions from the README roadmap: TaskSeq.exists2 : ('T -> 'U -> bool) -> TaskSeq<'T> -> TaskSeq<'U> -> Task<bool> TaskSeq.forall2 : ('T -> 'U -> bool) -> TaskSeq<'T> -> TaskSeq<'U> -> Task<bool> TaskSeq.forall2Async: ('T -> 'U -> #Task<bool>) -> TaskSeq<'T> -> TaskSeq<'U> -> Task<bool> TaskSeq.fold2 : ('S -> 'T -> 'U -> 'S) -> 'S -> TaskSeq<'T> -> TaskSeq<'U> -> Task<'S> TaskSeq.fold2Async : ('S -> 'T -> 'U -> #Task<'S>) -> 'S -> TaskSeq<'T> -> TaskSeq<'U> -> Task<'S> Semantics: stop at the shorter sequence (consistent with map2/iter2/zip). Files changed: - TaskSeqInternal.fs: exists2, forall2, forall2Async, fold2, fold2Async - TaskSeq.fs: wrapper members - TaskSeq.fsi: public signatures with XML doc - TaskSeq.Exists2Forall2Fold2.Tests.fs: 206 tests (null, empty, immutable, side-effects) - FSharp.Control.TaskSeq.Test.fsproj: new test file reference - release-notes.txt: entry under v0.6.0 - README.md: mark exists2, fold2/fold2Async, forall2/forall2Async as done Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5a03593 commit ed33d93

File tree

7 files changed

+684
-5
lines changed

7 files changed

+684
-5
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ The `TaskSeq` project already has a wide array of functions and functionalities,
214214
- [x] `chunkBySize` / `windowed` (see [#258])
215215
- [ ] `compareWith`
216216
- [ ] `distinct`
217-
- [ ] `exists2` / `map2` / `fold2` / `iter2` and related '2'-functions
217+
- [ ] `exists2` / `map2` / `iter2` and related '2'-functions (partial: `exists2`, `forall2`, `forall2Async`, `fold2`, `fold2Async` done)
218218
- [ ] `mapFold`
219219
- [x] `pairwise` (see [#293])
220220
- [ ] `allpairs` / `permute` / `distinct` / `distinctBy`
@@ -283,18 +283,18 @@ This is what has been implemented so far, is planned or skipped:
283283
| &#x2705; [#83][] | `except` | `except` | | |
284284
| &#x2705; [#83][] | | `exceptOfSeq` | | |
285285
| &#x2705; [#70][] | `exists` | `exists` | `existsAsync` | |
286-
| | `exists2` | `exists2` | | |
286+
| &#x2705; | | `exists2` | | |
287287
| &#x2705; [#23][] | `filter` | `filter` | `filterAsync` | |
288288
| &#x2705; [#23][] | `find` | `find` | `findAsync` | |
289289
| &#x1f6ab; | `findBack` | | | [note #2](#note2 "Because of the async nature of TaskSeq sequences, iterating from the back would be bad practice. Instead, materialize the sequence to a list or array and then apply the 'Back' iterators.") |
290290
| &#x2705; [#68][] | `findIndex` | `findIndex` | `findIndexAsync` | |
291291
| &#x1f6ab; | `findIndexBack` | n/a | n/a | [note #2](#note2 "Because of the async nature of TaskSeq sequences, iterating from the back would be bad practice. Instead, materialize the sequence to a list or array and then apply the 'Back' iterators.") |
292292
| &#x2705; [#2][] | `fold` | `fold` | `foldAsync` | |
293-
| | `fold2` | `fold2` | `fold2Async` | |
293+
| &#x2705; | | `fold2` | `fold2Async` | |
294294
| &#x1f6ab; | `foldBack` | | | [note #2](#note2 "Because of the async nature of TaskSeq sequences, iterating from the back would be bad practice. Instead, materialize the sequence to a list or array and then apply the 'Back' iterators.") |
295295
| &#x1f6ab; | `foldBack2` | | | [note #2](#note2 "Because of the async nature of TaskSeq sequences, iterating from the back would be bad practice. Instead, materialize the sequence to a list or array and then apply the 'Back' iterators.") |
296296
| &#x2705; [#240][]| `forall` | `forall` | `forallAsync` | |
297-
| | `forall2` | `forall2` | `forall2Async` | |
297+
| &#x2705; | | `forall2` | `forall2Async` | |
298298
| &#x2753; | `groupBy` | `groupBy` | `groupByAsync` | [note #1](#note1 "These functions require a form of pre-materializing through 'TaskSeq.cache', similar to the approach taken in the corresponding 'Seq' functions. It doesn't make much sense to have a cached async sequence. However, 'AsyncSeq' does implement these, so we'll probably do so eventually as well.") |
299299
| &#x2705; [#23][] | `head` | `head` | | |
300300
| &#x2705; [#68][] | `indexed` | `indexed` | | |

release-notes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Release notes:
1717
- adds TaskSeq.unfold and TaskSeq.unfoldAsync, #289
1818
- adds TaskSeq.chunkBySize (closes #258) and TaskSeq.windowed, #289
1919
- fixes: CancellationToken passed to GetAsyncEnumerator is now honored in MoveNextAsync, #179
20+
- adds TaskSeq.exists2, forall2, forall2Async, fold2, fold2Async
2021

2122
0.5.0
2223
- update engineering to .NET 9/10

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<Compile Include="TaskSeq.Distinct.Tests.fs" />
2424
<Compile Include="TaskSeq.Pairwise.Tests.fs" />
2525
<Compile Include="TaskSeq.Exists.Tests.fs" />
26+
<Compile Include="TaskSeq.Exists2Forall2Fold2.Tests.fs" />
2627
<Compile Include="TaskSeq.Filter.Tests.fs" />
2728
<Compile Include="TaskSeq.FindIndex.Tests.fs" />
2829
<Compile Include="TaskSeq.Find.Tests.fs" />

0 commit comments

Comments
 (0)