Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover parametricity using a matchable top type #94

Closed
LPTK opened this issue Mar 11, 2022 · 2 comments · Fixed by #187
Closed

Recover parametricity using a matchable top type #94

LPTK opened this issue Mar 11, 2022 · 2 comments · Fixed by #187
Labels
enhancement New feature or request

Comments

@LPTK
Copy link
Contributor

LPTK commented Mar 11, 2022

Currently, parametricity is violated because we can pattern-match on anything, including abstract types, thereby retrieving information that should not have been accessible.

We can easily fix this by requiring pattern matching scrutinees to be subtypes of some "matchable" upper bound which all concrete types subtype (but not type parameters).

This is similar to Scala 3's Matchable type (https://docs.scala-lang.org/scala3/reference/other-new-features/matchable.html).

@LPTK LPTK added the enhancement New feature or request label Mar 11, 2022
@LPTK LPTK changed the title Recover parametricity using a _matchable_ top type Recover parametricity using a matchable top type Mar 11, 2022
@LPTK LPTK moved this to 📋 Backlog in MLscript backlog Aug 31, 2022
@LPTK
Copy link
Contributor Author

LPTK commented Oct 11, 2023

We're implementing this with the Object base class in #187.

@LPTK LPTK linked a pull request Oct 11, 2023 that will close this issue
@LPTK LPTK closed this as completed in #187 Jan 12, 2024
@LPTK
Copy link
Contributor Author

LPTK commented Feb 8, 2024

Note: Another advantage of Object is that it will allow us to cleanly separate primitive types, such as primitive integers, which have their own binary representation (in WASM), from object types. The two are distinct and should not be mixed in pattern matching expressions.

@LPTK LPTK moved this from 📋 Backlog to ✅ Done in MLscript backlog Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant