Skip to content

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

Merged
dsyme merged 2 commits into
mainfrom
repo-assist/refactor-splitAt-rest-while-bang-20260418-0388821e31824de0
Apr 20, 2026
Merged

[Repo Assist] refactor: simplify splitAt 'rest' taskSeq to use while!#393
dsyme merged 2 commits into
mainfrom
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:

letrest= taskSeq {let mutablego2= go
if go2 thenlet!step= e.MoveNextAsync()
go2 <- step
while go2 doyield 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):

letrest= taskSeq {if go thenwhile! e.MoveNextAsync()doyield e.Current
}

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

Correctness

Three cases:

ScenariogoCurrent behaviourNew behaviour
Source exhausted before countfalserest is emptyrest is empty (guard skips)
Source has ≥ count elementstrueAdvance past first, yield remainderwhile! does the same advance-then-yield
count = 0trueAdvance from start, yield allSame

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>
@dsyme
dsyme marked this pull request as ready for review April 20, 2026 02:30
@dsyme
dsyme merged commit bc60302 into mainApr 20, 2026
5 checks passed
@dsyme
dsyme deleted the repo-assist/refactor-splitAt-rest-while-bang-20260418-0388821e31824de0 branch April 20, 2026 02:34
Sign up for freeto 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.

1 participant

@dsyme