xxus
February 22, 2024, 6:14am
1
Hi Team, is there any way to view the implementation of to_json and of_json implementation for a particular type generated by ppx_deriving_yojson and yojson
type person = {
name : string;
age : int;
}
[@@deriving yojson]
Now I wanted to see person_to_yojson and person_of_yojson implementation generated by ppx??
Kakadu
February 22, 2024, 7:30am
2
Add -dsource compiler flag, and run dune --verbose
xxus
February 26, 2024, 7:43am
3
@Kakadu can you please tell me where to add this -dsource flag?
emillon
February 26, 2024, 8:49am
4
You don’t have to bother with -dsource and the log. Instead you can simply use dune show pp path/to/file.ml. It will display the preprocessed source.
NAlec
July 6, 2025, 12:27pm
5
Hello @xxus ,
Here is an example of my dune file with ‘-dsource’
(executable
(public_name test)
(name main)
(libraries unix fmt cryptokit ppx_yojson_conv_lib yojson)
(preprocess (pps ppx_yojson_conv)))
(env
(dev
(flags (:standard -w +42 -warn-error -32 -warn-error -33 -dsource) ))
(release
(ocamlopt_flags (:standard -O3))))
If you’re using VSCode, you can also use Ctrl + Shift + P -> OCaml: Show Preprocessed Document to see the ppx output right in your editor
Khady
July 7, 2025, 2:29am
7
with ocamllsp it’s now also possible to “hover” or get type at point on @@deriving and it will show the generated code.