You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following piece of code triggers warning 32 (unused value show_x). This is a common pattern, it happens whenever an exposed type uses a type that is not exposed.
moduleM : sigtypet
[@@deriving show]
valmake : int -> tend=structtypex = int
[@@deriving show]
typet = Cofx
[@@deriving show]
letmaken=C n
end
The problem is the following:
4 bindings are created: pp_x, show_x, pp, and show.
pp, and show are exposed
pp_x is used in the generated definition for pp
show_x is not, so a warning is triggered.
The root cause is similar to ocaml-ppx/ppx_deriving_yojson#76: there is a "convenience function" (here show) that is not meant to be used recursively.
I am not sure how to best fix this without breaking existing code, but here are some possibilities:
generate let _ = show_x to suppress the warning
similarly, wrap the generated structure within [@@@warning "-32"]
add an option so that we can [@@derive show { only_pp = true }]
introduce a [@@deriving pp] that only derives pp. This would enable [%pp: t] as well.
What do you think?
Thanks!
The text was updated successfully, but these errors were encountered:
@NathanReb As mentioned above in #171 (comment), I think both [@@warning "-32"] and [@deriving pp] ought to be implemented. If you can do one of them, great!
Hi,
The following piece of code triggers warning 32 (unused value
show_x
). This is a common pattern, it happens whenever an exposed type uses a type that is not exposed.The problem is the following:
pp_x
,show_x
,pp
, andshow
.pp
, andshow
are exposedpp_x
is used in the generated definition forpp
show_x
is not, so a warning is triggered.The root cause is similar to ocaml-ppx/ppx_deriving_yojson#76: there is a "convenience function" (here
show
) that is not meant to be used recursively.I am not sure how to best fix this without breaking existing code, but here are some possibilities:
let _ = show_x
to suppress the warning[@@@warning "-32"]
[@@derive show { only_pp = true }]
[@@deriving pp]
that only derivespp
. This would enable[%pp: t]
as well.What do you think?
Thanks!
The text was updated successfully, but these errors were encountered: