Hi Folks,
I’m new to OCaml, and I am trying to setup ppx_deriving so that I can print out data structures to gain insight into the output that my algorithms create. I have no prior experience with any OCaml build tools.
I have a basic setup with make and ocamlbuild, but I am unable to get ppx deriving to work.
My project is structured as following:
|-- _build/
| |-- (generated output)
|-- src/
| `-- main.ml
`-- Makefile
`-- _tags
Makefile
contains the following code:
.PHONY: all clean byte native profile debug test
OCB_FLAGS = -tag bin_annot -I src
OCB = ocamlbuild $(OCB_FLAGS)
all: native byte # profile debug
clean:
$(OCB) -clean
native:
$(OCB) main.native
byte:
$(OCB) main.byte
profile:
$(OCB) -tag profile main.native
debug:
$(OCB) -tag debug main.byte
test: native
./main.native "OCaml" "OCamlBuild" "users"
and _tags contains:
true: package(ppx_deriving.std)
and main.ml contains:
type test = {
name: string;
} [@@deriving show]
(* I also tried this with show_test and pp,
all of which complained about unbound values *)
let _ = print_string(show_test {
name = "John Doe"
})
the output of make
is:
ocamlbuild -tag bin_annot -I src main.native
File "_tags", line 1, characters 10-26:
Warning: the tag "ppx_deriving.std" is not used in any flag or dependency declaration, so it will have no effect; it may be a typo. Otherwise you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning.
+ /home/gcf/.opam/4.02.3/bin/ocamlc.opt -c -I /home/gcf/.opam/4.02.3/lib/biniou -I /home/gcf/.opam/4.02.3/lib/easy-format -I /home/gcf/.opam/4.02.3/lib/yojson -bin-annot -I src -o src/main.cmo src/main.ml
File "src/main.ml", line 6, characters 21-30:
Error: Unbound value show_test
Command exited with code 2.
Compilation unsuccessful after building 2 targets (1 cached) in 00:00:00.
Makefile:13: recipe for target 'native' failed
make: *** [native] Error 10