Hegel.DeriveAuxiliary submodule for @@deriving hegel_generator.
The type foo resolves to hegel_generator_foo, and the type t in a module M resolves to M.hegel_generator.
open Hegel is required in each file that uses @@deriving hegel_generator:
open Hegel
type point =
{ x : int
; y : int
}
[@@deriving hegel_generator]On OxCaml, [@@deriving hegel_generator ~portable] makes the generator portable, so a concurrent rule body can capture it. On upstream OCaml, ~portable has no effect.
A different module in scope can shadow these names to change the defaults. For example, Hegel_jane.Derive resolves the same names to Core-typed generators.
Use @@deriving hegel_generator for types defined in your project. For external types and modules, define a module including the type, a hegel_generator, and a sexp_of_t.
module M_Wrapper = struct
include External_M
let hegel_generator =
map External_M.f (integers ~min_value:0 ~max_value:1_000_000 ())
|> with_printer (fun m -> Sexplib0.Sexp.Atom (External_M.to_string m))
;;
let sexp_of_t t = Sexplib0.Sexp.Atom (External_M.to_string t)
end
type my_type =
{ x : M_Wrapper.t
; y : string
}
[@@deriving hegel_generator]