Module Bindoj_gen.Generator

This module provides functions to generate OCaml code.

val gen_structure_with_json_codec : ?self_contained:bool -> ?gen_json_shape_explanation:bool -> ?discriminator_value_accessor:bool -> ?json_shape_explanation_resolution: Json_codec.json_shape_explanation_resolution -> ?codec:Bindoj_typedesc.Type_desc.Coretype.codec -> ?type_decl:[ `expr of Ppxlib.expression | `path of string ] -> formatter:Kxclib.ppf -> Bindoj_typedesc.Type_desc.type_decl -> unit

Writes the OCaml code of the structures of Caml_datatype.gen_structure and Json_codec.gen_json_codec.

  • parameter ?self_contained

    If true, generates builtin encoders/decoders in encoder/decoder functions.

  • parameter ?gen_json_shape_explanation

    If present, val <type_name>_json_shape_explanation is also generated.

  • parameter ?discriminator_value_accessor

    If true and the given type_decl is Variant_decl, val <type_name>_json_discriminator_value is also generated.

  • parameter ?json_shape_explanation_resolution

    How ident is resolved when generating json_shape_explanation.

  • parameter ?codec

    If codec is `default, type t and val <type_name>_<value_name> are generated. If codec is `in_module _, type <type_name> and val <value_name> are generated.

  • parameter ?type_decl

    the expression of / the path to the type_decl value. If present, val <type_name>_decl and val <type_name>_typed_decl are also generated.

  • parameter formatter

    Formatter in which the results are written.

  • parameter type_decl

    type declaration to be generated.

val gen_signature_with_json_codec : ?gen_json_shape_explanation:bool -> ?discriminator_value_accessor:bool -> ?codec:Bindoj_typedesc.Type_desc.Coretype.codec -> gen_type_decl:bool -> formatter:Kxclib.ppf -> Bindoj_typedesc.Type_desc.type_decl -> unit

Writes the OCaml code of the signatures of Caml_datatype.gen_signature and Json_codec.gen_json_codec_signature.

  • parameter ?gen_json_shape_explanation

    If present, val <type_name>_json_shape_explanation is also generated.

  • parameter ?discriminator_value_accessor

    If true and the given type_decl is Variant_decl, val <type_name>_json_discriminator_value is also generated.

  • parameter ?codec

    If codec is `default, type t and val <type_name>_<value_name> are generated. If codec is `in_module _, type <type_name> and val <value_name> are generated.

  • parameter ?gen_type_decl

    If true, val <type_name>_decl and val <type_name>_typed_decl are also generated.

  • parameter formatter

    Formatter in which the results are written.

  • parameter type_decl

    type declaration to be generated.