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
Add coercion hook #17794
Add coercion hook #17794
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.
Needs to be made safe wrt backtracking
I don't think so. This pr is a twin of |
I understood that that PR was only for "experimentation", but see my review. I think that both that PR and this PR need amending as they are breaking a critical use case, breaking unrelated files / backtrack of the plugin require. Both of the approaches hinted above should work (indirection or |
I think you want to error if the same hook is declared twice. |
@ejgallego your request should now be fullfilled, could you please update your review if you agree this is indeed the case? |
Thanks @proux01 , I'm happy with any mechanism that works with the current [I would prefer if we had an API that was actually always safe instead of placing the burden in the plugin writer, but as long as things work properly on backtrack I don't mind so much here. But indeed, if we are gonna start making these parts of Coq extensible IMHO we need a principled approach] |
This PR seems to validate that property. |
Yes you are correct I somehow misread it. I think we have some similar code already in the system so at some point it could be nice to refactor this pattern into something that could be shared. |
@coqbot run full ci |
Any idea where? I thought the same but couldn't find any example. |
We don't need to solve this now, but I think a couple of places where we do something similar is in the primitive notations and grammar extension code, but @SkySkimmer @herbelin know better. |
Those have a similar principle of indirection through strings, but they're different enough that it's not clearly factorizable IMO |
Too bad :( For #17807 we want to copy this code but I'm unsure if that's enought as to make this "Summary-friendly" Hook API available in as |
@coqbot merge now |
When doing the following since coq#17794 ```Coq Declare ML Module "module-declaring-a-coercion-hook". (* <backtrack> *) (* <reexecute previous command> *) ``` Coq complained about "Hook already registered". To avoid that, this commit puts the set of registered hooks under a summary.
This adds a hook in
pretyping/coercion.ml
to enable programming more elaborate coercions in an external metalanguage (Ltac, Ltac2, Elpi,...). This was developped during CUDW 2023 along with a coq-elpi interface: https://github.com/proux01/coq-elpi/tree/coercion_hookFixes / closes #????
Added / updated test-suite.Added / updated documentation.Documented any new / changed user messages.Updated documented syntax by runningmake doc_gram_rsts
.Opened overlay pull requests.