Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 9, 2025

Fixes #41953

This PR adds documentation explaining how to define and implement empty (marker) interfaces in F#, which was previously undocumented and difficult to discover.

Changes

New Section Added

Added a new section titled "Implementing empty or marker interfaces" to the F# interfaces documentation (docs/fsharp/language-reference/interfaces.md). The section:

  • Explains what empty/marker interfaces are and their purpose for type identification
  • Documents the interface end syntax for defining empty interfaces
  • Demonstrates implementation in both record types and class types

Code Example

Created samples/snippets/fsharp/lang-ref-1/snippet2806.fs with a complete example showing:

// Define an empty interface (also known as a marker interface)
type IMarker = 
    interface end

// Implement the empty interface in a record type
type MyRecord = 
    { Name: string }
    interface IMarker

// Implement the empty interface in a class type
type MyClass(value: int) =
    member _.Value = value
    interface IMarker

Placement

The new section is positioned logically after "Implementing Interfaces by Using Class Types" and before "Calling Interface Methods", as it relates directly to interface implementation techniques.

This documentation will help F# developers who need to use empty interfaces for marking or categorizing types without requiring specific behavior implementations.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add section on how to make an empty/marker interface</issue_title>
<issue_description>I didn't edit this in because I'm not sure how the code blocks are built in docs, but can work with someone on this. Something like below (yep, this was hard for me to figure out or find)

Implementing empty, or marker, interfaces

Empty interfaces can be used to identify a set of types as being interchangeable. You define an empty interface as:

type MyInterface = interface end

You implement the interface as

type MyType = 
    { Name: string }
    interface MyInterface

edit by @BillWagner Add document block.


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


💬 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/interfaces.md Interfaces (F#)

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Oct 9, 2025
@Copilot Copilot AI changed the title [WIP] Add section on how to make an empty or marker interface Add documentation for empty/marker interfaces in F# Oct 9, 2025
@Copilot Copilot AI requested a review from BillWagner October 9, 2025 19:36
Copilot finished work on behalf of BillWagner October 9, 2025 19:36
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, with one suggestion.

@BillWagner BillWagner marked this pull request as ready for review October 10, 2025 14:01
@BillWagner BillWagner requested review from a team as code owners October 10, 2025 14:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive documentation for empty/marker interfaces in F#, addressing a gap in the official documentation where this important feature was undocumented and difficult to discover.

  • Added a new documentation section explaining empty/marker interface concepts and syntax
  • Created a complete code example demonstrating implementation in both record and class types
  • Positioned the new content logically within the existing interfaces documentation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docs/fsharp/language-reference/interfaces.md Added new section "Define empty or marker interfaces" with explanation and code reference
samples/snippets/fsharp/lang-ref-1/snippet2806.fs Created F# code example showing empty interface definition and implementation patterns
Comments suppressed due to low confidence (1)

docs/fsharp/language-reference/interfaces.md:1

  • Missing required 'ai-usage' frontmatter key for AI-generated content. Add ai-usage: ai-assisted to the frontmatter section since this content was created with AI assistance.
---

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.

Add section on how to make an empty/marker interface

2 participants