2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the file LICENSE. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
1995-08-09 08:06:35 -07:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Substitutions *)
|
|
|
|
|
1996-09-23 04:33:27 -07:00
|
|
|
open Types
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
type t
|
|
|
|
|
1997-03-14 07:16:30 -08:00
|
|
|
(*
|
|
|
|
Substitutions are used to translate a type from one context to
|
2017-08-10 03:59:23 -07:00
|
|
|
another. This requires substituting paths for identifiers, and
|
1997-03-14 07:16:30 -08:00
|
|
|
possibly also lowering the level of non-generic variables so that
|
2017-08-10 03:59:23 -07:00
|
|
|
they are inferior to the maximum level of the new context.
|
1997-03-14 07:16:30 -08:00
|
|
|
|
|
|
|
Substitutions can also be used to create a "clean" copy of a type.
|
|
|
|
Indeed, non-variable node of a type are duplicated, with their
|
|
|
|
levels set to generic level. That way, the resulting type is
|
|
|
|
well-formed (decreasing levels), even if the original one was not.
|
|
|
|
*)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
val identity: t
|
|
|
|
|
|
|
|
val add_type: Ident.t -> Path.t -> t -> t
|
2016-08-29 21:16:28 -07:00
|
|
|
val add_type_path: Path.t -> Path.t -> t -> t
|
2016-09-10 18:17:00 -07:00
|
|
|
val add_type_function:
|
2016-08-29 21:16:28 -07:00
|
|
|
Path.t -> params:type_expr list -> body:type_expr -> t -> t
|
1995-05-04 03:15:53 -07:00
|
|
|
val add_module: Ident.t -> Path.t -> t -> t
|
2016-09-04 11:06:50 -07:00
|
|
|
val add_module_path: Path.t -> Path.t -> t -> t
|
1995-05-04 03:15:53 -07:00
|
|
|
val add_modtype: Ident.t -> module_type -> t -> t
|
2002-04-03 19:49:58 -08:00
|
|
|
val for_saving: t -> t
|
2002-04-04 14:19:02 -08:00
|
|
|
val reset_for_saving: unit -> unit
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2008-01-11 08:13:18 -08:00
|
|
|
val module_path: t -> Path.t -> Path.t
|
|
|
|
val type_path: t -> Path.t -> Path.t
|
2020-01-20 05:30:25 -08:00
|
|
|
val modtype_path: t -> Path.t -> Path.t
|
2008-01-11 08:13:18 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
val type_expr: t -> type_expr -> type_expr
|
1998-06-24 12:22:26 -07:00
|
|
|
val class_type: t -> class_type -> class_type
|
1995-05-04 03:15:53 -07:00
|
|
|
val value_description: t -> value_description -> value_description
|
|
|
|
val type_declaration: t -> type_declaration -> type_declaration
|
2014-05-04 16:08:45 -07:00
|
|
|
val extension_constructor:
|
|
|
|
t -> extension_constructor -> extension_constructor
|
1998-06-24 12:22:26 -07:00
|
|
|
val class_declaration: t -> class_declaration -> class_declaration
|
2012-05-30 07:52:37 -07:00
|
|
|
val cltype_declaration: t -> class_type_declaration -> class_type_declaration
|
2019-04-12 02:50:35 -07:00
|
|
|
|
|
|
|
(*
|
|
|
|
When applied to a signature item, a substitution not only modifies the types
|
|
|
|
present in its declaration, but also refreshes the identifier of the item.
|
|
|
|
Effectively this creates new declarations, and so one should decide what the
|
|
|
|
scope of this new declaration should be.
|
|
|
|
|
|
|
|
This is decided by the [scoping] argument passed to the following functions.
|
|
|
|
*)
|
|
|
|
|
|
|
|
type scoping =
|
|
|
|
| Keep
|
|
|
|
| Make_local
|
|
|
|
| Rescope of int
|
|
|
|
|
|
|
|
val modtype: scoping -> t -> module_type -> module_type
|
|
|
|
val signature: scoping -> t -> signature -> signature
|
|
|
|
val signature_item: scoping -> t -> signature_item -> signature_item
|
|
|
|
val modtype_declaration:
|
|
|
|
scoping -> t -> modtype_declaration -> modtype_declaration
|
|
|
|
val module_declaration: scoping -> t -> module_declaration -> module_declaration
|
2009-05-20 04:52:42 -07:00
|
|
|
|
2010-01-22 04:48:24 -08:00
|
|
|
(* Composition of substitutions:
|
2009-05-20 04:52:42 -07:00
|
|
|
apply (compose s1 s2) x = apply s2 (apply s1 x) *)
|
|
|
|
val compose: t -> t -> t
|
2016-09-10 18:17:00 -07:00
|
|
|
|
|
|
|
(* A forward reference to be filled in ctype.ml. *)
|
|
|
|
val ctype_apply_env_empty:
|
|
|
|
(type_expr list -> type_expr -> type_expr list -> type_expr) ref
|