Module Bindoj_gen.Caml_datatype

This module provides functionalities to generate OCaml types.

val type_declaration_of_type_decl : ?type_name:string -> ?attrs:Ppxlib.attribute list -> Bindoj_base.Type_desc.type_decl -> Ppxlib.type_declaration

Generates a type declaration.

val gen_reflect : ?codec:Bindoj_base.Type_desc.Coretype.codec -> Bindoj_base.Type_desc.type_decl -> Ppxlib.value_binding

Generates a reflection.

val gen_structure : ?type_name:string -> ?refl:bool -> ?attrs:Ppxlib.attribute list -> ?codec:Bindoj_base.Type_desc.Coretype.codec -> ?generators: (?codec:Bindoj_base.Type_desc.Coretype.codec -> Bindoj_base.Type_desc.type_decl -> Ppxlib.structure) list -> ?type_decl:[ `path of string | `expr of Ppxlib.expression ] -> Bindoj_base.Type_desc.type_decl -> Ppxlib.structure

generate the whole structure containing the results of type_declaration_of_type_decl and gen_reflect.

  • parameter refl

    if true, a field type_name_reflect will be generated. if additionally ?type_decl is given, then a field typed_decl will also be generated.

  • parameter generators

    additional generators e.g. Json_codec.gen_json_encoder.

  • 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. If codec is `in_module _, val decl and val typed_decl are generated instead.

val gen_reflect_signature : ?refl_type_abbr:string -> ?codec:Bindoj_base.Type_desc.Coretype.codec -> Bindoj_base.Type_desc.type_decl -> Ppxlib.value_description

Generaets a signatuoe of reflection

val gen_signature : ?type_name:string -> ?refl:bool -> ?attrs:Ppxlib.attribute list -> ?codec:Bindoj_base.Type_desc.Coretype.codec -> ?generators: (?codec:Bindoj_base.Type_desc.Coretype.codec -> Bindoj_base.Type_desc.type_decl -> Ppxlib.signature) list -> ?type_decl:bool -> ?refl_type_abbr:string -> ?type_decl_type_abbr:string -> ?typed_type_decl_type_abbr:string -> Bindoj_base.Type_desc.type_decl -> Ppxlib.signature

generate the whole signature containing the results of type_declaration_of_type_decl and gen_reflect_signature.

  • parameter refl

    if true, a field type_name_reflect will be generated. if additionally ?type_decl is given, then a field typed_decl will also be generated.

  • parameter generators

    additional generators e.g. Json_codec.gen_json_encoder_signature.

  • 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. If codec is `in_module _, val decl and val typed_decl are generated instead.