I can use ppx_deriving make
successfully in utop
. I’m trying to figure out how to use it with dune (as a first step to using deriving
in other ways, along with other ppx
processors). What should I have in the jbuilder
file for this purpose? (I have read anything I can find that seems relevant in the jbuilder/dune docs or in the ppx_deriving
README, but I have not yet figured this out. A tutorial on this sort of thing would be very welcome.)
foo.ml:
type t = {a : int; b : float} [@@deriving make]
let () =
(* let make_t x y = {a=x; b=y} in *)
let f y x = make_t x y in
let foo1 = f 2.1 3 in
Printf.printf "%f %d\n" foo1.b foo1.a
The best hypothesis I have about what should go in jbuild is something like this:
(jbuild_version 1)
(executables
((names (foo))
(public_names (foo))
(package bar)
(preprocess (pps (ppx_deriving.std)))
(libraries (core ppx_deriving.runtime))
(modes (native))))
However, compiling with jbuilder build @install
produces:
...
File "foo.ml", line 6, characters 14-20:
Error: Unbound value make_t
Hint: Did you mean make?
If I uncomment the definition of make_t
in foo.ml, the executable builds and runs with expected output.