Add cancellableValueTaskOption and cancellableValueTaskResult CEs for IcedTasks#349
Conversation
… IcedTasks Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Option and Result computation expressions for CancellableValueTask<'T> to the FsToolkit.ErrorHandling.IcedTasks library, enabling ergonomic short-circuit semantics without allocating Task objects. Additionally, it registers previously unimplemented cancellableTaskOption / backgroundCancellableTaskOption CEs and fixes a nullness warning in CancellableTaskOptionCE.fs.
Changes:
- Added
cancellableValueTaskResultandbackgroundCancellableValueTaskResultCEs that inherit from the existingCancellableTaskResultBuilderBaseand useAsyncValueTaskMethodBuilder<Result<'T, 'Error>> - Added
cancellableValueTaskOptionandbackgroundCancellableValueTaskOptionCEs with self-contained state machine implementation usingAsyncValueTaskMethodBuilder<'T option> - Registered previously unimplemented
cancellableTaskOption/backgroundCancellableTaskOptionCEs by adding them to the fsproj file - Fixed FS3264 nullness warning by replacing unsafe
:?>downcast with safematch ... :?pattern inCancellableTaskOptionCE.fs
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/FsToolkit.ErrorHandling.IcedTasks/FsToolkit.ErrorHandling.IcedTasks.fsproj | Adds CancellableTaskOptionBuilderBase, CancellableTaskOptionCE, CancellableValueTaskResultCE, and CancellableValueTaskOptionCE to project compilation |
| src/FsToolkit.ErrorHandling.IcedTasks/CancellableValueTaskResultCE.fs | Implements Result CE for CancellableValueTask, inheriting from CancellableTaskResultBuilderBase with companion module functions |
| src/FsToolkit.ErrorHandling.IcedTasks/CancellableValueTaskOptionCE.fs | Implements Option CE for CancellableValueTask with self-contained state machine and companion module functions |
| src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskOptionCE.fs | Fixes nullness warning by replacing unsafe cast with safe pattern match |
| tests/FsToolkit.ErrorHandling.IcedTasks.Tests/FsToolkit.ErrorHandling.IcedTasks.Tests.fsproj | Registers new test files for CancellableTaskOptionCE, CancellableValueTaskResultCE, and CancellableValueTaskOptionCE |
| tests/FsToolkit.ErrorHandling.IcedTasks.Tests/CancellableValueTaskResultCE.fs | Comprehensive tests for CancellableValueTaskResult CE including return, bind, cancellation, and exception handling |
| tests/FsToolkit.ErrorHandling.IcedTasks.Tests/CancellableValueTaskOptionCE.fs | Comprehensive tests for CancellableValueTaskOption CE including return, bind, None short-circuit, cancellation, and exception handling |
TheAngryByrd
left a comment
There was a problem hiding this comment.
@copilot Fix comments. Make sure to add doc comments to any public method/function that missing them in this PR. Also this PR is missing gitbook documentation.
Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Fixed in 8543e47 — the |
TheAngryByrd
left a comment
There was a problem hiding this comment.
@copilot Found something else. Check for any uses of a computation expression that doesn't do any binds and make sure they return a simplier version that doesn't create state machines.
Co-authored-by: TheAngryByrd <1490044+TheAngryByrd@users.noreply.github.com>
Fixed in 3d67762. |
- [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
- [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
- [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
- [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
- [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
- [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
CancellableTaskOptionfiles into library fsprojCancellableTaskOptiontest file into tests fsprojCancellableValueTaskResultCE.fs(new source file, inherits fromCancellableTaskResultBuilderBase)CancellableValueTaskOptionCE.fs(new source file with new state machine types usingAsyncValueTaskMethodBuilder)CancellableValueTaskResultCECancellableValueTaskOptionCECancellableTaskOptionCE.fs(ICriticalNotifyCompletion downcast)BackgroundCancellableValueTaskOptionBuilderSetResult bugsometo use directfun _ -> ValueTask<'a option>(Some x)(avoids state machine creation)ReturnFromparameter label to use correct non-option BindAsync,AsyncEx, andAsyncOptionBuilderinCancellableValueTaskOptionCE.fscancellableValueTaskOption(ce, bind, apply, map, zip, either, others)cancellableValueTaskResult(index, ce, bind, apply, map, zip)SUMMARY.mdwith new documentation entriesOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.