aboutsummaryrefslogtreecommitdiffhomepage
path: root/tactics
diff options
context:
space:
mode:
authorGravatar Arnaud Spiwack <arnaud@spiwack.net>2014-07-30 12:12:21 +0200
committerGravatar Arnaud Spiwack <arnaud@spiwack.net>2014-08-01 19:18:58 +0200
commit78692ad28ded4f94d5cf7e54240fe0b71d1be282 (patch)
tree05ccc456677d61f2d6b34dff334641059d179193 /tactics
parent47c688165c6ad00b725bc4f93574bba55c2544f5 (diff)
Add [numgoal] to Ltac.
Diffstat (limited to 'tactics')
-rw-r--r--tactics/tacintern.ml3
-rw-r--r--tactics/tacinterp.ml9
-rw-r--r--tactics/tacsubst.ml1
3 files changed, 12 insertions, 1 deletions
diff --git a/tactics/tacintern.ml b/tactics/tacintern.ml
index a651d298f..324ea2f04 100644
--- a/tactics/tacintern.ml
+++ b/tactics/tacintern.ml
@@ -631,7 +631,7 @@ and intern_tactic_as_arg loc onlytac ist a =
| TacCall _ | TacExternal _ | Reference _
| TacDynamic _ | TacGeneric _ as a -> TacArg (loc,a)
| Tacexp a -> a
- | ConstrMayEval _ | UConstr _ | TacFreshId _ | TacPretype _ as a ->
+ | ConstrMayEval _ | UConstr _ | TacFreshId _ | TacPretype _ | TacNumgoals as a ->
if onlytac then error_tactic_expected loc else TacArg (loc,a)
| MetaIdArg _ -> assert false
@@ -663,6 +663,7 @@ and intern_tacarg strict onlytac ist = function
TacExternal (loc,com,req,List.map (intern_tacarg !strict_check false ist) la)
| TacFreshId x -> TacFreshId (List.map (intern_or_var ist) x)
| TacPretype c -> TacPretype (intern_constr ist c)
+ | TacNumgoals -> TacNumgoals
| Tacexp t -> Tacexp (intern_tactic onlytac ist t)
| TacGeneric arg ->
let (_, arg) = Genintern.generic_intern ist arg in
diff --git a/tactics/tacinterp.ml b/tactics/tacinterp.ml
index a6f7ff9af..1eecb9497 100644
--- a/tactics/tacinterp.ml
+++ b/tactics/tacinterp.ml
@@ -971,6 +971,9 @@ struct
bind (Proofview.Goal.raw_goals >>= fun l -> Proofview.tclUNIT (Depends l))
(fun gl -> Proofview.V82.wrap_exceptions (fun () -> f gl))
+ let lift (type a) (t:a Proofview.tactic) : a t =
+ Proofview.tclBIND t (fun x -> Proofview.tclUNIT (Uniform x))
+
(** If the tactic returns unit, we can focus on the goals if necessary. *)
let run m k = m >>= function
| Uniform v -> k v
@@ -1144,6 +1147,12 @@ and interp_tacarg ist arg : typed_generic_argument GTac.t =
Proofview.V82.tclEVARS sigma <*>
GTac.return (Value.of_constr c_interp)
end
+ | TacNumgoals ->
+ GTac.lift begin
+ let open Proofview.Notations in
+ Proofview.numgoals >>= fun i ->
+ Proofview.tclUNIT (Value.of_int i)
+ end
| Tacexp t -> val_interp ist t
| TacDynamic(_,t) ->
let tg = (Dyn.tag t) in
diff --git a/tactics/tacsubst.ml b/tactics/tacsubst.ml
index c0b81e90d..ecadfca59 100644
--- a/tactics/tacsubst.ml
+++ b/tactics/tacsubst.ml
@@ -262,6 +262,7 @@ and subst_tacarg subst = function
TacExternal (_loc,com,req,List.map (subst_tacarg subst) la)
| TacFreshId _ as x -> x
| TacPretype c -> TacPretype (subst_glob_constr subst c)
+ | TacNumgoals -> TacNumgoals
| Tacexp t -> Tacexp (subst_tactic subst t)
| TacGeneric arg -> TacGeneric (Genintern.generic_substitute subst arg)
| TacDynamic(the_loc,t) as x ->