Skip to content

[Repo Assist] refactor: simplify splitAt 'rest' taskSeq to use while!#393

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/refactor-splitAt-rest-while-bang-20260418-0388821e31824de0
Draft

[Repo Assist] refactor: simplify splitAt 'rest' taskSeq to use while!#393
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/refactor-splitAt-rest-while-bang-20260418-0388821e31824de0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant.

Summary

The rest sequence produced by TaskSeq.splitAt used a manual go2 flag and an explicit MoveNextAsync pre-advance before its inner loop:

let rest = taskSeq {
    let mutable go2 = go

    if go2 then
        let! step = e.MoveNextAsync()
        go2 <- step

    while go2 do
        yield e.Current
        let! step = e.MoveNextAsync()
        go2 <- step
}

This is equivalent to a single while! e.MoveNextAsync() do guarded by the existing outer go flag (which already tracks whether the source was exhausted while filling first):

let rest = taskSeq {
    if go then
        while! e.MoveNextAsync() do
            yield e.Current
}

This follows the same while! idiom used throughout the codebase (e.g. tryTail, tryLast, lengthBy).

Correctness

Three cases:

Scenario go Current behaviour New behaviour
Source exhausted before count false rest is empty rest is empty (guard skips)
Source has ≥ count elements true Advance past first, yield remainder while! does the same advance-then-yield
count = 0 true Advance from start, yield all Same

Test Status

  • Build: ✅ dotnet build -c Release — succeeded (0 warnings, 0 errors)
  • Tests: ✅ dotnet test -c Release — 5180 passed, 2 skipped (pre-existing infrastructure skips)
  • Format: ✅ dotnet fantomas . --check — passed

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

The 'rest' sequence returned by splitAt used a manual go2 flag and an
explicit MoveNextAsync pre-advance before its loop.  This is equivalent
to a direct 'while! e.MoveNextAsync() do yield e.Current' guarded by
the existing 'go' flag (which tracks whether the source was exhausted
while filling 'first').

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants