Add IAsyncEnumerable support to task computation expressions#347
Merged
Conversation
…n, taskValueOption CEs Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for IAsyncEnumerable in computation expressions
Add IAsyncEnumerable support to task computation expressions
Feb 24, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds IAsyncEnumerable<T> support to task-based computation expressions, enabling for .. in .. iteration over async sequences with early exit on error/None conditions.
Changes:
- Implemented
WhileAsyncandFor(#IAsyncEnumerable<'T>)methods in core builder base classes - Added
Source(#IAsyncEnumerable<_>)extension methods in separate auto-open modules to avoid CLR signature conflicts - Added test helper
toAsyncEnumerableand comprehensive tests for all affected builders
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/FsToolkit.ErrorHandling.Tests/TestHelpers.fs | Added toAsyncEnumerable helper to create test IAsyncEnumerable<T> instances from lists |
| tests/FsToolkit.ErrorHandling.Tests/TaskValueOptionCE.fs | Added tests for IAsyncEnumerable iteration in taskValueOption with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/TaskValidationCE.fs | Added tests for IAsyncEnumerable iteration in taskValidation with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/TaskResultCE.fs | Added tests for IAsyncEnumerable iteration in taskResult with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/TaskOptionCE.fs | Added tests for IAsyncEnumerable iteration in taskOption with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/BackgroundTaskValueOptionCE.fs | Added tests for IAsyncEnumerable iteration in backgroundTaskValueOption with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/BackgroundTaskResultCE.fs | Added tests for IAsyncEnumerable iteration in backgroundTaskResult with happy path and early exit scenarios |
| tests/FsToolkit.ErrorHandling.Tests/BackgroundTaskOptionCE.fs | Added tests for IAsyncEnumerable iteration in backgroundTaskOption with happy path and early exit scenarios |
| src/FsToolkit.ErrorHandling/TaskValueOptionCE.fs | Implemented WhileAsync, For(#IAsyncEnumerable<'T>), and Source extension for TaskValueOptionBuilderBase |
| src/FsToolkit.ErrorHandling/TaskValidationCE.fs | Implemented WhileAsync, For(#IAsyncEnumerable<'T>), and Source extension for TaskValidationBuilderBase |
| src/FsToolkit.ErrorHandling/TaskResultCE.fs | Implemented WhileAsync, For(#IAsyncEnumerable<'T>), and Source extension for TaskResultBuilderBase |
| src/FsToolkit.ErrorHandling/TaskOptionCE.fs | Implemented WhileAsync, For(#IAsyncEnumerable<'T>), and Source extension for TaskOptionBuilderBase |
Collaborator
|
@copilot open a new PR and create gitbook docs to show off this new feature |
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot Remove AutoGPT subproject reference
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot Remove AutoGPT subproject reference
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot
TheAngryByrd
added a commit
that referenced
this pull request
Feb 27, 2026
- [Add IAsyncEnumerable support to task computation expressions](#347) Credits @Copilot - [Add `valueTaskValueOption` CE for `ValueTask<'T voption>` computation expressions](#348) Credits @Copilot - [Add `cancellableValueTaskOption` and `cancellableValueTaskResult` CEs for IcedTasks](#349) Credits @Copilot - [Add `Source` overloads to `taskResultOption` CE for interop with `Result`, `TaskResult`, `Option`, `Task`, and `Async`](#351) Credits @Copilot - [Add `requireSomeWith` and `requireNoneWith` for lazy error evaluation](#352) Credits @Copilot - [Add `TaskResult.ofCatchTask`](#353) Credits @Copilot - [Add comprehensive gitbook documentation for all public API surface](#354) Credits @Copilot Remove AutoGPT subproject reference
This was referenced Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task-based computation expressions (
taskResult,taskOption,taskValidation,taskValueOption, and theirbackgroundTask*variants) did not supportfor .. in ..iteration overIAsyncEnumerable<T>sequences.Changes
Core builders (
TaskResultCE.fs,TaskOptionCE.fs,TaskValidationCE.fs,TaskValueOptionCE.fs)WhileAsync— async condition loop that awaitsValueTask<bool>before each iteration; built onthis.While(notResumableCode.While) so error/None short-circuit stops the loop without an extraMoveNextAsync()call. Implements both the static state machine (__useResumableCode) and dynamic paths.For(#IAsyncEnumerable<'T>)— usesthis.Usingfor async disposal of the enumerator +WhileAsyncwithe.MoveNextAsync().Source(#IAsyncEnumerable<_>)— added in a separate[<AutoOpen>]extension module to avoid CLR signature conflicts with the existingSource(#seq<_>)method (both compile to the same generic signature on the same type).backgroundTask*builders inherit from these base classes and gain support automatically.Tests
TestHelpers.toAsyncEnumerable— minimalIAsyncEnumerable<T>wrapper over a list for test use.Example
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.