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
|
1996-09-23 04:33:27 -07:00
|
|
|
open Types
|
1995-05-04 03:15:53 -07:00
|
|
|
|
1997-03-08 14:04:36 -08:00
|
|
|
exception Unify of (type_expr * type_expr) list
|
|
|
|
exception Subtype of
|
|
|
|
(type_expr * type_expr) list * (type_expr * type_expr) list
|
|
|
|
exception Cannot_expand
|
|
|
|
exception Recursive_abbrev
|
|
|
|
|
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
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
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
|
1997-03-08 14:04:36 -08:00
|
|
|
val none: type_expr
|
|
|
|
(* A dummy type expression *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
val repr: type_expr -> type_expr
|
|
|
|
(* Return the canonical representative of a type. *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
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 *)
|
1997-03-08 14:04:36 -08:00
|
|
|
val opened_object: type_expr -> bool
|
|
|
|
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
|
|
|
|
|
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 *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
val instance: type_expr -> type_expr
|
|
|
|
(* Take an instance of a type scheme *)
|
1997-02-20 12:39:02 -08:00
|
|
|
val instance_list: type_expr list -> type_expr list
|
|
|
|
(* Take an instance of a list of type schemes *)
|
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 *)
|
1997-03-08 14:04:36 -08: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
|
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
|
1997-03-08 14:04:36 -08:00
|
|
|
val substitute:
|
|
|
|
Env.t -> 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]. *)
|
|
|
|
|
1996-05-26 06:42:34 -07:00
|
|
|
val expand_abbrev:
|
1997-01-21 09:43:53 -08:00
|
|
|
Env.t -> Path.t -> type_expr list -> Types.abbrev_memo ref ->
|
1996-04-22 04:15:41 -07:00
|
|
|
int -> type_expr
|
|
|
|
(* Expand an abbreviation *)
|
1997-03-07 14:49:24 -08:00
|
|
|
val expand_head: Env.t -> type_expr -> type_expr
|
1997-03-08 14:04:36 -08:00
|
|
|
val full_expand: Env.t -> type_expr -> type_expr
|
|
|
|
|
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-09-23 04:33:27 -07:00
|
|
|
val filter_method: Env.t -> string -> type_expr -> type_expr
|
1996-04-22 04:15:41 -07:00
|
|
|
(* A special case of unification (with {m : 'a; 'b}). *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
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. *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1997-02-20 12:39:02 -08:00
|
|
|
val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool
|
1995-05-04 03:15:53 -07:00
|
|
|
(* [equal env [x1...xn] tau [y1...yn] sigma]
|
|
|
|
checks whether the parameterized types
|
|
|
|
[/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1997-01-20 09:11:47 -08:00
|
|
|
val enlarge_type: Env.t -> type_expr -> type_expr
|
1996-04-22 04:15:41 -07:00
|
|
|
(* Make a type larger *)
|
1997-01-20 09:11:47 -08:00
|
|
|
val subtype : Env.t -> type_expr -> type_expr -> unit -> unit
|
|
|
|
(* [subtype env t1 t2] checks that [t1] is a subtype of [t2].
|
|
|
|
It accumulates the constraints the type variables must
|
|
|
|
enforce and returns a function that inforce this
|
|
|
|
constraints. *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
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. *)
|
1997-03-09 10:40:54 -08:00
|
|
|
val nondep_type_decl:
|
|
|
|
Env.t -> Ident.t -> Ident.t -> bool -> type_declaration ->
|
|
|
|
type_declaration
|
|
|
|
(* Same for type declarations. *)
|
1996-04-22 04:15:41 -07:00
|
|
|
val nondep_class_type: Env.t -> Ident.t -> class_type -> class_type
|
|
|
|
(* Same for class types. *)
|
1997-03-08 14:04:36 -08:00
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
val correct_abbrev: Env.t -> Ident.t -> type_expr list -> type_expr -> unit
|
1997-03-08 14:04:36 -08:00
|
|
|
|
|
|
|
type closed_schema_result = Var of type_expr | Row_var of type_expr
|
|
|
|
val closed_schema: bool -> type_expr -> bool
|
|
|
|
val closed_schema_verbose: type_expr -> closed_schema_result option
|
|
|
|
(* Check whether the given type scheme contains no non-generic
|
|
|
|
type variables *)
|
|
|
|
|
1997-02-20 12:39:02 -08:00
|
|
|
val unalias: type_expr -> type_expr
|
1996-04-22 04:15:41 -07:00
|
|
|
val unroll_abbrev: Ident.t -> type_expr list -> type_expr -> type_expr
|
1995-05-04 03:15:53 -07:00
|
|
|
val arity: type_expr -> int
|
|
|
|
(* Return the arity (as for curried functions) of the given type. *)
|