Skip to content

Adding extracted_files field to rocq.extraction stanza#13997

Merged
Alizter merged 6 commits intoocaml:mainfrom
Durbatuluk1701:rocq_extraction_improv
Apr 10, 2026
Merged

Adding extracted_files field to rocq.extraction stanza#13997
Alizter merged 6 commits intoocaml:mainfrom
Durbatuluk1701:rocq_extraction_improv

Conversation

@Durbatuluk1701
Copy link
Copy Markdown
Contributor

This PR adds an extracted_files field to the rocq.extraction stanza. In particular, this field is used to specify files that should be produced by extraction other than those purely meant for OCaml extraction (the current extracted_modules field behavior).

The primary motivation for this is the following behavior: given a Rocq extraction prelude X.v that extracts to Haskell and produces a file X.hs, a single dune build will produce this file, but subsequent dune build will wipe the X.hs from _build/....

This behavior is mitigated by this PR and specifically witnessed by the Test rebuild does not clean extracted files: test in test/blackbox-tests/test-cases/rocq/extraction/extracted-files.t


It is my belief that the extracted_files stanza could subsume extracted_modules: (extracted_modules F1 ... FN) --> (extracted_files F1.ml F1.mli ... FN.ml FN.mli), however for compatibility I did not do this, although maybe it is worth discussing.

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Apr 1, 2026

I'm in favour of supporting more extractions features of Rocq, however I think we should think a bit harder about reducing the fields in the extraction stanza.

I think guarding the extracted_modules field to be for rocq lang 0.12 and below would be more straight forward. That way we don't have to merge anything and users who transition from 0.12 -> 0.13 could have a helpful error message telling them how to upgrade their stanzas.

We don't do such upgrades for the rest of dune lang, however until rocq lang is considered stable, I think its fine to make it better.

@rlepigre-skylabs-ai I would like to get your input on this also.

Comment thread test/blackbox-tests/test-cases/rocq/coqtop/coqtop-root.t/run.t
@Alizter Alizter added the rocq label Apr 1, 2026
Signed-off-by: Will Thomas <30wthomas@gmail.com>
…`, duplicate rocq.extraction files warning instead of error

Signed-off-by: Will Thomas <30wthomas@gmail.com>
@Durbatuluk1701 Durbatuluk1701 force-pushed the rocq_extraction_improv branch 3 times, most recently from 8b02d9b to 3d4d5b6 Compare April 4, 2026 18:59
…tracted_modules for version 0.13

Signed-off-by: Will Thomas <30wthomas@gmail.com>
@Durbatuluk1701 Durbatuluk1701 force-pushed the rocq_extraction_improv branch from 3d4d5b6 to d7d8744 Compare April 4, 2026 19:15
Copy link
Copy Markdown
Collaborator

@rlepigre-skylabs-ai rlepigre-skylabs-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me, but I've not used extraction very much myself. It might be good to check with other users.

Comment thread src/dune_rules/rocq/rocq_stanza.ml Outdated
Comment thread doc/rocq.rst Outdated

- ``(extracted_files <filenames>)`` is a list of filenames (with extensions)
that will be produced by the extraction. This allows extraction to languages
other than OCaml, such as Haskell (``.hs``) or Scheme (``.scm``). Available
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a since field somewhere in the docs. That should be used when describing this field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't exactly find a since field, but maybe what I ended up doing is what you intended?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my memory this morning was very poor, its

      .. versionadded:: 3.23

Comment thread doc/rocq.rst Outdated

- ``(extracted_modules <names>)`` is an exhaustive list of OCaml modules
extracted.
- ``(extracted_modules <names>)`` specifies the OCaml modules to be extracted.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the information about upgrading in this section, and move this section below.

Comment thread doc/rocq.rst Outdated
Rocq may be instructed to *extract* sources as part of the compilation
process by using the ``rocq.extraction`` stanza:

For ``(rocq 0.12)`` and below:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only keep the new version otherwise it risks being confusing.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. don't repeat the stanza, just show the new version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved info about extracted_modules into a note, because it felt a bit orphaned now

…fixes

Signed-off-by: Will Thomas <30wthomas@gmail.com>
Signed-off-by: Will Thomas <30wthomas@gmail.com>
@Durbatuluk1701
Copy link
Copy Markdown
Contributor Author

This seems fine to me, but I've not used extraction very much myself. It might be good to check with other users.

This is a good idea, topic opened up here

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Apr 9, 2026

Needs a changelog entry

Signed-off-by: Will Thomas <30wthomas@gmail.com>
@Alizter Alizter merged commit 1debce3 into ocaml:main Apr 10, 2026
30 checks passed
@Durbatuluk1701 Durbatuluk1701 deleted the rocq_extraction_improv branch April 10, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants