Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 25, 2025

Fixes #7fabd101 (hypothetical issue reference based on the problem statement)

The syntax section of the discriminated unions documentation was missing an important detail: the first pipe character (|) is optional, particularly for single-case discriminated unions. This omission made it unclear that syntax like type X = Y of Z is valid.

Before:
The syntax section only showed the full syntax with pipe characters, leaving readers uncertain whether forms like type Address = Address of string were correct.

After:
Added explicit clarification that the first pipe character is optional, with a clear example:

type SingleCase = Case of string

This change ensures readers understand that both of these forms are valid:

  • type Address = | Address of string (with pipe)
  • type Address = Address of string (without pipe - commonly used for single-case DUs)

The addition is consistent with examples found throughout the F# documentation and aligns with the F# style guide recommendation to omit the leading pipe for single short unions.

Original prompt

This section details on the original issue you should resolve

<issue_title>Discriminated union syntax: Should mention that the 1st pipe character is optional</issue_title>
<issue_description>In the Syntax section at the beginning, it is important to state that the first 1st pipe character is optional.
Otherwise, it is not clear that "type X = Y of Z" is valid syntax for defining a single-case discriminated union.


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 #21971

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/discriminated-unions.md docs/fsharp/language-reference/discriminated-unions

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Sep 25, 2025
…n syntax

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Discriminated union syntax: Should mention that the 1st pipe character is optional Clarify that first pipe character is optional in discriminated union syntax Sep 25, 2025
Copilot finished work on behalf of BillWagner September 25, 2025 14:55
@Copilot Copilot AI requested a review from BillWagner September 25, 2025 14:55
@BillWagner BillWagner marked this pull request as ready for review September 26, 2025 14:33
@BillWagner BillWagner requested review from a team as code owners September 26, 2025 14:33
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready for final review.

@BillWagner BillWagner requested review from a team and IEvangelist October 2, 2025 12:56
@T-Gro T-Gro merged commit 090c434 into main Oct 3, 2025
13 checks passed
@T-Gro T-Gro deleted the copilot/fix-7fabd101-2812-499c-8623-9372b8057f27 branch October 3, 2025 06:38
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.

Discriminated union syntax: Should mention that the 1st pipe character is optional

3 participants