aboutsummaryrefslogtreecommitdiffhomepage
path: root/printing/printmod.ml
diff options
context:
space:
mode:
authorGravatar Pierre Letouzey <pierre.letouzey@inria.fr>2015-01-03 18:50:53 +0100
committerGravatar Pierre Letouzey <pierre.letouzey@inria.fr>2015-01-11 09:56:39 +0100
commitedf85b925939cb13ca82a10873ced589164391da (patch)
tree557735a0f0233f08a49e00169bb2f6afb6f695e2 /printing/printmod.ml
parentd103a645df233dd40064e968fa8693607defa6a7 (diff)
Declarations.mli refactoring: module_type_body = module_body
After this commit, module_type_body is a particular case of module_type. For a [module_type_body], the implementation field [mod_expr] is supposed to be always [Abstract]. This is verified by coqchk, even if this isn't so crucial, since [mod_expr] is never read in the case of a module type. Concretely, this amounts to the following rewrite on field names for module_type_body: - typ_expr --> mod_type - typ_expr_alg --> mod_type_alg - typ_* --> mod_* and adding two new fields to mtb: - mod_expr (always containing Abstract) - mod_retroknowledge (always containing []) This refactoring should be completely transparent for the user. Pros: code sharing, for instance subst_modtype = subst_module. Cons: a runtime invariant (mod_expr = Abstract) which isn't enforced by typing. I tried a polymorphic typing of mod_expr, to share field names while not having mtb = mb, but the OCaml typechecker isn't clever enough with polymorphic mutual fixpoints, and reject code sharing (e.g. between subst_modtype and subst_module). In the future (with ocaml>=4), some GADT could maybe help here, but for now the current solution seems good enough.
Diffstat (limited to 'printing/printmod.ml')
-rw-r--r--printing/printmod.ml12
1 files changed, 6 insertions, 6 deletions
diff --git a/printing/printmod.ml b/printing/printmod.ml
index 84d4208f9..6b8bdea40 100644
--- a/printing/printmod.ml
+++ b/printing/printmod.ml
@@ -234,12 +234,12 @@ let nametab_register_module_body mp struc =
nametab_register_dir mp;
List.iter (nametab_register_body mp DirPath.empty) struc
-let get_typ_expr_alg mtb = match mtb.typ_expr_alg with
+let get_typ_expr_alg mtb = match mtb.mod_type_alg with
| Some (NoFunctor me) -> me
| _ -> raise Not_found
let nametab_register_modparam mbid mtb =
- match mtb.typ_expr with
+ match mtb.mod_type with
| MoreFunctor _ -> () (* functorial param : nothing to register *)
| NoFunctor struc ->
(* We first try to use the algebraic type expression if any,
@@ -355,9 +355,9 @@ let rec print_expression x =
and print_signature x =
print_functor print_modtype print_structure x
-and print_modtype env mp locals mtb = match mtb.typ_expr_alg with
+and print_modtype env mp locals mtb = match mtb.mod_type_alg with
| Some me -> print_expression true env mp locals me
- | None -> print_signature true env mp locals mtb.typ_expr
+ | None -> print_signature true env mp locals mtb.mod_type
let rec printable_body dir =
let dir = pop_dirpath dir in
@@ -415,9 +415,9 @@ let print_modtype kn =
(keyword "Module Type" ++ spc () ++ name ++ str " =" ++ spc () ++
(try
if !short then raise ShortPrinting;
- print_signature' true (Some (Global.env ())) kn mtb.typ_expr
+ print_signature' true (Some (Global.env ())) kn mtb.mod_type
with e when Errors.noncritical e ->
- print_signature' true None kn mtb.typ_expr))
+ print_signature' true None kn mtb.mod_type))
end