ppxlib based make deriver
ppx_make can be installed via OCaml Package Manager.
$ opam install ppx_makeTo use this library, add (preprocess (pps ppx_make)) to the library/executable configuration in dune file.
type my_type = {
my_field : int;
my_option : int option;
my_list : int list;
my_string : string;
my_default : int; [@default 1024]
}
[@@deriving make]
(* the deriver will automatically generate the function below *)
val make_my_type :
my_field:int ->
?my_option:int ->
?my_list:int list ->
?my_string:string ->
?my_default:int ->
unit ->
my_typePlease check the test for more examples.