Skip to content
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

Replace Pervasives with Stdlib in nat extraction #15333

Merged
merged 1 commit into from
May 10, 2022

Conversation

rudynicolop
Copy link
Contributor

@rudynicolop rudynicolop commented Dec 11, 2021

  • Added changelog.
  • Opened overlay pull requests.

@rudynicolop rudynicolop requested a review from a team as a code owner December 11, 2021 00:14
@rudynicolop rudynicolop force-pushed the extract-nat-int branch 3 times, most recently from 1e21bcc to a64d179 Compare December 11, 2021 00:40
@proux01 proux01 added the part: extraction The extraction mechanism. label Dec 11, 2021
@proux01 proux01 requested a review from a team December 11, 2021 10:32
@proux01
Copy link
Contributor

proux01 commented Dec 11, 2021

What are the OCaml versions supported by extraction? Coq itself should build on OCaml 4.05 to 4.13, is it possible to support that range of versions here?

@herbelin
Copy link
Member

@rudynicolop: do your #???? in the header intend to refer to #7017 and #13288? As hinted by @proux01, Stdlib requires OCaml 4.08 (I did not follow closely the discussions, but the OCaml requirements for Coq 8.16 are probably not decided though).

@rudynicolop
Copy link
Contributor Author

@rudynicolop: do your #???? in the header intend to refer to #7017 and #13288? As hinted by @proux01, Stdlib requires OCaml 4.08 (I did not follow closely the discussions, but the OCaml requirements for Coq 8.16 are probably not decided though).

Sorry my bad I don't think I need the issue number.

@rudynicolop
Copy link
Contributor Author

To allow support for any OCaml version I could inline the functions in the extraction without referring to those in the standard library. I mainly would like to avoid Pervasives because extraction with it produces many warning messages in later OCaml versions.

@herbelin
Copy link
Member

To allow support for any OCaml version I could inline the functions in the extraction without referring to those in the standard library. I mainly would like to avoid Pervasives because extraction with it produces many warning messages in later OCaml versions.

Is there a way from inside OCaml to have code dependent on the version of OCaml running? If yes, extraction could add a header redefining Pervasives from Stdlib (or vice-versa).

An alternative would be to inline the code, e.g. fun x -> x + 1 in place of succ, etc. To mitigate this, we could imagine extending Extract Constant so that it takes arguments, as in Extract Constant succ n => "n + 1".

About what you propose, see the discussion at #10936: we would typically need to let succ, max, min be local keywords so that they don't need a qualifier and Coq extracts its own succ, max, min to say succ0, max0, min0.

@Alizter Alizter added needs: answer PR author must answer review comments. needs: progress Work in progress: awaiting action from the author. labels Jan 16, 2022
@Alizter Alizter removed needs: progress Work in progress: awaiting action from the author. needs: answer PR author must answer review comments. labels May 8, 2022
@Alizter
Copy link
Contributor

Alizter commented May 8, 2022

Now that we have bumped OCaml, we can probably go ahead with this.

@rudynicolop Can you rebase on a recent master?

cc @ppedrot

@Alizter Alizter added this to the 8.16+rc1 milestone May 8, 2022
@Alizter Alizter added the kind: cleanup Code removal, deprecation, refactorings, etc. label May 8, 2022
@ppedrot
Copy link
Member

ppedrot commented May 9, 2022

I've taken the liberty to rebase myself for faster integration.

@ppedrot ppedrot self-assigned this May 10, 2022
@ppedrot
Copy link
Member

ppedrot commented May 10, 2022

I've tweaked a bit the commit message because it was the result of squashing temporary commits, but this is ready. Will merge when CI finishes.

@ppedrot
Copy link
Member

ppedrot commented May 10, 2022

@coqbot merge now

@coqbot-app coqbot-app bot merged commit 4927b82 into coq:master May 10, 2022
Extract Inlined Constant max => "Pervasives.max".
Extract Inlined Constant min => "Pervasives.min".
Extract Inlined Constant max => "Stdlib.Int.max".
Extract Inlined Constant min => "Stdlib.Int.min".
Copy link
Member

Choose a reason for hiding this comment

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

Stdlib.Int.max was first introduced in ocaml/ocaml#10392.
As a result, the extracted code only compiles on OCaml 4.13.

Copy link
Contributor

Choose a reason for hiding this comment

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

@liyishuai That's a shame, I saw "since 4.08" at the top of Int and didn't assume that max and min would not be included. Am I correct in thinking that removing .Int will be enough?

Copy link
Member

Choose a reason for hiding this comment

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

Yes removing .Int should fix the issue.
Maybe also worth adding https://github.com/liyishuai/coq-http (that revealed this issue) to the CI test suite.

@Alizter Alizter added this to Done in Extraction May 31, 2022
@liyishuai liyishuai mentioned this pull request Aug 1, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: cleanup Code removal, deprecation, refactorings, etc. part: extraction The extraction mechanism.
Projects
Archived in project
Extraction
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

7 participants