type _ t =| Int : int t| Int32 : int32 t| Int64 : int64 t| Nativeint : nativeint t| Char : char t| Float : float t| String : string t| Bytes : bytes t| Bool : bool t| Unit : unit t| Option : 'a t -> 'a option t| List : 'a t -> 'a list t| Array : 'a t -> 'a array t| Lazy : 'a t -> 'a lazy_t t| Ref : 'a t -> 'a Stdlib.ref t| Function : ('dom t * 'rng t) -> ('dom -> 'rng) t| Tuple : 'a Typerep.Tuple.t -> 'a t| Record : 'a Typerep.Record.t -> 'a t| Variant : 'a Typerep.Variant.t -> 'a tThe
Namedconstructor both allows for custom implementations of generics based on name and provides a way to represent recursive types, the lazy part dealing with cycles| Named : ('a Typerep.Named.t * 'a t lazy_t option) -> 'a ttype packed =| T : 'a t -> packed
module Named : sig ... endmodule Tuple : sig ... endinclude Variant_and_record_intf.S with type 'a t := 'a t
include module type of sig ... end
module Tag_internal : sig ... endmodule Tag : sig ... endWitness of a tag, that is an item in a variant type, also called an "applied variant Constructor"
module Variant_internal : sig ... endmodule Variant : sig ... endmodule Field_internal : sig ... endmodule Field : sig ... endWitness of a field, that is an item in a record type. The first parameter is the record type, the second is the type of the field. Example:
module Record_internal : sig ... endmodule Record : sig ... endval same : _ t -> _ t -> boolsame t t'will return a proof a equality iftandt'are the same type. One can think of two types being thesameas two types whose values could be for example put in a list together. It is worth noting that this function *does not* operate compatiblity diffs between two different types with the same structure. Example:module M1 = struct type t = { a : int; b : float; } [@@deriving typerep] end module M2 = struct type t = { a : int; b : float; } [@@deriving typerep] end [%test_result:bool] ~expect:false (same M1.typerep_of_t M2.typerep_of_t) type a = int with typerep type b = int with typerep [%test_result:bool] ~expect:true (same typerep_of_a typerep_of_b)This is meant to recover type equality hidden by existential constructors.
Basically this function does structural equality for everything except variant types, record types, and named types with no lazy definition exposed. This last case is about types that are defined
with typerep(abstract)
val same_witness : 'a t -> 'b t -> ('a, 'b) Type_equal.t optionval same_witness_exn : 'a t -> 'b t -> ('a, 'b) Type_equal.tval typename_of_t : 'a t -> 'a Typename.tval head : 'a t -> 'a thead tyis used to traverse theNamedconstructor. It might be used when one care to pattern match directly on the representation in a low level way rather than going through a full generic.head tistiftis not of the formNamed _