Skip to content

Document private keyword in module type  #508

Closed

Description

@quinn-dougherty

Activity

  1. changed the title [-]`private` keyword in `module type` [/-] [+]Document `private` keyword in `module type` [/+] on Apr 8, 2022
  2. fhammerschmidt commented on May 9, 2025

    @fhammerschmidt
    Member

    There is also this idiom:

    type element = private {}

    Which can be used instead of an abstract type in order for the compiler to not unnecessarily add Primitive_option.some calls for optional props.

    Explanation: https://github.com/rescript-lang/rescript/pull/7450/files#r2081532393

  3. added this to the v12.0 milestone on May 9, 2025
  4. modified the milestones: v12.0, v12.1 on Sep 18, 2025
  5. self-assigned this
    on Apr 10, 2026
  6. fhammerschmidt commented on Nov 3, 2026

    @fhammerschmidt
    Member

    Closing as covered by Refining Module Types with Constraints.

    The Storage with type t = private string example explains how a private type exposes its representation for coercion while preventing callers from constructing values directly. Additional guidance about the private {} optimization mentioned later in this thread can be tracked as a separate documentation improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationChanges required for markdown documentation

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions