aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/constant.ml
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/constant.ml')
-rw-r--r--kernel/constant.ml19
1 files changed, 15 insertions, 4 deletions
diff --git a/kernel/constant.ml b/kernel/constant.ml
index c93d486fa..dda7274af 100644
--- a/kernel/constant.ml
+++ b/kernel/constant.ml
@@ -7,13 +7,15 @@ open Generic
open Term
open Sign
-type constant_entry = {
- const_entry_body : constr;
- const_entry_type : constr option }
+type lazy_constant_value =
+ | Cooked of constr
+ | Recipe of (unit -> constr)
+
+type constant_value = lazy_constant_value ref
type constant_body = {
const_kind : path_kind;
- const_body : constr option;
+ const_body : constant_value option;
const_type : typed_type;
const_hyps : typed_type signature;
const_constraints : constraints;
@@ -23,3 +25,12 @@ let is_defined cb =
match cb.const_body with Some _ -> true | _ -> false
let is_opaque cb = cb.const_opaque
+
+let cook_constant = function
+ | { contents = Cooked c } -> c
+ | { contents = Recipe f } as v -> let c = f () in v := Cooked c; c
+
+type constant_entry = {
+ const_entry_body : lazy_constant_value;
+ const_entry_type : constr option }
+