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

Printing polymorphic mode variables #3396

Open
wants to merge 3 commits into
base: ageorges.mode-polymorphism-integrate
Choose a base branch
from

Conversation

ageorg29
Copy link
Contributor

@ageorg29 ageorg29 commented Dec 19, 2024

Prints polymorphic mode variables and their constraints. In general, mode variables is printed in [...] containing its lower and upper bounds and constraints as follows: [< ... & ... > ... | ...]. Lower and upper bounds refer to the constant bounds on the polymorphic variable, and constraints might refer to other mode variables.

If a mode variable has no bounds or constraints, it is printed as a fresh mode variable name: 'm, 'n, 'o, etc.

Printing mode variables requires an expensive pre-processing step, which is only applied when -extension -mode_polymorphism_alpha is on.

Below are some examples:

  • val id : 'a @ [< 'm] -> 'a @ [> 'm]
  • let fst x y = x involves currying, and gets printed to val fst : 'a @ [< 'm & global many > aliased] -> 'b @ 'n -> 'a @ [> 'm | aliased]. Here, since the curry mode is zapped to legacy, the first parameter gets constrained to global many aliased.
  • let fst x = fun y -> x on the other hand is eta-expanded, and has slightly different constrains: 'a @ [< 'm & global many] -> ('b @ 'n -> 'a @ [> 'm | aliased]) @ [> nonportable]. The returned closure is polymorphic, but must be nonportable since it must account for the case where the input is uncontended.
  • let type 'a mytyp = { a : 'a @@ portable } then let f x = x.a is inferred and printed as val f : 'a mytyp @ [< 'm] -> 'a @ [> 'm mod portable]. Here mod portable stands for a meet, and the type expresses the output is lower bounded by 'm, except for the portability axis, which is lower bounded by portable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant