Skip to content

Allow a universe to bind many names #147

New issue

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

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

Already on GitHub? # to your account

Closed
leoyvens opened this issue Jun 4, 2018 · 0 comments · Fixed by #149
Closed

Allow a universe to bind many names #147

leoyvens opened this issue Jun 4, 2018 · 0 comments · Fixed by #149

Comments

@leoyvens
Copy link
Contributor

leoyvens commented Jun 4, 2018

In rustc we allow an universal binder to bind more than one name, such as for<'a, 'b> fn(&'a u32, &'b u32) were both 'a and 'b have a DeBruijn index of 0. In chalk we also allow you to write that, but when moved into the environment 'a and 'b will have distinct universes (see fn instantiate_binders_universally and unify_forall_tys).

Currently chalk represents universal type in the environment directly by the universe index, so forall<T> { Goal(T) } becomes Goal(Ui) once the binder is into the environment. We might want to instead represent them with an index into a table in the environment, like we do for existential variables today, this would be one way to allow us to associate the universal type not only with a universe but with a particular name within that universe. Or maybe we could inline it by carrying two indexes Uij where j is the relative index of the name within the universe.

A motivation would be to u-canonicalize forall<T, U> { Goal(T, U) } and forall<T, U> { Goal(U, T) } into the same thing, as it should be easier to put the universals in a canonical order when you know they are at the universe.

Or at least that's how I understood it, ping @nikomatsakis

@leoyvens leoyvens changed the title Allow a universal binder to bind many names Allow a universe to bind many names Jun 5, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant