1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Operations on core types *)
|
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
open Asttypes
|
1995-05-04 03:15:53 -07:00
|
|
|
open Typedtree
|
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
val generic_level: int
|
1996-07-15 09:35:35 -07:00
|
|
|
val init_def: int -> unit
|
|
|
|
(* Set the initial variable level *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val begin_def: unit -> unit
|
|
|
|
(* Raise the variable level by one at the beginning of a definition. *)
|
|
|
|
val end_def: unit -> unit
|
|
|
|
(* Lower the variable level by one at the end of a definition *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val reset_global_level: unit -> unit
|
|
|
|
val newty: type_desc -> type_expr
|
|
|
|
val newgenty: type_desc -> type_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
val newvar: unit -> type_expr
|
|
|
|
(* Return a fresh variable *)
|
1995-10-31 07:58:31 -08:00
|
|
|
val new_global_var: unit -> type_expr
|
|
|
|
(* Return a fresh variable, bound at toplevel
|
|
|
|
(as type variables ['a] in type constraints). *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val newobj: type_expr -> type_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
val repr: type_expr -> type_expr
|
|
|
|
(* Return the canonical representative of a type. *)
|
1996-05-16 09:10:16 -07:00
|
|
|
val flatten_fields : type_expr -> (string * type_expr) list * type_expr
|
1996-04-22 04:15:41 -07:00
|
|
|
(* Transform a field type into a list of pairs label-type *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val generalize: type_expr -> unit
|
|
|
|
(* Generalize in-place the given type *)
|
|
|
|
val make_nongen: type_expr -> unit
|
|
|
|
(* Make non-generalizable the given type *)
|
|
|
|
val instance: type_expr -> type_expr
|
|
|
|
(* Take an instance of a type scheme *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val instance_parameterized_type:
|
|
|
|
type_expr list -> type_expr -> type_expr list * type_expr
|
|
|
|
val instance_parameterized_type_2:
|
|
|
|
type_expr list -> type_expr list -> type_expr ->
|
|
|
|
type_expr list * type_expr list * type_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
val instance_constructor:
|
|
|
|
constructor_description -> type_expr list * type_expr
|
|
|
|
(* Same, for a constructor *)
|
|
|
|
val instance_label: label_description -> type_expr * type_expr
|
|
|
|
(* Same, for a label *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val instance_class:
|
|
|
|
class_type ->
|
|
|
|
type_expr list * type_expr list *
|
|
|
|
(mutable_flag * type_expr) Vars.t * type_expr
|
1996-05-26 06:42:34 -07:00
|
|
|
val expand_abbrev:
|
1996-04-22 04:15:41 -07:00
|
|
|
Env.t -> Path.t -> type_expr list -> (Path.t * type_expr) list ref ->
|
|
|
|
int -> type_expr
|
|
|
|
(* Expand an abbreviation *)
|
1996-05-26 06:42:34 -07:00
|
|
|
val full_expand: Env.t -> type_expr -> type_expr
|
|
|
|
val expand_root: Env.t -> type_expr -> type_expr
|
|
|
|
val occur: Env.t -> type_expr -> type_expr -> unit
|
1996-04-22 04:15:41 -07:00
|
|
|
(* [occur env var ty] Raise [Unify] if [var] occurs in [ty] *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val unify: Env.t -> type_expr -> type_expr -> unit
|
|
|
|
(* Unify the two types given. Raise [Unify] if not possible. *)
|
|
|
|
val filter_arrow: Env.t -> type_expr -> type_expr * type_expr
|
|
|
|
(* A special case of unification (with 'a -> 'b). *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val filter_method:
|
1996-05-16 09:10:16 -07:00
|
|
|
Env.t -> string -> Typedtree.type_expr -> Typedtree.type_expr
|
1996-04-22 04:15:41 -07:00
|
|
|
(* A special case of unification (with {m : 'a; 'b}). *)
|
1995-05-04 03:15:53 -07:00
|
|
|
val moregeneral: Env.t -> type_expr -> type_expr -> bool
|
|
|
|
(* Check if the first type scheme is more general than the second. *)
|
|
|
|
val equal: Env.t -> type_expr list -> type_expr ->
|
|
|
|
type_expr list -> type_expr -> bool
|
|
|
|
(* [equal env [x1...xn] tau [y1...yn] sigma]
|
|
|
|
checks whether the parameterized types
|
|
|
|
[/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val opened_object: type_expr -> bool
|
|
|
|
val enlarge_type: Env.t -> type_expr list -> type_expr -> type_expr
|
|
|
|
(* Make a type larger *)
|
|
|
|
val subtype : Env.t -> type_expr list -> type_expr -> type_expr -> unit
|
1995-05-04 03:15:53 -07:00
|
|
|
val closed_schema: type_expr -> bool
|
1996-05-26 06:42:34 -07:00
|
|
|
type closed_schema_result = Var of type_expr | Row_var of type_expr
|
|
|
|
val closed_schema_verbose: type_expr -> closed_schema_result option
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Check whether the given type scheme contains no non-generic
|
|
|
|
type variables *)
|
|
|
|
val nondep_type: Env.t -> Ident.t -> type_expr -> type_expr
|
|
|
|
(* Return a type equivalent to the given type but without
|
|
|
|
references to the given module identifier. Raise [Not_found]
|
1995-11-13 06:25:55 -08:00
|
|
|
if no such type exists. *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val nondep_class_type: Env.t -> Ident.t -> class_type -> class_type
|
|
|
|
(* Same for class types. *)
|
|
|
|
val substitute:
|
|
|
|
(Path.t * Typedtree.type_expr) list -> type_expr list ->
|
|
|
|
type_expr list -> type_expr -> type_expr
|
|
|
|
(* [substitute [v1...vN] [t1...tN] t]
|
|
|
|
returns a copy of [t] where the [vi] are replaced
|
|
|
|
by the [ti]. *)
|
|
|
|
val prune:
|
|
|
|
type_expr -> type_expr list -> type_expr * (type_expr * type_expr) list
|
|
|
|
val prune_class_type:
|
|
|
|
class_type ->
|
|
|
|
(type_expr * type_expr) list * type_expr list *
|
|
|
|
(mutable_flag * type_expr) Vars.t * type_expr
|
|
|
|
val close_object: type_expr -> unit
|
|
|
|
val set_object_name:
|
|
|
|
type_expr -> type_expr list -> Ident.t -> unit
|
|
|
|
val remove_object_name: type_expr -> unit
|
|
|
|
val correct_abbrev: Env.t -> Ident.t -> type_expr list -> type_expr -> unit
|
|
|
|
val unroll_abbrev: Ident.t -> type_expr list -> type_expr -> type_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
val is_generic: type_expr -> bool
|
|
|
|
(* Test whether the given type variable is generic *)
|
|
|
|
val arity: type_expr -> int
|
|
|
|
(* Return the arity (as for curried functions) of the given type. *)
|
|
|
|
val none: type_expr
|
|
|
|
(* A dummy type expression *)
|
|
|
|
|
1996-05-20 09:43:29 -07:00
|
|
|
exception Unify of (type_expr * type_expr) list
|
1996-05-26 06:42:34 -07:00
|
|
|
exception Subtype of
|
|
|
|
(type_expr * type_expr) list * (type_expr * type_expr) list
|
1996-04-22 04:15:41 -07:00
|
|
|
exception Cannot_expand
|
|
|
|
exception Nonlinear_abbrev
|
|
|
|
exception Recursive_abbrev
|