Skip to content

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

Open
Niols wants to merge 1 commit intoc-cube:mainfrom
Niols:qcheck-in-mli
Open

Add [@@deriving qcheck] support in interface files#409
Niols wants to merge 1 commit intoc-cube:mainfrom
Niols:qcheck-in-mli

Conversation

@Niols
Copy link
Copy Markdown

@Niols Niols commented Apr 30, 2026

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
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

1 participant