Module Dynamic


module Dynamic: sig .. end
Dynamic values, and functions which operate on them.

type t 
The static type of dynamic values.
val __dynamic_type_t : Type.type_meta
type runtime_type_meta 
Run-time type information associated with a dynamic value has this static type.
exception Type_error of string Lazy.t
Exception raised when a type error occurs. The error message is a lazy string to avoid computationally expensive formatting of the message in the case when the program expects a type error.
val unsafe_to_dynamic : Type.type_meta -> 'a -> t
unsafe_to_dynamic t v casts v to a dynamic value with type t. This function is unsafe - it is up to you to ensure that a really does have type t. If it does not, your program may crash. The dynaml camlp4 expension uses this function in a type safe manner by ensuring that the value has the correct type. In general, this function should not be used other than by the camlp4 extension.
val unsafe_to_static : Type.type_meta -> t -> 'a
unsafe_to_static t d casts d to a normal O'Caml value, or throws Type_error if d does not have type t. This function is unsafe - it is up to you to cast the returned value to the same type specified by t. If you do not, your program may crash. In general, this function should not be used other than by the camlp4 extension.
val has_type : Type.type_meta -> t -> bool
has_type t d is true iff d has type t. Iff this returns true, casting d to t would succeed. (So long as ungeneralised types in t are not determined by another cast in the mean time.)
val get_runtime_type : t -> runtime_type_meta
Get the runtime type of a dynamic value.
val get_type : t -> Type.type_meta
Get the type of a dynamic value.
val apply : t -> t -> t
Apply a value to a function. This can cause a type error if:
val apply_l : t -> t list -> t
Apply a list of values to a function.
exception Type_error' of string
Like Type_error, but the error message isn't lazy. This makes the error a little easier to see in the top-level.
val display_type_error : ('a -> 'b) -> 'a -> 'b
display_type_error f returns a new function, identical to f, except that Type_error exceptions are mapped to Type_error' exceptions.
val incorrect_type_msg : string -> Type.type_meta -> Type.type_meta -> 'a