Skip to content

Add [@@deriving qcheck] support in interface files - #409

Merged
jmid merged 3 commits into
c-cube:mainfrom
Niols:qcheck-in-mli
Aug 30, 2026
Merged

jmid merged 3 commits into
c-cube:mainfrom
Niols:qcheck-in-mli

Conversation

@Niols

@Niols Niols commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Register a sig_type_decl expander for both qcheck and qcheck2 derivers, so that [@@deriving qcheck] in .mli files generates val declarations for generators (and arbitraries for QCheck).

For example:

type 'a t [@@deriving qcheck2]

produces:

val gen : 'a QCheck2.Gen.t -> 'a t QCheck2.Gen.t

Parametrized types are handled by adding one Gen.t arrow per type parameter. Sized generator signatures (gen_*_sized) are intentionally left out.

Closes #189

I hope this addresses the concerns raised in #286 — let me know if there is anything you would like to see improved.

Register a `sig_type_decl` expander for both `qcheck` and `qcheck2`
derivers, so that `[@@deriving qcheck]` in `.mli` files generates val
declarations for generators (and arbitraries for QCheck).

For example:

    type 'a t [@@deriving qcheck2]

produces:

    val gen : 'a QCheck2.Gen.t -> 'a t QCheck2.Gen.t

Parametrized types are handled by adding one `Gen.t` arrow per type
parameter. Sized generator signatures (`gen_*_sized`) are intentionally
left out.

Closes c-cube#189
@jmid

jmid commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks a bunch for this! 🙏
I've only given it a brief skim for now. I will take the time for a proper review soonish... 🙂

@Niols

Niols commented May 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Of course, take your time! It took me months to motivate myself to write this and months before to consider contributing, what's a few more months!

@Niols

Niols commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Hey there! Gentle ping, but there is still no rush :-)

@jmid jmid left a comment

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.

Thanks a bunch for this - and sorry for the delay.

LGTM!

Minor nit: The comments regarding the arb-generator can perhaps state
a bit more clearly that this is strictly for QCheck. I've made a few suggestions
there, which I'll commit and then merge.

Thanks again! 🙏

Comment thread src/ppx_deriving_qcheck/ppx_deriving_qcheck.ml Outdated
Comment thread src/ppx_deriving_qcheck/ppx_deriving_qcheck.mli Outdated
@jmid

jmid commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

I've also added a brief mention of the module signature support in the ppx_deriving_qcheck README file.

CI is failing on 32-bit workflows which is an unrelated issue #415

@Niols

Niols commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot! No worries about the timing, I know how it goes. Thanks for coming back to it :-)

IIUC I have nothing to do, but if you'll have me do something I'll happily oblige (but I don't touch a computer until mid-September at the earliest).

@jmid
jmid merged commit 4f495fa into c-cube:main Aug 30, 2026
22 of 24 checks passed
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.

Deriver: deriver in interface files

2 participants