-
Notifications
You must be signed in to change notification settings - Fork 77
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
Use constant sorts in transl #3266
Conversation
dffcb1d
to
3353de5
Compare
ab43d23
to
540cc23
Compare
I have rebased this to accommodate the fact that #3224 has been merged. |
I'm up to review this if you want. |
Sorry - this has been behind review of Ryan's unboxed records PR on my stack. I hope to finish that today. I'm broadly happy for @dkalinichenko-js to review this. But, question regarding the second commit: I believe we want, soon, to allow, e.g., record declarations to have fields with layout |
A good question. I think that moving to checking representability at construction would effectively remove the second commit. We won't be storing any sort information in these structures after that change, constant or no. Nothing in this patch makes the change you propose harder or easier, I believe. |
Seems right. Or maybe this field becomes an option to optimize the common case where it is known at declaration time. Anyway, I recall our earlier conversation and still have no objections to this direction if it works (as it seems to). So I think @dkalinichenko-js should review, including the questions about whether the first commit is a win. Thanks in advance, Diana. |
Yes, that sounds likely. |
I don't think we should do (1). |
goldfirere@ce8f169 seems reasonable. |
I'm fine with that conclusion, but
I pretty strongly disagree here. So I just want to check that we agree on the reasoning before worrying so much about the conclusion (because perhaps as we discuss the reasoning, your conclusion might change). |
Yes, I find that unproblematic –
I see. But uses of Thinking through that, even though (1) creates more callsites for |
Never? In theory, there could be another pass through the AST after type-checking and before translation; this pass would remove all sort variables. This would make great sense, and do a better job separating concerns. (GHC has this pass.) But it means reconstructing the entire AST! And it's so easy to do as a little initial step in translation. One annoyance here is that the So in some sense this patch brings the call to |
540cc23
to
05c3424
Compare
As discussed with @ccasin, all of the
transl
functions can really work overSort.Const.t
, notSort.t
. This PR makes this change.Motivation: The second commit, which replaces
Jkind.t
withJkind.Sort.Const.t
invariant_representation
,label_description
, andrecord_representation
. This actually was possible without the first commit, but there were a sad number of calls toJkind.Sort.of_const
to reconsistute the non-constant sorts for transl... so I wrote the first commit.Review: commit-by-commit. The changes are very boring; it's the design change that's interesting.
Jkind.Sort.Const.t
instead ofJkind.Sort.t
(akaJkind.sort
). The there are two sad bits. (a) There are lots more calls todefault_for_transl_and_get
. Previously, we called this function only in Typeopt when we actually needed the sort. Now this function has to be called for every sort stored in the typedtree. I think this is OK, though, because though the function call is written more, it is executed either less or the same amount (previously, sometimes a sort flowed through multiple paths, and it had to begot
ten more than once). It might be reasonable to object to this commit based on the new calls. (b) There is a sad little dance in typedtree because a function needs to deal with both constant and non-constant sorts. The dance is local, but regrettable.Jkind.Sort.Const.t
. This, in turn, is motivated by trying to use kinds as little as possible, because they're about to get a lot more complicated. But actually it's a nice change on its own.If you like (2) but don't like (1) (reasonable! I'm not sure about (1) myself), you can check out goldfirere@ce8f169, which is a version of commit (2) without needing (1). It works. But see the number of
of_const
calls in translcore. These made me sad and is the concrete motivation for (1).If you say to take (2) with the sad
of_const
s because that's better than (1), I won't push back.Review: I'd love @ccasin to push back on the design. If he doesn't want to review the rest of the details, I'm sure @dkalinichenko-js could do so. I recommend looking at the commits separately.