Skip to content

Constrained type syntax and parsing#407

Merged
LPTK merged 7 commits intohkust-taco:hkmc2from
maximemulder:constrained-types
Mar 10, 2026
Merged

Constrained type syntax and parsing#407
LPTK merged 7 commits intohkust-taco:hkmc2from
maximemulder:constrained-types

Conversation

@maximemulder
Copy link
Copy Markdown
Contributor

@maximemulder maximemulder commented Mar 9, 2026

My first PR after one year in the group lmao.

Description

This PR adds syntax, parsing, and elaboration for constrained types, using the following syntax:

[(type (<: |: >) type)*] => type

Example:

[A <: Int, Str :> B] => Bool

Design choices

  • Both subtyping (<:) and supertyping (:>) constraint syntaxes are accepted.
  • A single constrained type can have an arbitrary number of constraints (0 to n).
  • I added some parsing tests (Tree) but I did not see any dedicated place to add elaboration tests (Term).

@maximemulder maximemulder changed the title constrained type syntax and parsing Constrained type syntax and parsing Mar 9, 2026
@maximemulder maximemulder force-pushed the constrained-types branch 2 times, most recently from c0f52ae to 7249c50 Compare March 9, 2026 06:56
@maximemulder maximemulder marked this pull request as ready for review March 9, 2026 09:23
Copy link
Copy Markdown
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala Outdated
Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala Outdated
Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala
Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala
Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala
Comment thread hkmc2/shared/src/main/scala/hkmc2/syntax/Keyword.scala
Comment thread hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala Outdated
@LPTK LPTK merged commit 88d6c64 into hkust-taco:hkmc2 Mar 10, 2026
1 of 2 checks passed
@LPTK LPTK deleted the constrained-types branch March 10, 2026 06:15
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.

2 participants