Module Type


module Type: sig .. end
Representation of types.

type type_meta 
A type.
type concrete 
Type a non-function, non-variable type , like int, 'a list, int list.
type variable 
A type variable, like 'a
type func 
Function, like int -> int or 'a -> 'a
val func : type_meta -> type_meta -> type_meta
func t0 t1 creates a function type which takes t0 as a parameter, and returns t1. Matching variables in t0 and t1 are considered to be the same variable.
val is_func : type_meta -> bool
Return true iff the given type is a function.
val get_func : type_meta -> func option
get_func t returns None of t is not a function type, otherwise Some f where f is the func of t.
val decompose_func : func -> type_meta * type_meta
decompose_func f return (a,r), where a is the argument type of f, and r is the return type of f.
val is_ground : type_meta -> bool
Return true iff the given type is fully ground (contains no type variables.
type subst = variable * type_meta 
A substition of a variable for a type.
type substs 
0 or more substitutions.
val subst : variable -> type_meta -> type_meta -> type_meta
subst v t0 t1 substitues v for t0 in t1.
val substs : substs -> type_meta -> type_meta
substs ss t performs all substitutions in list ss to t.
val substs_to_list : substs -> subst list
Turn a substs into a list subst. This is just for convenience - substitutions are not really ordered.
val unify : type_meta -> type_meta -> (type_meta * substs) option
unify t0 t1 unifies types t0 and t1. The result is None if t0 and t1 cannot be unified. Otherwise the result is Some (t, s). t is the unification of t0 and t1. s is the that makes t0 and t1 equal.
val is_unifiable : type_meta -> type_meta -> bool
True iff the types unify.
val specialise : type_meta -> type_meta -> (type_meta * substs) option
specialise t0 with t1.
val is_specialisable : type_meta -> type_meta -> bool
True iff t0 can be specialised with t1.
val type_meta_equal : type_meta -> type_meta -> bool
Equality over types variables. Note that two different variables are not considered equal, that is, type_meta_equal (typerep list 'a) (typerep list 'a) returns false, because the 'a in the first expression is not the variable as the 'a in the second expression.
val type_meta_equivelent : type_meta -> type_meta -> bool
Equivelence over types. Equivelence compares two types, but doesn't care exactly what variables are in the types. That is, type_meta_equivelent (typrep list 'a) (typerep list 'b) returns true, because the two types are the same if you substitute 'a for 'b.
val type_meta_hash : type_meta -> int
Hash function over types. Returns the same value for types that are equivelent.
val canonicalize : type_meta -> type_meta
Relable the variables in a type to bring it into "canonical" form. This makes equivelent types equal, by substituting variables from a list of "canonical" variables. Equivelence is implemented by canonicalising the variables and then comparing them.
module TypeMetaHashtbl: Hashtbl.S  with type key = type_meta
Hash table over types.

Showers
val type_meta_shower : type_meta Show.show
val subst_shower : subst Show.show
val substs_shower : substs Show.show
val unify_shower : (type_meta * substs * substs) option Show.show
val toplevel_type_meta_printer : Format.formatter -> type_meta -> unit

Used by the dynaml camlp4 extension.
val variable_context : unit -> string option -> type_meta
val new_base_type : string -> type_meta
val new_poly_type : string -> type_meta list -> type_meta
val new_func_type : type_meta -> type_meta -> type_meta