Skip to content

[Repo Assist] Add AsyncSeq.removeAt, updateAt, insertAt — 3 new Seq-mirroring combinators#268

Merged
dsyme merged 3 commits intomainfrom
repo-assist/improve-insertat-removeat-updateat-b05e62031b4bf94b
Mar 7, 2026
Merged

[Repo Assist] Add AsyncSeq.removeAt, updateAt, insertAt — 3 new Seq-mirroring combinators#268
dsyme merged 3 commits intomainfrom
repo-assist/improve-insertat-removeat-updateat-b05e62031b4bf94b

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 6, 2026

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

Summary

Adds three combinators that mirror the F# 6.0 Seq module additions:

val removeAt : index:int -> source:AsyncSeq<'T> -> AsyncSeq<'T>
val updateAt : index:int -> value:'T -> source:AsyncSeq<'T> -> AsyncSeq<'T>
val insertAt : index:int -> value:'T -> source:AsyncSeq<'T> -> AsyncSeq<'T>

AsyncSeq.removeAt

Returns a new sequence with the element at position index omitted:

AsyncSeq.ofSeq [1; 2; 3; 4] |> AsyncSeq.removeAt 1 // → [1; 3; 4]

AsyncSeq.updateAt

Returns a new sequence with the element at position index replaced:

AsyncSeq.ofSeq [1; 2; 3] |> AsyncSeq.updateAt 1 99 // → [1; 99; 3]

AsyncSeq.insertAt

Returns a new sequence with value inserted before position index (appends when index = length):

AsyncSeq.ofSeq [1; 2; 4] |> AsyncSeq.insertAt 2 3 // → [1; 2; 3; 4]
AsyncSeq.ofSeq [1; 2; 3] |> AsyncSeq.insertAt 3 4 // → [1; 2; 3; 4]
```

## Error Handling

All three raise `ArgumentException` for negative indices. `insertAt` additionally raises `ArgumentException` when the index exceeds the sequence length (matching `Seq.insertAt` semantics).

## Implementation Notes

- All three are implemented as `asyncSeq { for x in source do}` generators — clean, single-pass, lazy.
- Placed immediately after `AsyncSeq.except` in `AsyncSeq.fs`, adjacent to other element-manipulation combinators.
- Signatures added to `AsyncSeq.fsi`.
- `RELEASE_NOTES.md` updated with a 4.7.0 entry.
- `version.props` bumped to 4.7.0.

## Test Status

✅ All **301 tests pass** (287 pre-existing + **14 new tests**):

```
Passed!  - Failed: 0, Passed: 301, Skipped: 0, Total: 301

New tests cover: normal operation, boundary cases (index 0, index = last, index = length), empty source, negative index, and out-of-bounds index.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@10f087607af87e4e89439161f1e5d4724235f396

These three F# 6.0 Seq-mirroring combinators enable in-place mutation-style
operations on async sequences:

- removeAt: skip the element at the given index
- updateAt: replace the element at the given index with a new value
- insertAt: insert a value before the element at the given index
           (or append when index == length)

All three raise ArgumentException for negative indices. insertAt also
raises ArgumentException when index exceeds the sequence length.

14 new tests added; 301/301 pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 7, 2026 19:00
@dsyme dsyme merged commit efa9e4c into main Mar 7, 2026
1 check passed
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