blob: f43e0121efb7870b671bc5964b0c89bd8f1c5a93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
Require Import Ltac2.Ltac2 Ltac2.Notations.
Goal True -> False.
Proof.
Fail
let b := { contents := true } in
let f c :=
match b.(contents) with
| true => Message.print (Message.of_constr c); b.(contents) := false; fail
| false => ()
end
in
(** This fails because the matching is not allowed to backtrack once
it commits to a branch*)
lazy_match! '(nat -> bool) with context [?a] => f a end.
lazy_match! Control.goal () with ?a -> ?b => Message.print (Message.of_constr b) end.
(** This one works by taking the second match context, i.e. ?a := nat *)
let b := { contents := true } in
let f c :=
match b.(contents) with
| true => b.(contents) := false; fail
| false => Message.print (Message.of_constr c)
end
in
match! '(nat -> bool) with context [?a] => f a end.
Abort.
|