Unused value warning with ppx_deriving.enum

Hi everyone, I’m using ppx_deriving.enum in the following way:

type myenum =
| A
| B
| C
[@@deriving enum]

This produces 4 values:

val myenum_to_enum : myenum -> int
val myenum_of_enum : int -> myenum option
val min_myenum : int
val max_myenum : int

However, the rest of my code only uses the conversion functions, and not the min and max ones. This triggers warning 32, “unused value”. How do I disable it just for the scope of the type definition generated code included? Doing this:

[@@deriving enum][@@warning "-32"]

appears to only affect the type definition itself.

You can do [@@@warning "-32"] before the type definition and [@@@warning "+32"] after. It is a bit of a hackish thing and ppx_deriving should most likely wrap the generated code in these declarations itself.

I was afraid I’d hear that. I’s not a pretty solution indeed. Thanks!