Hi @mradke. Welcome to OCaml!
The derived show
function for a type called simple
will be show_simple
. PPX derivers in OCaml generally have a convention that the type name appears in the names of generated functions unless the type is called t
(in which case the name is generally omitted). So:
type t = ... [@@deriving show]
val show : t -> string
type foo = ... [@@deriving show]
val show_foo : t -> string
This helps ensure that the generated functions for different types don’t shadow each other.
For debugging these sorts of problems it’s very helpful to have some way to inspect the generated code. In my own editor environment, I tend to do this by putting the code with [@@deriving]
inside a wrapper module and then querying the type of that module. If you’re using something like VS Code then I’d guess there is a nicer solution than this by now One can also use a script like this: Simple script for expanding OCaml PPXes (in a readable way) · GitHub.
Hope this helps!
Craig.