Module Type


module Type: sig .. end
Type value. A type value is a value representing a static ML monomorphic type.
Consult the Plugin Development Guide for additional details.

type 'a t 
Type of type values. For each (static) monomorphic type ty, a value of type ty t dynamically represents the type ty. Such a value is called a type value and should be unique for each static monomorphic type.
Consult the Plugin Development Guide for additional details.

type precedence =
| Basic
| Call
| Couple
| List
| NoPar
Precedences used for generating the minimal number of parenthesis in combination with function Type.par below.
val par : precedence ->
precedence -> Format.formatter -> (Format.formatter -> unit) -> unit
par context myself fmt pp is used to put parenthesis around the verbatim prints by pp according to the precedence myself of the verbatim and to the precedence context of the caller of the pretty printer. fmt is the output formatter.

The typical use is the following: let pretty_print p_caller fmt x = let pp fmt = Format.fprintf "..." ... x ... in let myself = Call in par p_caller Call fmt pp

exception AlreadyExists of string
val register : name:string ->
value_name:string option ->
?pp:(precedence -> Format.formatter -> 'a -> unit) ->
?varname:('a -> string) -> 'a list -> 'a t
register ~name ~value_name abstract pp repr registers a new type value from a value repr representing this type.
Raises Change in Boron-20100401: request a list of representant, not only a single one
val name : 'a t -> string
Returns the name used to register the given type value.
val pp_value_name : 'a t -> precedence -> Format.formatter -> unit
pretty print the value_name used to register the given type value.
val register_pp : 'a t -> (precedence -> Format.formatter -> 'a -> unit) -> unit
register_pp ty pp sets the pretty printer of ty with pp.
exception NoPrinter of string
val pp : 'a t -> precedence -> Format.formatter -> 'a -> unit
pp ty fmt v prints v on fmt according to the printer registered for the type value ty. This function must be called from other pretty printers. However, the printed verbatim contains formatting materials and so should not be used for a direct output. Consider to use Type.use_pp instead.
Raises NoPrinter if there is no printer registered for ty.
val varname : 'a t -> ('a -> string) option
Returns the prefix to use for generating variable names of this type value (as register with optional argument varname of Type.register). Return None if there is no known prefix.
val use_pp : 'a t -> Format.formatter -> 'a -> unit
use_pp ty fmt v prints v on fmt according to the printer registered for the type value ty and to the formatting materials that it contains.
Raises NoPrinter if there is no printer registered for ty.
exception Not_dynamic of string
type ty 
val get_dynamic : string -> ty t
Raises Not_dynamic if no dynamic type value was registered with this name.
Returns the dynamic type value corresponding to the given name.
val is_dynamic : 'a t -> bool
Returns true iff the type value was registered as abstract.

Type values are comparable


val equal : 'a t -> 'b t -> bool
val compare : 'a t -> 'b t -> int
val hash : 'a t -> int

Basic type values


val unit : unit t
The type value corresponding to unit.
Consult the Plugin Development Guide for additional details.
val bool : bool t
The type value corresponding to bool.
val int : int t
The type value corresponding to int.
val int32 : int32 t
The type value corresponding to in32t.
Since Beryllium-20090901
val int64 : int64 t
The type value corresponding to int64.
Since Beryllium-20090901
val nativeint : nativeint t
The type value corresponding to nativeint.
Since Beryllium-20090901
val float : float t
The type value corresponding to float.
val char : char t
The type value corresponding to char.
val string : string t
The type value corresponding to string.
Consult the Plugin Development Guide for additional details.
val formatter : Format.formatter t
The type value corresponding to Format.formatter.

Polymorphic type values


