aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Jesus Gallego Arias2020-06-29 11:31:09 +0200
committerEmilio Jesus Gallego Arias2020-07-08 15:12:43 +0200
commite0474577f9b83249d69b0f5b5942d6a6bbb1055b (patch)
tree4dc0ed57241956cf78bf9cce78110196a6048269
parent421b2214a9bcb232739346ef27ae20df64728eb4 (diff)
[declare] Generalize type of hooks.
This is essential to allow hooks to modify state.
-rw-r--r--vernac/declare.ml8
-rw-r--r--vernac/declare.mli5
2 files changed, 9 insertions, 4 deletions
diff --git a/vernac/declare.ml b/vernac/declare.ml
index 85359d5b62..a7da245b0f 100644
--- a/vernac/declare.ml
+++ b/vernac/declare.ml
@@ -33,11 +33,13 @@ module Hook = struct
}
end
- type t = (S.t -> unit) CEphemeron.key
+ type 'a g = (S.t -> 'a -> 'a) CEphemeron.key
+ type t = unit g
- let make hook = CEphemeron.create hook
+ let make_g hook = CEphemeron.create hook
+ let make (hook : S.t -> unit) : t = CEphemeron.create (fun x () -> hook x)
- let call ?hook x = Option.iter (fun hook -> CEphemeron.get hook x) hook
+ let call ?hook x = Option.iter (fun hook -> CEphemeron.get hook x ()) hook
end
diff --git a/vernac/declare.mli b/vernac/declare.mli
index 4891e66803..e13611a828 100644
--- a/vernac/declare.mli
+++ b/vernac/declare.mli
@@ -40,7 +40,9 @@ open Names
care, as imperative effects may become not supported in the
future. *)
module Hook : sig
- type t
+ type 'a g
+
+ type t = unit g
(** Hooks allow users of the API to perform arbitrary actions at
proof/definition saving time. For example, to register a constant
@@ -61,6 +63,7 @@ module Hook : sig
}
end
+ val make_g : (S.t -> 'a -> 'a) -> 'a g
val make : (S.t -> unit) -> t
val call : ?hook:t -> S.t -> unit
end