Debian Codegraph @

kernel/mod_declarations.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Names
12 open Mod_subst
13 open Declarations
14
15 type 'a generic_module_body
16 type module_body = mod_body generic_module_body
17
18 (** For a module, there are five possible situations:
19 - [Declare Module M : T] then [mod_expr = Abstract; mod_type_alg = Some T]
20 - [Module M := E] then [mod_expr = Algebraic E; mod_type_alg = None]
21 - [Module M : T := E] then [mod_expr = Algebraic E; mod_type_alg = Some T]
22 - [Module M. ... End M] then [mod_expr = FullStruct; mod_type_alg = None]
23 - [Module M : T. ... End M] then [mod_expr = Struct; mod_type_alg = Some T]
24 And of course, all these situations may be functors or not. *)
25
26 type module_type_body = mod_type generic_module_body
27
28 (** A [module_type_body] is just a [module_body] with no implementation and
29 also an empty [mod_retroknowledge]. Its [mod_type_alg] contains
30 the algebraic definition of this module type, or [None]
31 if it has been built interactively. *)
32
33 type structure_field_body =
34 (module_body, module_type_body) Declarations.structure_field_body
35
36 type structure_body =
37 (module_body, module_type_body) Declarations.structure_body
38
39 (** A module signature is a structure, with possibly functors on top of it *)
40
41 type module_signature = (module_type_body,structure_body) functorize
42
43 type module_implementation =
44 | Abstract (** no accessible implementation *)
45 | Algebraic of module_expression (** non-interactive algebraic expression *)
46 | Struct of delta_resolver * structure_body (** interactive body living in the parameter context of [mod_type] *)
47 | FullStruct (** special case of [Struct] : the body is exactly [mod_type] *)
48
49 (** Extra invariants :
50
51 - No [MEwith] inside a [mod_expr] implementation : the 'with' syntax
52 is only supported for module types
53
54 - A module application is atomic, for instance ((M N) P) :
55 * the head of [MEapply] can only be another [MEapply] or a [MEident]
56 * the argument of [MEapply] is now directly forced to be a [ModPath.t].
57 *)
58
59 (** {6 Accessors} *)
60
61 val mod_expr : module_body -> module_implementation
62 val mod_type : 'a generic_module_body -> module_signature
63 val mod_type_alg : 'a generic_module_body -> module_expression option
64 val mod_delta : 'a generic_module_body -> delta_resolver
65 val mod_retroknowledge : module_body -> Retroknowledge.action list
66
67 val mod_global_delta : 'a generic_module_body -> delta_resolver option
68 (** [None] if the argument is a functor, [mod_delta] otherwise *)
69
70 (** {6 Builders} *)
71
72 val make_module_body : module_signature -> Mod_subst.delta_resolver -> Retroknowledge.action list -> module_body
73 val make_module_type : module_signature -> Mod_subst.delta_resolver -> module_type_body
74
75 val strengthen_module_body : src:ModPath.t ->
76 module_signature -> delta_resolver -> module_body -> module_body
77
78 val strengthen_module_type :
79 structure_body -> delta_resolver -> module_type_body -> module_type_body
80
81 val replace_module_body : structure_body -> delta_resolver -> module_body -> module_body
82
83 val module_type_of_module : module_body -> module_type_body
84 val module_body_of_type : module_type_body -> module_body
85
86 val functorize_module : (Names.MBId.t * module_type_body) list -> module_body -> module_body
87
88 (** {6 Setters} *)
89
90 (* This is internal code used by the kernel, you should not mess with this. *)
91
92 val set_implementation : module_implementation -> module_body -> module_body
93 val set_algebraic_type : module_type_body -> module_expression -> module_type_body
94 val set_retroknowledge : module_body -> Retroknowledge.action list -> module_body
95
96 (** {6 Substitution} *)
97
98 type subst_kind
99 val subst_dom : subst_kind
100 val subst_codom : subst_kind
101 val subst_dom_codom : subst_kind
102 val subst_shallow_dom_codom : Mod_subst.substitution -> subst_kind
103
104 val subst_signature : subst_kind -> substitution ->
105 ModPath.t -> module_signature -> module_signature
106
107 val subst_structure : subst_kind -> substitution ->
108 ModPath.t -> structure_body -> structure_body
109
110 val subst_module : subst_kind -> substitution ->
111 ModPath.t -> module_body -> module_body
112
113 val subst_modtype : subst_kind -> substitution ->
114 ModPath.t -> module_type_body -> module_type_body
115
116 (** {6 Hashconsing} *)
117
118 val hcons_generic_module_body : 'a generic_module_body -> 'a generic_module_body
119 val hcons_module_body : module_body -> module_body
120 val hcons_module_type : module_type_body -> module_type_body
121
122 (** {6 Cleaning a module expression from bounded parts }
123
124 For instance:
125 functor(X:T)->struct module M:=X end)
126 becomes:
127 functor(X:T)->struct module M:=<content of T> end)
128 *)
129
130 val clean_structure : Names.MBId.Set.t -> structure_body -> structure_body