-
Notifications
You must be signed in to change notification settings - Fork 51
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 synterp phase support for derive plugins. #597
Conversation
f957bc9
to
de2d45f
Compare
please put this text in the README.md (and fix the example there). |
topo [] _ [] :- !. | ||
topo L Deps SL :- | ||
std.partition L (not-a-src Deps) LNoDeps Other, | ||
if (LNoDeps = []) (coq.error "derive: no topological order:" L Deps) true, | ||
std.filter Deps (tgt-is-not-in LNoDeps) NewDeps, | ||
topo Other NewDeps SOther, | ||
std.append LNoDeps SOther SL. |
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.
TODO (for me): there is a coq.elpi.toposort but for a full graph. Fix/adapt to this use case.
Note: I fixed the generation of the alias for the type in the case where there is a wrapper module. It was named after the wrapper module name, instead of the type name. I also took this opportunity to add a |
@gares I have given it a quick try, and it seems to me like the |
Thanks. The code should be copy/pasted from readme.v which you edited to add the |
NOTE: the [derivation] predicate now has an extra boolean argument indicating whether the derivation has a non-trivial synterp phase (it is only relevant for recursive derivation). There is no such boolean in the synterp-level counterpart of [derivation].
9e045c7
to
a777090
Compare
I took care of adding a bit of documentation to |
This was developed and tested against our own derive commands (included in this branch). It would probably make sense to test this in the repo somehow though, maybe by adding a new deriver that creates some kind of module?
CC @Janno.
Edit:
We had to require a
synterp
phase for all derivers since we need to know about all of them upfront (thedep1
arguments are not enough to compute the full list, since independent derivers have nodep1
). This does not seem too bad though.We tweaked the module wrapping behaviour of
derive
in the following way:derive Inductive ty := ...
does not automatically create a modulety
anymore.#[module] derive Inductive ty := ...
.#[module="Ty"] derive Inductive ty := ...
.prefix
(string) attribute.no_alias
(boolean) attribute can be used to avoid generating alias notations.