-
Notifications
You must be signed in to change notification settings - Fork 412
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
[lang] Preliminary Coq support, core part with recursively qualified modules. #1968
Conversation
41cb9d1
to
721472a
Compare
Something I don't understand is why |
SC.resolve_program ~dir sctx prg ~loc:None ~hint:"try: opam install coq" in | ||
{ coqdep = rr "coqdep" | ||
; coqc = rr "coqc" | ||
; coqpp = rr "coqpp" |
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.
Is there a plan to use coqpp
in the future? I don't see it being used anywhere now?
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.
Yes, I'd like to use it to do .mlg
-> .ml
conversion; I still didn't implement it as I am testing with Coq 8.8 and coqpp
was introduced in coq 8.9 so I need to figure out what the best way to conditionally detect it is.
@@ -0,0 +1,50 @@ | |||
(* This file is licensed under The MIT License *) |
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.
I'm not sure this header is necessary given DCO. Someone from Jane Street should comment on this :)
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.
(same for all similar headers)
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.
I thought it would be safer to explicitly state the license :) No problem doing whatever is needed in this area.
src/coq_rules.ml
Outdated
|
||
let coq_debug = false | ||
|
||
(* TODO: *) |
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.
I'd suggest doing this, opening an issue, or removing this comment 🙂
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.
Comment removed; I will indeed open an issue (in the Coq repos) to discuss what library model should Dune + Coq support. There are a few design decisions to make.
] | ||
|
||
let create_ccoq sctx ~dir = | ||
let rr prg = |
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.
how about renaming this resolve
?
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.
Btw, this record might not be entirely useful. First of all, resolve_program
is actually cached os there's no need to save its result. Second of all, when we change our rules to take advantage of memoization it's best to just ask for values that you actually use. This will help track dependencies more accurately and re-run less stuff. I will leave it up to you if you want to make the change however, there's no immediate need.
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.
Sounds, good; I have scheduled a removal of the record. I find it useful for now as to quickly see what we do require in the toolchain.
@@ -255,6 +266,10 @@ let load_text_files sctx ft_dir | |||
let generated_files = | |||
List.concat_map stanzas ~f:(fun stanza -> | |||
match (stanza : Stanza.t) with | |||
| Coq.T _coq -> | |||
(* Format.eprintf "[coq] generated_files called at sctx: %a@\n%!" Path.pp File_tree.Dir.(path ft_dir); *) | |||
(* FIXME: Need to generate ml files from mlg ? *) |
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.
don't forget this part :)
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.
I was planning to tackle this a part of #1555 where we add support for depending on Coq plugins, however this may be the wrong place to do it as this should affect the regular library
stanza, will remove it for now I think.
@ejgallego could you add a test for the Is the issue only caused in |
721472a
to
a23b9d4
Compare
Thanks a lot folks, I've done a pass.
There is a test already using the coq domain, should I lift it to the general case?
I̶ ̶d̶o̶n̶'̶t̶ ̶t̶h̶i̶n̶k̶ ̶s̶o̶,̶ ̶i̶f̶ ̶y̶o̶u̶ ̶l̶o̶o̶k̶ ̶a̶t̶ ̶t̶h̶e̶ ̶o̶u̶t̶p̶u̶t̶ ̶o̶f̶ ̶t̶h̶e̶ ̶t̶e̶s̶t̶s̶ ̶[̶a̶n̶d̶ ̶t̶h̶e̶ ̶d̶i̶f̶f̶ ̶w̶i̶t̶h̶ ̶h̶t̶t̶p̶s̶:̶/̶/̶g̶i̶t̶h̶u̶b̶.̶c̶o̶m̶/̶e̶j̶g̶a̶l̶l̶e̶g̶o̶/̶d̶u̶n̶e̶/̶t̶r̶e̶e̶/̶c̶o̶q̶+̶r̶e̶c̶u̶r̶s̶i̶v̶e̶+̶i̶n̶s̶t̶a̶l̶l̶ ̶w̶h̶e̶r̶e̶ ̶t̶h̶e̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶r̶u̶l̶e̶s̶ ̶w̶o̶r̶k̶a̶r̶o̶u̶n̶d̶ ̶t̶h̶e̶ ̶b̶u̶g̶]̶ ̶i̶t̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶h̶a̶p̶p̶e̶n̶ ̶i̶n̶ ̶b̶o̶t̶h̶ ̶m̶o̶d̶e̶s̶.̶ Note that I am using |
04750a2
to
596d8fa
Compare
596d8fa
to
125b030
Compare
Update @rgrinberg , indeed the issue is only present in that case, sorry for the wrong diagnosis; it seems that the |
aaba6c5
to
695d746
Compare
695d746
to
ca79eaa
Compare
doc/coq.rst
Outdated
****** | ||
|
||
Dune is also able to build Coq developments. A Coq project is a mix of | ||
Coq ``.v`` files and (optionally) OCaml libraries (in which case we say the project is a *Coq plugin*). To enable |
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.
Actually, a Coq project could contain OCaml files without being a plugin. There is a specific (and standard case) which is an OCaml project where some OCaml files are automatically extracted from Coq files, and some others are hand-written. At some point, it would be good to have good Dune support for this.
A Coq plugin is a Coq project containing OCaml files that link to the Coq API.
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.
I will refine this a bit; but indeed I will not talk about extraction until we get support for it.
The stanza will build all `.v` files on the given directory. | ||
The semantics of fields is: | ||
- ``<module_prefix>>`` will be used as the default Coq library prefix | ||
``-R`` |
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.
I am not sure I understand the choice of -R
over -Q
which was IIMN the recommended choice these days.
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.
I think virtually no library will compile with -Q, note that once installed -Q is implicit as of today given that coqtop includes the top level user-contribs.
We need to discuss the library model indeed, but I'll open an issue for that as there are many complications. For now this PR and 1555 will just reach the point single libraries can be handled properly as in coq makefile.
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.
I suggest you leave this for now and just create an issue. We'll address this in a subsequent PR.
Understood, thanks!
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.
Many libraries actually rely on -Q
as of today and it would be good that there is no regression for these libraries (as coq_makefile supports the two options). That being said, I can understand that this is still experimental support and could be seen as a later refinement.
Yeah, this issue actually affects OCaml as well. The only reason why the situation wasn't observed is that the archive targets would be included in I suggest you leave this for now and just create an issue. We'll address this in a subsequent PR. |
Thanks @Zimmi48 , that's indeed another option; we could even test that in a separate repos [and do more comprehensive testing] At least the problem here is that we have many options to choose from :) in this case it is a good problem to have :) I added the real thing, which admittedly is very heavy, just to be sure we were testing the real beast :) p.s: @rgrinberg most of the time complexity of installing Coq does indeed stem from the fact the Coq has no modular build; so opam will build a large package including the standard library which is quite heavy; the core of Coq is much lighter [dune compiles it in my laptop in less than 2 mins] Indeed, we are not very far from the moment we can split the stdlib from the coq package, even coqdep could be packaged independently, which in this case would add just a few seconds to the compilation. |
That's a good point @ejgallego given that the Dune support is precisely what is going to make this splitting possible. |
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary.
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary.
22903c6
to
07e243c
Compare
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
07e243c
to
3585fd5
Compare
This PR now depends on #1980 , IMHO once that one is in, we could merge this without too much problem. |
3585fd5
to
28c7739
Compare
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
28c7739
to
d971316
Compare
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
d971316
to
0815f1e
Compare
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
0815f1e
to
db2ed20
Compare
This is a cherry-pick of the directory traversal parts from the Dune PR (ocaml#1968). I was uncomfortable with the misnaming done there, so this PR enables the `(include_subdirs qualified)` syntax and provides a `local` part to the traversal so clients [such as the Coq mode] can use it. Note that this does introduce a bit of overhead in the tree traversal, especially in deep trees, it should be possible to optimize if we deem it necessary. Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
db2ed20
to
95bbd20
Compare
This commit adds experimental Coq support to Dune. See Dune issue 1446 for more details. The patch adds a new stanza `(coqlib ...)` enabled by adding `(using coq 0.1)` to `dune-project`. The stanza looks like: ```lisp (coqlib (name Ltac2) ; Determines the `-R` flag (synopsis "Ltac 2 Plugin") ; (modules core Lib.mod) (flags -warn -no-cbv)) ; Flags for `coqc` ``` The functionality of the mode is basic, but it should suffice to replace and extend most uses of `coq_makefile`. The main remaining issue is the definition of on Coq libraries. Local support for Coq libraries should suffice in the short-term. That is to say, `(coqlib ....)` will only see libraries in the same scope, and rely on Coq's default rules for the rest. However, this doesn't seem straightforward. In particular, we may have to re-implement `Lib.DB` which is not trivial. Upcoming commits will add: - support for depending on ML libraries; - generation of `(install ...)` rules; Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
95bbd20
to
0181fbc
Compare
To keep things simple, let's follow Jeremie's advice (he's usually right about this stuff) and start with just copying Something that might be of interest to you is the discussion regarding resolved names: #1900 (comment) I believe this idea could be quite useful as well and perhaps all languages supported by dune can be handled the same way at this name resolution level. |
Thanks @rgrinberg , indeed it'd be great to share the same resolution level; I will open an specific issue for the Coq library model [in the coq repos] tho; there are some minor nits to be addressed, in particular w.r.t. how things work with "legacy" libs. A very annoying thing for example is that Coq installs OCaml and Coq modules all together, so having a transition plan needs some thinking. |
You're talking about the stdlib, right? Or the installation using the coq generate makefile? |
Both, but coq_makefile is the main problem here. |
Dear Dune devs, this is a reworked partial version of #1555 , which only includes the very basic handling of Coq modules and rules.
We piggyback on the
local
support for dir traversal when(include_subdirs qualified)
is enabled to build qualified Coq modules.I have tested this on a few developments that use recursive modules and so far it works well :)
Below is the commit message:
This commit adds experimental Coq support to Dune. See Dune issue 1446
for more details.
The patch adds a new stanza
(coqlib ...)
enabled by adding(using coq 0.1)
todune-project
. The stanza looks like:The functionality of the mode is basic, but it should suffice to
replace and extend most uses of
coq_makefile
.The main remaining issue is the definition of on Coq libraries. Local
support for Coq libraries should suffice in the short-term. That is to
say,
(coqlib ....)
will only see libraries in the same scope, andrely on Coq's default rules for the rest.
However, this doesn't seem straightforward. In particular, we may have
to re-implement
Lib.DB
which is not trivial.Upcoming commits will add:
(install ...)
rules;Signed-off-by: Emilio Jesus Gallego Arias e+git@x80.org