Skip to content

docs: model class inheritance with phantom types - #1465

Closed
fhammerschmidt wants to merge 2 commits into
rescript-lang:v12from
fhammerschmidt:docs/phantom-class-inheritance
Closed

fhammerschmidt wants to merge 2 commits into
rescript-lang:v12from
fhammerschmidt:docs/phantom-class-inheritance

Conversation

@fhammerschmidt

@fhammerschmidt fhammerschmidt commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

The class inheritance guide currently requires explicit coercions to use parent methods. Use phantom type parameters constrained by polymorphic variants so dog->Animal.getName works directly while parent values remain rejected by Dog.bark.

Keep the existing JavaScript Animal → Mammal → Dog implementation and @send method bindings. Update the .resi example, move the cross-link from Type Alias to Type Parameter, and link the polymorphic variant page's lower-bound section to the inheritance example.

Validation: the inheritance and type pages pass example compilation, output checks, and MDX compilation. All changed pages pass formatting and the full relative-link check. A temporary fixture compiled and ran the exact documented bindings and JavaScript, verified direct inherited calls, and confirmed rejection of invalid subclass calls and missing parent tags.

Follow-up to #1462.

Replace private aliases and explicit coercions with phantom type parameters constrained by polymorphic variants. Keep the Animal, Mammal, and Dog JavaScript hierarchy and method bindings, allowing Dog values to call parent methods directly.

Update the interface example and move the cross-link to the type parameter section.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T18:50:50.243642Z 8bf3778 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Point readers of polymorphic variant lower bounds to the practical inheritance binding example that combines them with phantom type parameters.
@fhammerschmidt

Copy link
Copy Markdown
Member Author

We decided this is a little too weird to promote (yet).

@fhammerschmidt
fhammerschmidt deleted the docs/phantom-class-inheritance branch October 22, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant