Module Bindoj_typedesc.Type_desc

This module provides functionalities to describe the types used in Bindoj.

type pos = [
  1. | `type_decl
  2. | `record_field
  3. | `variant_constructor
  4. | `variant_tuple_argument
  5. | `coretype
  6. | `string_enum_case
]
type ('pos, 'kind) config = .. constraint 'pos = [< pos ]

Configuration type where 'pos is restricted to pos types.

module Configs : sig ... end

This module provides the functionality of configurations. Contains types and functions for handling configurations.

type 'pos configs = 'pos Configs.t constraint 'pos = [< pos ]
val pp_configs : _ -> Kxclib.ppf -> _ configs -> unit

dummy printer. always prints "<configs>".

val equal_configs : _ -> _ configs -> _ configs -> bool
  • alert equal_configs Bindoj_type_desc.equal_configs always returns true
module Coretype : sig ... end

This module provides functionalities to handle core types.

type coretype = Coretype.t
val pp_coretype : Kxclib.ppf -> coretype -> unit

Pretty printer for the coretype.

val string_of_coretype : coretype -> string
val equal_coretype : coretype -> coretype -> bool

Checks equality of two coretypes.

type record_field = {
  1. rf_name : string;
    (*

    Name of the record field

    *)
  2. rf_type : [ `direct of coretype | `nested of type_decl * Coretype.codec ];
    (*

    Type of the record field

    *)
  3. rf_configs : [ `record_field ] configs;
    (*

    Configurations associated with the record field

    *)
  4. rf_doc : Bindoj_runtime.doc;
    (*

    Documentation of the record field

    *)
}

Represents a record field.

and variant_tuple_argument = {
  1. va_type : [ `direct of coretype | `nested of type_decl * Coretype.codec ];
  2. va_configs : [ `variant_tuple_argument ] configs;
  3. va_doc : Bindoj_runtime.doc;
}
and variant_constructor = {
  1. vc_name : string;
    (*

    Name of the variant constructor

    *)
  2. vc_param : [ `no_param | `tuple_like of variant_tuple_argument list | `inline_record of record_field list | `reused_inline_record of type_decl ];
  3. vc_configs : [ `variant_constructor ] configs;
    (*

    Configurations associated with the variant constructor

    *)
  4. vc_doc : Bindoj_runtime.doc;
    (*

    Documentation of the variant constructor

    *)
}

Represents a variant constructor.

and type_decl_kind =
  1. | Alias_decl of coretype
    (*

    Type alias kind

    *)
  2. | Record_decl of record_field list
    (*

    Record type kind

    *)
  3. | Variant_decl of variant_constructor list
    (*

    Variant type kind

    *)

Describe the kind of a type declaration.

and type_decl = {
  1. td_name : string;
    (*

    Name of the type declaration

    *)
  2. td_configs : [ `type_decl ] configs;
    (*

    Configurations associated with the type declaration

    *)
  3. td_kind : type_decl_kind;
    (*

    Kind of the type declaration

    *)
  4. td_doc : Bindoj_runtime.doc;
    (*

    Documentation of the type declaration

    *)
}

Represents a type declaration.

val pp_record_field : Kxclib.ppf -> record_field -> unit

Pretty printer for the record_field.

val string_of_record_field : record_field -> string
val equal_record_field : record_field -> record_field -> bool

Checks equality of two record_fields.

val record_field : ?doc:Bindoj_runtime.doc -> ?configs:[ `record_field ] configs -> string -> coretype -> record_field

Creates a new record_field backed by a coretype.

val record_field_nested : ?doc:Bindoj_runtime.doc -> ?configs:[ `record_field ] configs -> ?codec:Coretype.codec -> string -> type_decl -> record_field

Creates a new record_field backed by another type_decl.

val variant_argument : ?doc:Bindoj_runtime.doc -> ?configs:[ `variant_tuple_argument ] configs -> coretype -> variant_tuple_argument

Creates a new argument type specification backed by a coretype for a position in a variant constructor that takes tuple-like arguments.

val variant_argument_nested : ?doc:Bindoj_runtime.doc -> ?configs:[ `variant_tuple_argument ] configs -> ?codec:Coretype.codec -> type_decl -> variant_tuple_argument

Creates a new argument type specification backed by a type_decl for a position in a variant constructor that takes tuple-like arguments.

val pp_variant_constructor : Kxclib.ppf -> variant_constructor -> unit

Pretty printer for the variant_constructor.

val string_of_variant_constructor : variant_constructor -> string
val equal_variant_constructor : variant_constructor -> variant_constructor -> bool

Checks equality of two variant_constructors.

val variant_constructor : ?doc:Bindoj_runtime.doc -> ?configs:[ `variant_constructor ] configs -> string -> [ `no_param | `tuple_like of variant_tuple_argument list | `inline_record of record_field list | `reused_inline_record of type_decl ] -> variant_constructor

Creates a new variant_constructor

val pp_type_decl : Kxclib.ppf -> type_decl -> unit

Pretty printer for the type_decl.

val string_of_type_decl : type_decl -> string
val equal_type_decl : type_decl -> type_decl -> bool

Checks equality of two type declarations.

type variant_type = [
  1. | `regular
    (*

    the default

    *)
  2. | `polymorphic
]

Represents a variant type.

type config +=
  1. | Config_caml_variant_type : variant_type -> ([ `type_decl ], [ `caml_variant_type ]) config
    (*

    Configuration for the Caml variant type.

    *)
module Caml_config : sig ... end

This module provides functionalities to handle configs of OCaml.

val alias_decl : ?doc:Bindoj_runtime.doc -> ?configs:[ `type_decl ] configs -> string -> coretype -> type_decl
val record_decl : ?doc:Bindoj_runtime.doc -> ?configs:[ `type_decl ] configs -> string -> record_field list -> type_decl
val variant_decl : ?variant_type:variant_type -> ?doc:Bindoj_runtime.doc -> ?configs:[ `type_decl ] configs -> string -> variant_constructor list -> type_decl
type ancestral_configs = [ `alias of [ `type_decl ] configs | `record_field of [ `type_decl ] configs * [ `record_field ] configs | `variant_field of [ `type_decl ] configs * [ `variant_constructor ] configs * [ `record_field ] configs | `variant_reused_field of [ `type_decl ] configs * [ `variant_constructor ] configs * [ `type_decl ] configs * [ `record_field ] configs | `variant_argument of int * [ `type_decl ] configs * [ `variant_constructor ] configs * [ `variant_tuple_argument ] configs ] list

List of kind and configs of type_decl, the parent of the coretype. The format of the list is path, with head being the closest.

val fold_coretypes' : ('a -> (coretype * ancestral_configs) -> 'a) -> 'a -> type_decl -> 'a

Folds a function over all coretype in the given type_decl.

val fold_coretypes : ('a -> coretype -> 'a) -> 'a -> type_decl -> 'a

Folds a function over all coretype in the given type_decl.

val is_recursive : type_decl -> bool

Returns if the given type_decl is recursive or not.