Commit 5c79074
refactor: replace FoldStep DU with foldWhile predicate+folder API
Reworks the early-termination fold added in 7bde226 to match the
conventions of FSharp.Control.TaskSeq: bool-returning predicate + plain
folder, and no new public DU. Every other early-termination API in the
library (takeWhile, skipWhile, tryFind, forall, exists) uses this
shape; every DU in the source is internal. FoldStep<'State> would have
been the only public DU, which is the inconsistency @dsyme flagged on
the PR.
API:
- TaskSeq.foldWhile : ('State -> 'T -> bool)
-> ('State -> 'T -> 'State)
-> 'State -> TaskSeq<'T> -> Task<'State>
- TaskSeq.foldWhileAsync : ('State -> 'T -> #Task<bool>)
-> ('State -> 'T -> #Task<'State>)
-> 'State -> TaskSeq<'T> -> Task<'State>
Semantics (match takeWhile, exclusive): the predicate is evaluated
against (currentState, nextElement) before that element is folded. If
false, iteration halts without folding that element and the source is
not enumerated further.
Removes:
- public FoldStep<'State> DU
- internal FoldUntilAction DU
- TaskSeq.foldUntil / foldUntilAsync
Tests: rewritten for exclusive semantics (halting element not folded,
predicate-call / folder-call counts asserted separately).
Full test suite green (5277 passed).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7bde226 commit 5c79074
File tree
7 files changed
+333
-284
lines changed- src
- FSharp.Control.TaskSeq.Test
- FSharp.Control.TaskSeq
7 files changed
+333
-284
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 0 additions & 226 deletions
This file was deleted.
0 commit comments