Skip to content

[Repo Assist] feat: add TaskSeq.splitInto#327

Open
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/improve-splitinto-2026-03-10-4bfa9f8b67a1a5ed
Open

[Repo Assist] feat: add TaskSeq.splitInto#327
github-actions[bot] wants to merge 3 commits intomainfrom
repo-assist/improve-splitinto-2026-03-10-4bfa9f8b67a1a5ed

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Implements TaskSeq.splitInto, the missing analogue to Seq.splitInto — one of the remaining TODO functions in the README table.

What this does

TaskSeq.splitInto count source splits the input task sequence into at most count chunks of roughly equal size. The remainder is distributed across the leading chunks.

// 10 elements into 3 chunks → [4; 3; 3]
taskSeq { 1..10 } |> TaskSeq.splitInto 3
// yields: [|1;2;3;4|], [|5;6;7|], [|8;9;10|]

// count > length → one element per chunk
taskSeq { 1..3 } |> TaskSeq.splitInto 10
// yields: [|1|], [|2|], [|3|]

Unlike chunkBySize (which fixes chunk size), splitInto fixes the number of chunks.

Design notes

  • Validates count > 0 eagerly (before enumeration), consistent with chunkBySize.
  • Materialises the source via toResizeArrayAsync then slices the array — necessary because total element count is unknown until consumed. Same pattern as groupBy / partition.
  • Returns TaskSeq<'T[]> to match Seq.splitInto's return shape.

Changes

File Change
TaskSeqInternal.fs Add splitInto implementation
TaskSeq.fs Expose splitInto on the TaskSeq type
TaskSeq.fsi Add signature + XML doc comment
TaskSeq.SplitInto.Tests.fs 91 new tests
FSharp.Control.TaskSeq.Test.fsproj Register test file
README.md Mark splitInto as ✅
release-notes.txt Add changelog entry

Test Status

Build: dotnet build src/FSharp.Control.TaskSeq.sln -c Release — succeeded, 0 warnings, 0 errors
All tests: dotnet test4,621 passed, 2 skipped (real-world network tests), 0 failed
Formatting: dotnet fantomas . --check — clean

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

Implements TaskSeq.splitInto, the missing analogue to Seq.splitInto.
Splits the sequence into at most N chunks of roughly equal size, with
remainder elements distributed across the first chunks.

When count > length, returns one element per chunk (length chunks total).
When the source is empty, returns an empty sequence.
Validates count > 0 eagerly (before enumeration).

Internally materializes the source via toResizeArrayAsync, then slices
the resulting array – same approach as groupBy/partition, necessary
because total element count is unknown until the sequence is consumed.

- 91 new tests covering: empty, null, invalid args, split(1), split(N),
  split(> length), exact/uneven distribution, side-effect variants
- README table updated (✅)
- release-notes.txt updated

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 12, 2026 20:44
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.

1 participant