-
Notifications
You must be signed in to change notification settings - Fork 90
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
Dune support #477
Comments
Sounds reasonable, but we'd need to be able to determine when dune is in use. Could dune generate a _CoqProject file for us? In my projects I just write it by hand:
Also, we need some indication of where each .v file came from, so that jump-to-definition can go to the right place. |
It could, but I'm not sure I'm willing to do this; notably the
What do you concretely mean? If you use
|
Yeah, already we cannot generate a |
OK. Then running
When I press
Then it jumps to the corresponding .v file: With dune this doesn't work: instead of going to the original .v file it jumps to the copy that dune made in (We discussed this on gitter a while ago:
|
That's the standard method, we could add a variable in case the user wants to override?
Oh yes I remember that, I thought it had happened in an issue but I couldn't locate it. Actually OCaml has the same problem sometimes [you use M-. but it sends you to the _build dir] but tuareg got a hack for it; I'll have a look and discuss with dune / OCaml upstream to see what the plan regarding this is.
Actually that doesn't bother me too much; for now the large majority of users will be satisfied by that; we could add a The medium term plan is to have something similar to the LSP protocol locate call; still the relation between the lsp-server and the build tool has not been fully determined tho. |
Isn't it the So if we accept dune project files we need to either parse it or be able to query dune for several things. |
It's not so much that company-coq needs _CoqProject; it's that dune copies source files into a separate directory, so it adds extra work to find out where things came from. Maybe dune could add a comment at the end of the file, or something. Or maybe it could have a command to figure out where a file came from. |
OK and no other feature of company-coq needs the compile-options? |
Everything is queried through Coq, so they do need the options, but indirectly ^^ |
Note that |
@ejgallego IIUC you suggest that the main place from PG codebase where
with just If yes, would this work as well with |
Not even |
BTW I have the same question as
also we may want to detect if anyway correct me if I'm wrong, but it seems we'll also need to keep |
I guess it boils down to whether you want to do I tend to prefer working from the root; keep in mind that Keeping Regarding |
That sounds good, though we should use default-directory, not buffer-file-name. Also, this will break for some projects using dune, so we should be careful to add a setting to disable it (my Coq projects using dune have multiple libraries depending on each other, and these dependencies are captured in a _CoqProject but not in a dune file. Maybe the latest changes make that unnecessary?
Note that doing the former will change the way commands producing files behave, I think (not necessarily a bad thing, just pointing it out).
I think it's also that we want to support projects with just one of these systems. |
What commands? If you mean extraction that will be fixed in Coq itself soon.
There is limited composition support already in dune |
Yep, Extraction, as well as graph-dumping commands and other debugging commands that write a file. The "obvious" fix would be to make all these commands print the path of the file they just created (some of them already do). Not a big deal.
😍
Yes! Our PLDI20 paper :) We'll release it on Github in just a few days ^^ I can send you a tarball if you want? |
Actually I'm reworking any command that produces a file so it has to go thru a standard API, that should solve these problems which indeed are annoying. LSP-Coq will forbid all these stuff [except maybe for extraction] and have commands provide output by the protocol.
Thanks! I can wait for the github release, no worries. |
Hi, this is very interesting to read. I have the following
|
It would be easy to use
What to do in this case is an open question;
Not as of today, but we may add support for it in the future. As long as you can write reasonable build rules for that should be easy to add to dune. Myself I'm not very interested in |
While I don't plan to work on this right now I'd strongly encourage for people interested to open an issue in Basically you'd need to figure out the right build rules and write them down using Dune's OCaml-based rule language. |
@ejgallego Thanks for your quick answers! From the answers I would conclude, that currently dune cannot support the auto compilation feature of Proof General. Because there, we need support for interactively adding/changing require commands.
My plan for this is to add a compilation mode to Proof General, where first -vos is used and then, with a suitable delay after -vos finished, start a normal .vo compilation in the background. This way, one can quickly proceed and sees any potential errors relatively soon. I've been using this for -quick/-vio2vo for quite a while.
With this you mean, that a .vos cannot be converted into a .vo? |
I guess it depends how you want to look at it, currently dune has all capabilities to indeed provide compilation support, it is more a matter of the interface to access them I think.
Note that replicating Coq's build system in PG is going to be costly in terms of work, as for example dune provides more and more features including composition.
Not only that, but By incremental I mean more of a true incremental compiliation, that is to say, only recheck proofs that need rechecking, not a file-based approach. |
Yes, but there are important features missing and there is the general problem, that dune cannot deduce dependencies, before the file has been saved. I am not sure, if it is desirable to save a file when Proof General processes a require command.
Well, Proof General's support for compiling Coq projects exists already since 2011, so it is not that we are paying the effort now, which would indeed be questionable. |
This is due to the interface being this way, but can send the file to stdout or save in
Things for simple projects will still continue to work, however quite a few of new features are being added now so the PG code will need updating if we intend to support such projects. |
As certain of my projects grows in complexity, the need for a “dune support” in PG increases. Is there a way to help here to see this issue moving forward? |
What is the status of this? If there is a workaround? We are attempting to switch a sizeable Coq project to Dune, and |
I think Dune makes these files read-only now, so you realize the issue quickly. Still I agree it would be nice to have this. There's no general solution AFAIK, but we should probably just implement a hack at this point. I won't have time to work on it soon though (I'm defending my thesis in a week), so someone would have to write the (ELisp) code. |
@cpitclaudel good luck with your defense! Do we have a consensus on how this "hack" should work? Maybe you can explain the general idea and we can see if somebody else can help... |
Thanks! My guess is that the algorithm is, roughly:
In step 2 we could also look for a dune project file. In step 4 what I mean is that |
Let me check I understand: We don't implement dune support immediately. We just hack something so that dune does not make PG open the wrong files. Is that it? If yes then this needs a fake _coqProject in sync with dune. Right? Let me try to sum up what we need to really support dune and check what seems solved:
Anything else? Do we have a solution for the last point. |
Right
Also right.
I don't use the locking feature, and I'm not sure it's worth maintaining. I often develop generic lemmas or tactics while working on an example, and copy them as I make progress into an appropriate library file that the current file depends on. Locking just gets in the way of that.
I don't really use auto-compilation either, so for me the important point is really the third one; I don't have too many thoughts on the other points. I've resisted doing anything on this because it's bad to accumulate hacks in PG, but since we don't have a solution currently on the dune side, I think we should go ahead with a minimal number of hacks. |
I use it most of the time. It helps me maintain a consistency between files. It is sometimes a bit annoying to recompile files when I know nothing will break, but with vso mode + "don't check proof" mode I basically am happy.
auto-compilation is extremely nice. IMHO it is the best feature of PG. vos mode is definitely the |
1. Find file defining symbol under point — this company-coq already does.
2. Check (`locate-dominating-file` with a predicate) whether the file we
found is in a `_build` directory
Maybe a regexp match for "/_build/" is sufficient?
Stefan
|
I'm not suggesting breaking it, just not fixing it yet (it's already broken by dune, right?)
|
What function does |
The |
@cpitclaudel Please only answer after your defence! |
It should, and I wish it did. but AFAIK it doesn't at the moment, and the issue has been with us for long enough that I now think worth a hack ^^
(Sorry, couldn't resist. Take care.) |
tuareg just strips the |
By the way @ejgallego does dune rename coq modules as it does for ML modules with the dune__exe__ prefix? Isn't that also a source of hacks somewhere in merlin or tuareg? |
@Matafou not that I know of yet, that's mostly for object files tho so it is hard to observe. |
Indeed the ML module names are correct error messages. Does it mean dune performs on-the-fly translation of names on error messages? |
Based on the suggestions above, I am currently using the following hack to make
This simple heuristic seems to work so far for my use cases but I don't know how robust it is. |
Thanks! We will try something similar. |
@MackieLoeffel LGTM, do you want to make it into a PR in company-coq? |
Done in cpitclaudel/company-coq#257 |
Now that support for Roughly, what needs to be done to have reasonable support is (I think) the following:
|
Thanks for all the work @rlepigre , a few comments: 1 and 2: Indeed there are some heuristics to guess that, usually I guess a good start would be to find a project root (using locate-dominating-file) and start from there. For 3. we have a bug in dune, once we fix it, it should work to run For 4. I'd just copy what tuareg does, a very simple but effective hack: if the file starts with _build, strip the prefix 😆 |
Hi folks,
the Coq mode for Dune is getting more mature, and a big blocker now is integration with Proof General. I am unsure how to best approach this; basically PG should add the right flags to make libraries compiled in
_build
into scope.A possibility is indeed to let
dune
handle this; so PG could calldune coqtop foo.v
and indeed coqtop would be started with the right settings. WDYT?The text was updated successfully, but these errors were encountered: