Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 6, 2025

Summary

Addresses #76257adf by enhancing the documentation for the and! keyword to explicitly explain applicative computation expressions.

Issue

The computation expressions documentation mentioned the and! keyword but did not explain its role in enabling applicative computation expressions, a feature introduced in F# 5. Users were unaware that and! provides a different computational model from the standard monadic approach, with specific performance benefits and restrictions.

Changes

Enhanced the and! section in docs/fsharp/language-reference/computation-expressions.md to include:

  1. Explicit mention of applicative computation expressions: The section now clearly states that and! enables applicative CEs, which provide a different computational model from the standard monadic approach.

  2. Clear explanation of benefits: The documentation now lists the advantages of using and! for independent computations:

    • Execute computations more efficiently
    • Potentially run computations in parallel
    • Accumulate results without forcing unnecessary sequential dependencies
  3. Clarified the difference from let!: The updated text explains that let! ... let! ... forces sequential execution where each bind depends on the previous one, while let! ... and! ... indicates computations are independent.

  4. Documented the restriction: Added explanation that computations combined with and! cannot depend on the results of previously bound values within the same chain, clarifying the trade-off for the performance benefits.

  5. Added references: Included links to the Applicative Computation Expressions in F# 5 documentation and F# RFC FS-1063 for readers who want more detailed information.

Example

The documentation now helps readers understand the difference:

// Sequential with let! - each depends on previous
async {
    let! data1 = fetch url1
    let! data2 = fetch url2  // Waits for data1 to complete
    ...
}

// Independent with and! - can be executed in parallel
async {
    let! data1 = fetch url1
    and! data2 = fetch url2  // Can run concurrently with data1
    ...
}

This change ensures developers understand when and why to use and! for more efficient computation expressions.

Closes #76257adf-38fc-4ff9-8868-3e87efe532f4

Original prompt

This section details on the original issue you should resolve

<issue_title>Computational expression docs should mention applicative "and!"</issue_title>
<issue_description>As of F# 5, computational expressions now support applicative behavior via and!. However, this is not mentioned in the documentation for computational expressions.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)

Fixes #26017

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/computation-expressions.md docs/fsharp/language-reference/computation-expressions

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Oct 6, 2025
@Copilot Copilot AI changed the title [WIP] Computational expression docs should mention applicative "and!" Document applicative computation expressions with and! keyword Oct 6, 2025
@Copilot Copilot AI requested a review from BillWagner October 6, 2025 15:03
Copilot finished work on behalf of BillWagner October 6, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fsharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Computational expression docs should mention applicative "and!"
2 participants