aboutsummaryrefslogtreecommitdiff
path: root/tactics/class_tactics.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2020-07-02 15:34:27 +0200
committerPierre-Marie Pédrot2020-08-12 14:07:13 +0200
commit85e56b4c25071f048624ffbe7f7891f6f1534127 (patch)
treec1bdc5ca26e848a0923c6a0bc335f018e401eec1 /tactics/class_tactics.ml
parente0e07f58da0d45ab54558c61a4a1c3074dfb6380 (diff)
Inline Class_tactics.clenv_of_prods.
It was unnecessarily obfuscated.
Diffstat (limited to 'tactics/class_tactics.ml')
-rw-r--r--tactics/class_tactics.ml37
1 files changed, 14 insertions, 23 deletions
diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml
index 63cafbf76d..94c5ca38fb 100644
--- a/tactics/class_tactics.ml
+++ b/tactics/class_tactics.ml
@@ -211,32 +211,23 @@ let unify_resolve_refine flags gl clenv =
(** Dealing with goals of the form A -> B and hints of the form
C -> A -> B.
*)
-let clenv_of_prods nprods h gl =
- let { hint_term = c; hint_clnv = clenv; hint_poly = poly } = h in
- if poly || Int.equal nprods 0 then Some (None, clenv)
- else
- let sigma = Tacmach.New.project gl in
- let ty = Retyping.get_type_of (Proofview.Goal.env gl) sigma c in
- let diff = nb_prod sigma ty - nprods in
- if (>=) diff 0 then
- (* Was Some clenv... *)
- Some (Some diff,
- mk_clenv_from_n gl (Some diff) (c,ty))
- else None
-
let with_prods nprods h f =
if get_typeclasses_limit_intros () then
Proofview.Goal.enter begin fun gl ->
- try match clenv_of_prods nprods h gl with
- | None ->
- let info = Exninfo.reify () in
- Tacticals.New.tclZEROMSG ~info (str"Not enough premisses")
- | Some (diff, clenv') ->
- let h = { h with hint_clnv = clenv' } in
- f gl (h, diff)
- with e when CErrors.noncritical e ->
- let e, info = Exninfo.capture e in
- Proofview.tclZERO ~info e end
+ let { hint_term = c; hint_clnv = clenv; hint_poly = poly } = h in
+ if poly || Int.equal nprods 0 then
+ f gl (h, None)
+ else
+ let sigma = Tacmach.New.project gl in
+ let ty = Retyping.get_type_of (Proofview.Goal.env gl) sigma c in
+ let diff = nb_prod sigma ty - nprods in
+ if (>=) diff 0 then
+ (* Was Some clenv... *)
+ let clenv = mk_clenv_from_n gl (Some diff) (c,ty) in
+ let h = { h with hint_clnv = clenv } in
+ f gl (h, Some diff)
+ else Tacticals.New.tclZEROMSG (str"Not enough premisses")
+ end
else Proofview.Goal.enter
begin fun gl ->
if Int.equal nprods 0 then f gl (h, None)