Skip to content

Conversation

@jmid
Copy link
Collaborator

@jmid jmid commented Dec 21, 2025

@raphael-proust suggested adding https://github.com/v-gb/ocamlmig migration annotations to help users migrate to the new combinator names. After experimenting a bit, this PR therefore does just that.

Out of 102 deprecations I've come up with annotations for 91 of them.
The remaining 11 deprecated bindings don't have a direct translation and would benefit from the test author to ponder how to translate beyond pushing a button:

  • QCheck.Gen.big_nat generates at most 1_000_000 without a direct translation in distribution
  • QCheck.Gen.neg_int a non-uniform generator without a direct translation in distribution
  • QCheck.Gen.int_pos_corners deprecated without a replacement
  • QCheck.Gen.int_corners deprecated without a replacement
  • QCheck.neg_int a non-uniform generator without a direct translation in distribution
  • QCheck.small_int_corners without a direct translation as int_small_corners is signed
  • QCheck2.Gen.big_nat generates at most 1_000_000 without a direct translation in distribution
  • QCheck2.Gen.neg_int a non-uniform generator without a direct translation in distribution
  • QCheck2.Gen.small_int_corners without a direct translation as int_small_corners is signed
  • QCheck2.Gen.int_pos_corners deprecated without a replacement
  • QCheck2.Gen.int_corners deprecated without a replacement

To utilize the annotations I did the following:

opam install ocamlmig
opam install ./qcheck-core.opam      # to pin my locally patched version
dune build --profile release
dune build --profile release @check  # to be sure everything in the target project was built
ocamlmig migrate                     # to output and review a diff
ocamlmig migrate -w                  # to write the diff changes to files

and doing so, I could essentially port multicoretests automatically to the new API! 🥳
(I recommend reviewing the automatic translation rather than blindly trusting it though)
Based on this I expect the annotations can be helpful for other users too.
I may test the annotations a bit more and then roll a 0.91 release with them.

@jmid
Copy link
Collaborator Author

jmid commented Dec 21, 2025

I was reminded of in-place QCheck.Gen.shuffle_a which shouldn't be translated directly to the non-destructive shuffle_array. The latest commit therefore reverts that annotation.

In addition to being helpful for automatic migration, this turns out to be good to flesh out the 0.90 API changes that go beyond name-to-name mapping 🙂

@jmid
Copy link
Collaborator Author

jmid commented Dec 21, 2025

I may test the annotations a bit more and then roll a 0.91 release with them.

OK, I tried the ocamlmig migration out on containers.

After some back and forth (e.g. installing ocamlformat), I managed to get it working across 36 test files resulting in a +2000LOC diff, except for one stubborn file tests/core/t_list.ml, which is fortunately straightforward to fix with some simple query-replace 🤷

While doing so, I discovered that some rewriting rules needed adjusting, as one cannot assume, e.g., QCheck is open.
The tests in containers instead uses an abbreviated qualification Q., meaning that e.g., Q.small_printable_string shouldn't be replaced verbatim with Q.string_size_of Gen.nat_small Gen.char_printable, but with Q.string_size_of Q.Gen.nat_small Q.Gen.char_printable. This is expressed in ocamlmig with Rel. which represents "the current module context". The latest commit contains the adjustment to use Rel. for such additional arguments.

There may still be a couple of small issues, but even so, overall this should already be useful for users seeking automation help to migrate. With the above successes I therefore declare this "good enough".

@jmid
Copy link
Collaborator Author

jmid commented Dec 21, 2025

Famous last words 😅 I gave the PR a last read through before merging and spotted the typo fixed in 6747e52.

@jmid jmid merged commit 948650a into c-cube:main Dec 21, 2025
24 checks passed
@jmid jmid deleted the ocamlmig branch December 21, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant