OCaml By Examples

deriving

main.ml

open Core

type person = { name: string ; age: int ; human : bool }
[@@deriving show]

let () =
  let human_one = { name = "david" ; age = 32 ; human = false } in
  printf "%s\n" (show_person human_one)

dune

(executable
 (name main)
 (libraries core)
 (preprocess
  (pps ppx_deriving.show)))

console

$ opam install base ppx_deriving
$ dune exec ./main.exe
{ Main.name = "david"; age = 32; human = false }
next: serialization