val no_pp : precedence -> Format.formatter -> 'a -> unit
Raises Assert_failure if fully applied.
module type POLYMORPHIC = sig .. end
For a polymorphic type value with one type variable, you must use an implementation of this signature.
module Polymorphic: 
functor (D : sig
val name : 'a Type.t -> string
How to build a name for each monomorphic instance of the type value from the underlying type.
val value_name : string
The name of the built module.
type 'a t 
Static polymorphic type corresponding to its dynamic counterpart to register.
val repr : 'a -> 'a t
How to make the representant of each monomorphic instance of the polymorphic type value from an underlying representant.
val pp : (Type.precedence -> Format.formatter -> 'a -> unit) ->
Type.precedence -> Format.formatter -> 'a t -> unit
How to pretty print values with the help of a pretty printer for the underlying type. Use no_pp if you don't want to register a pretty printer.
end) -> POLYMORPHIC with type 'a poly = 'a D.t
Generic implementation of polymorphic type value.
module type POLYMORPHIC2 = sig .. end
Same as POLYMORPHIC for types with two type variables.
module Polymorphic2: 
functor (D : sig
val name : 'a Type.t -> 'b Type.t -> string
val value_name : string
type ('a, 'b) t 
val repr : 'a -> 'b -> ('a, 'b) t
val pp : (Type.precedence -> Format.formatter -> 'a -> unit) ->
(Type.precedence -> Format.formatter -> 'b -> unit) ->
Type.precedence -> Format.formatter -> ('a, 'b) t -> unit
end) -> POLYMORPHIC2 with type ('a, 'b) poly = ('a, 'b) D.t

Prebuilt polymorphic type values


module Ref: POLYMORPHIC  with type 'a poly = 'a ref
val t_ref : 'a t -> 'a Pervasives.ref t
Alias of Parameters.instantiate.
Since Beryllium-20090901
module Option: POLYMORPHIC  with type 'a poly = 'a option
val option : 'a t -> 'a option t
Alias of Parameters.instantiate.
module List: POLYMORPHIC  with type 'a poly = 'a list
val list : 'a t -> 'a list t
Alias of List.instantiate.
module Couple: POLYMORPHIC2  with type ('a, 'b) poly = 'a * 'b
val couple : 'a t -> 'b t -> ('a * 'b) t
Alias of Couple.instantiate.
val hashtbl : 'a t -> 'b t -> ('a, 'b) Hashtbl.t t
Alias of Hashtbl.instantiate.
module Hashtbl: POLYMORPHIC2  with type ('a, 'b) poly = ('a, 'b) Hashtbl.t
module Function: sig .. end
Same signature than Type.POLYMORPHIC2 with possibility to specify a label for the function parameter.
val func : ?label:string * (unit -> 'a) option ->
'a t -> 'b t -> ('a -> 'b) t
Alias of Type.Function.instantiate.
Consult the Plugin Development Guide for additional details.
val optlabel_func : string -> (unit -> 'a) -> 'a t -> 'b t -> ('a -> 'b) t
optlabel_func lab dft ty1 ty2 is equivalent to func ~label:(lab, Some dft) ty1 ty2
val func2 : ?label1:string * (unit -> 'a) option ->
'a t ->
?label2:string * (unit -> 'b) option ->
'b t -> 'c t -> ('a -> 'b -> 'c) t
Type value for a function taking 2 arguments. func2 ?label1 ty1 ?label2 ty2 ty_ret is equivalent to func ?label:label1 ty1 (func ?label:label2 ty2 ty_ret)
Since Boron-20100401
val func3 : ?label1:string * (unit -> 'a) option ->
'a t ->
?label2:string * (unit -> 'b) option ->
'b t ->
?label3:string * (unit -> 'c) option ->
'c t -> 'd t -> ('a -> 'b -> 'c -> 'd) t
Type value for a function taking 3 arguments. func3 ?label1 ty1 ?label2 ty2 ?label3 ty3 ty_ret is equivalent to func ?label:label1 ty1 (func ?label:label2 ty2 (func ?label:label3 ty3 ty_ret))
Since Boron-20100401
val func4 : ?label1:string * (unit -> 'a) option ->
'a t ->
?label2:string * (unit -> 'b) option ->
'b t ->
?label3:string * (unit -> 'c) option ->
'c t ->
?label4:string * (unit -> 'c) option ->
'd t -> 'e t -> ('a -> 'b -> 'c -> 'd -> 'e) t
Type value for a function taking 4 arguments. func4 ?label1 ty1 ?label2 ty2 ?label3 ty3 ?label4 ty4 ty_ret is equivalent to func ?label:label1 ty1 (func ?label:label2 ty2 (func ?label:label3 ty3 ?label:label4 ty4 ty_ret))
Since Boron-20100401

Heterogeneous Tables

These tables are safe to use but nevertheless not for casual users.
module StringTbl: sig .. end
Heterogeneous tables indexed by string
module TyTbl: sig .. end
Heterogeneous tables indexed by type.
module Binding: sig .. end
val no_obj : unit -> unit
Deactivate all the black magic. Roughly, in this mode, nothing is done by this module.