diff options
author | Pierre Letouzey <pierre.letouzey@inria.fr> | 2015-01-03 18:50:53 +0100 |
---|---|---|
committer | Pierre Letouzey <pierre.letouzey@inria.fr> | 2015-01-11 09:56:39 +0100 |
commit | edf85b925939cb13ca82a10873ced589164391da (patch) | |
tree | 557735a0f0233f08a49e00169bb2f6afb6f695e2 /checker/cic.mli | |
parent | d103a645df233dd40064e968fa8693607defa6a7 (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 'checker/cic.mli')
-rw-r--r-- | checker/cic.mli | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/checker/cic.mli b/checker/cic.mli index c8b7c9e66..75ce98e90 100644 --- a/checker/cic.mli +++ b/checker/cic.mli @@ -365,7 +365,7 @@ and module_signature = (module_type_body,structure_body) functorize and module_expression = (module_type_body,module_alg_expr) functorize and module_implementation = - | Abstract (** no accessible implementation *) + | Abstract (** no accessible implementation (keep this constructor first!) *) | Algebraic of module_expression (** non-interactive algebraic expression *) | Struct of module_signature (** interactive body *) | FullStruct (** special case of [Struct] : the body is exactly [mod_type] *) @@ -382,18 +382,11 @@ and module_body = mod_delta : delta_resolver; mod_retroknowledge : action list } -(** A [module_type_body] is similar to a [module_body], with - no implementation and retroknowledge fields *) - -and module_type_body = - { typ_mp : module_path; (** path of the module type *) - typ_expr : module_signature; (** expanded type *) - (** algebraic expression, kept if it's relevant for extraction *) - typ_expr_alg : module_expression option; - typ_constraints : Univ.constraints; - (** quotiented set of equivalent constants and inductive names *) - typ_delta : delta_resolver} +(** A [module_type_body] is just a [module_body] with no + implementation ([mod_expr] always [Abstract]) and also + an empty [mod_retroknowledge] *) +and module_type_body = module_body (*************************************************************************) (** {4 From safe_typing.ml} *) |