-
Notifications
You must be signed in to change notification settings - Fork 632
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
Return canonical instance from basic declare.ml APIs + use to fix Program bug #18931
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to me, thanks.
let univs = match univs with | ||
| Monomorphic_entry _ -> UVars.Instance.empty | ||
| Polymorphic_entry uctx -> UVars.UContext.instance uctx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines of code are used at least 2 other times in the code. Would it make sense to add them to the universe API (in particular, they seem obvious to expert, but documenting why they are canonical in some sense - if so - would help non-expert like me).
let kn = declare_primitive_core ?typing_flags ~name cd in | ||
let () = register_constant kn IsPrimitive local ?user_warns in | ||
kn | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By curiosity, why to extract a specific declare_primitive
? It is because primitive cannot be polymorphic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the message on the commit which does this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
One reason I'm asking is that I started to be afraid at some time by the diversity of code doing this or that manipulation on universes which is sometimes the same sometimes different of what is done in similar functions, and, at the end I felt unable to evaluate whether it is normal that there are difference or if there were oversights.
For instance, so that it is easier to be convinced that the treatment done in declare_primitive_core
is consistent with what is done in declare_constant_core
would it make sense to encapsulate the following lines beyond a level of abstraction shared with declare_constant_core
:
let typ, ubinders, ctx = ... in
let () = Global.push_context_set ~strict:true ctx in
let ubinders = (UState.Monomorphic_entry ctx, ubinders) in
let () = DeclareUniv.declare_univ_binders (GlobRef.ConstRef kn) ubinders in
so that it is clear that it is intended to work as in declare_constant_core
?
For instance, are Global.push_context_set
and DeclareUniv.declare_univ_binders
always supposed to go in pair?
Or, would it make sense to change the level of abstraction of extract_monomorphic
to take a pair (univs, ubinders)
and return a triple (univ_entry, ctx, (UState.Monomorphic_entry ctx, ubinders))
?
PS: My question is more general than the PR and it is not blocking for the PR.
92ad3ad
to
bdf5e3b
Compare
bdf5e3b
to
1f61f0b
Compare
1f61f0b
to
7638cbb
Compare
7638cbb
to
cf237dd
Compare
…re.ml They are special because they don't always come with a universe instance.
cf237dd
to
cade612
Compare
Seems not that useful in the end |
Fix #13979 (based on #18918)