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
Command line option to set the directory for Extraction "file" #9148
Comments
cc: #8052 |
Until Coq has better support, what I do is create a file
Now you must run This file is difficult to use interactively since you have to make sure the working directory is correct. I'll typically temporarily remove the Cd directives to debug it, and then I just make sure to put the extraction directives somewhere else and import them to Extract.v so that the file rarely changes. (Note that while I phrased everything in terms of Haskell I think the story would be pretty much identical for OCaml, modulo where exactly you should put the output code.) |
Related to #9295. |
After a bit of thinking (maybe not enough) , I think that the best choice of action here is to actually remove There is no sane way Coq could understand enough context as for Not to talk about the semantics of That being said, having an option to set the output dir is also compatible with the above plan; but I am a bit wary of option creep; ideally the option would be shared for extraction objects and |
The deprecation plan for |
What about instead, in 8.12:
The compatibility option will ensure that users have time to migrate, while the transformation of |
I don't like this proposal because it forces me to use the Coq source tree as the Haskell source tree (I believe all of this applies equally to OCaml), and places even more auto-generated files in that tree. If Coq supported a separate output directory (which would clean up the source tree), then that directory would have both build outputs and be a Haskell source tree. My layout looks like this:
This places all the auto-generated Haskell files in their own I think the solution I'd like best would be to use paths relative to the source file. It doesn't have to be |
@tchajed what do you mean by "and extraction does start in src/ and output files in proj-client/"? Do you mean that some of your files other than Extract.v contain extraction? How painful would it be if you needed to put (Also, I thought Coq does now support separate output directories, since dune?) |
@tchajed I think extraction build outputs are sort-of like assembly .s files emitted by gcc, or other build intermediates, which are generally placed in the build outputs directory. Do you view them differently? |
No, I just meant that extraction means that the Haskell project has to know about the Coq project, which makes it complicated. However, the Coq project is perfectly ordinary. You can probably ignore this point - at some point clearly we need a unified build system that connects Coq to haskell-stack, and that gets messy because it happens by using In practice I do need a file with the extraction setup on the Coq side, so maybe I should just put |
This is a good point. The biggest difference is that I actually use the extracted files - I open them in an editor, they're processed by Haskell's language server, and I need to search them occasionally. I think the concrete thing I'm not sure how to do is that I'll need the Haskell stack project to include a source directory outside of the root to grab the Coq build directory, whether that's an output directory |
That's precisely what we are trying to improve (see ocaml/dune#3299).
The way it works (for Coq and also for OCaml) is that Dune copies the source files in I'm not sure I've understood from this discussion if your use case could be covered by simply moving the file containing the extraction commands to the Haskell part of your project @tchajed? Regarding the build workflow, you could use Dune (next version) to build the Coq project up to Haskell extraction, use |
Yeah, I think my setup actually already works as long as I keep the output adjacent to the Coq file, except that Extraction.v has to be alongside the auto-generated code. It’s still annoying that this will require changes to my Haskell extraction and doesn’t improve the situation for me (except for the perceived security concern of using Cd). For example, I still use post-processing to insert additional imports needed for Extract Constant commands (eg, Data.ByteString). |
I thought there was an issue about this, but I couldn't find it, so I made #11956
It will actually improve the user-experience a little bit: you will no longer have to modify the file to get it to compile interactively. (Admittedly, this is not very interesting for tiny files with just |
I think extracted files should go in the build outputs directory, though, not the .v file directory. What about the following, in 8.12?
|
Yes, but currently this is the same and there is no way to configure it, is there? See also:
|
@JasonGross Is there much difference between our two proposals? I feel like the only difference is whether the behavior of |
I think the difference is that my proposal also affects However, on second look, I think your proposal might be simpler, and I'm fine with it (but let's also have it apply to |
Useful discussion thanks; I'll try to address this next week; I'll introduce an abstraction for controlling the generation of object files in general so it should be easy to tweak it. |
I've made a PR allowing you to configure the output directory of extraction. This "kind of" lets you have a command line option for it also: #16126 |
(as of Coq 8.8)
Extraction "file" foo.
withcoqc
puts the extracted file wherever the current directory is, which is typically the root of your project, and which should ideally not be thus polluted.A possible workaround is to change the current directory, but in a
Makefile
you have to be careful to do it on the same line as thecoqc
command, and then you have to accordingly shift the-Q
arguments. A command line option would be a much more obvious solution.This sounds related to #8649 but I'm not actually familiar with those commands.
The text was updated successfully, but these errors were encountered: