-
Couldn't load subscription status.
- Fork 149
Proposal: Name representation and resolution #2572
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
base: develop
Are you sure you want to change the base?
Conversation
|
Hi @pieter-bos — thanks! This sounds like an excellent idea to me. I also like the proposal: @facundominguez or @nikivazou do you see any issues? A (much!) more “extreme” approach would be to have some version of fixpoints ExprV just for LH and make these different kinds of names different Var variants there. (This is what “flux” the LH for rust does which allows us to handle const generics there) but this proposal seems more pragmatic given the present state. thanks!!! |
|
👋 Thanks for the proposal! Introducing uniques looks plausible. I share some questions below. The proposal mentions Considering alternatives, I could only think of the following. Maybe you already have a good argument to prefer uniques: It would be helpful to collect here the issues that would be helped with this proposal. Or you could create some, if they are not written yet. At the moment, I don't know what examples would be possible to verify after the proposal is implemented. |
|
Thanks for the prompt feedback!
On review I specifically meant
Hmm, I see two obstacles (please correct me if I'm mistaken about anything):
Actually I suppose then that collisions between
Will do! |
That looks like adopting the rapier approach. Section 2 of this paper [link] gives a short account of the difficulties. If it were only In this place of the code, I had to determine the scope of the various bindings in RTypeV [link]. It may help define other functions that also need to understand the scope of bindings like
Maybe the transformation from GHC name to symbol could include the unique as a suffix. But I don't claim to know all the trouble that this will create. Also, note that there is a place in the code that is hardcoding the liquidhaskell/liquidhaskell-boot/src/Language/Haskell/Liquid/Types/PredType.hs Lines 261 to 262 in f049893
Might not affect bindings. |
|
On applying the rapier: this looks like a nice and principled approach. I don't think it quite prevents the need to generate fresh GHC names (as long as they are also mentioned by symbols), as type variables can presumably also shadow dependent bindings. I think that's pretty unlikely given that those bindings are also renamed by
Quite honestly an interesting idea but I don't have high hopes that I can get this right 😅 I think I still have the most confidence that I can do a |
Can it be avoided though? The proposal is abstracting Symbol from the various data types. This looks to me like a good amount of work, but even if it can be completed, names still need to be disambiguated when putting names in string form for the SMT solver. Is it better to wait until this late to differentiate between names that only differ in their uniques? |
|
That's true, but I hope that that is a final transformation after all the logic that needs names to be well-resolved is finished. I'm mostly nervous about having a stage where RType's mention type variables unqualified by uniques (
To me: yes! It's nice to have a type that separates the pretty name and the identity of the name, where you can always glue the pretty name and identity (unique) together in the end. |
When a type variable is represented with a symbol, I would consider always suffixing with the unique, so there are not stages where they are not suffixed. When initially parsed, the type variables are symbols (as One other feature to consider is the serialization and deserialization of lifted specs in
I think it is ok to explore this path. I'm sure quite some details will surface that we are not anticipating now, so we might get back to discussing approaches later on. |
Right, I see. I had written off doing this immediately from the parser, as I suppose this would require some notion of name resolution to be embedded in the parser immediately.
Yes, good point. I think the most principled approach is to refuse to serialize types that have an embedded Given that I think it's probably more practical to just store the
Okay! Practically I'll start then with binding generalization, so steps (1)-(3) from the proposal. |
|
For reference, an issue discussing uniques and unique tags in GHC: https://gitlab.haskell.org/ghc/ghc/-/issues/26264 |
Hello! We'd like to contribute some work to get to a state where we can add refinement types to the prelude of Clash. I thought it would be good to start by improving the support for mentioning value-kind type variables in refinements; here phrased as a proposal so that we can discuss a plan.
It is still somewhat light on details, but broadly I'd suggest to continue adopting
LHNameoverSymbolto represent names, in our case especially for local names. I'd also suggest adding an equivalent of GHC'sUniquetoLHName, to remove the need to make names unique prior to or along resolution.Curious to hear what you think!