[Repo Assist] fix: correct Async.bind signature and implementation#394
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] fix: correct Async.bind signature and implementation#394github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
The previous signature was (Async<'T> -> Async<'U>) -> Async<'T> -> Async<'U>,
which passed the entire Async<'T> computation to the binder without first
awaiting it. This made the function essentially equivalent to plain function
application, not a monadic bind.
The correct signature is ('T -> Async<'U>) -> Async<'T> -> Async<'U>, matching
Task.bind (which had the same bug fixed in commit 8486e1b) and standard
monadic bind semantics.
Updated CompatibilitySuppressions.xml to suppress the CP0002 baseline-breaking
change diagnostic, since this is an intentional fix of an incorrect public API.
Added Utils.Tests.fs with tests covering the corrected behavior of
Async.bind, Task.bind, Async.map, and Task.map.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This is an automated pull request from Repo Assist, an AI assistant.
Summary
Async.bindinUtils.fshad the same bug thatTask.bindwas fixed for in commit 8486e1b: the binder function received the entireAsync<'T>wrapper rather than the awaited inner value'T.Root Cause
The previous implementation:
And its corresponding signature:
The
binderreceivedAsync<'T>— effectively makingAsync.bindequivalent to plain function application (fun binder async -> binder async), not a monadic bind. This was inconsistent withTask.bindwhich correctly hasbinder: ('T -> #Task<'U>).Fix
Both the implementation and the signature have been corrected to standard monadic bind:
Breaking Change
This changes the public API signature. The previous signature was incorrect and the function was likely never useful as published (any code using it would have needed a
fun (asyncT: Async<'T>) -> ...binder rather than the naturalfun (t: 'T) -> ...form). A suppression has been added toCompatibilitySuppressions.xml.Added Tests
Utils.Tests.fsis a new test file coveringAsync.bind,Task.bind,Async.map, andTask.map— none of which had dedicated tests before.Test Status
dotnet build -c Release— succeeded (0 warnings, 0 errors)dotnet test -c Release— 5190 passed, 2 skipped (pre-existing infrastructure skips)dotnet fantomas . --check— passed