aboutsummaryrefslogtreecommitdiff
path: root/test-suite/ltac2/example1.v
diff options
context:
space:
mode:
authorMaxime Dénès2019-04-25 14:09:42 +0200
committerMaxime Dénès2019-05-07 10:02:56 +0200
commit9779c0bf4945693bfd37b141e2c9f0fea200ba4d (patch)
tree26f563e3ad9562bdeb67efe8ff55be5de7fc55e2 /test-suite/ltac2/example1.v
parent392d40134c9cd7dee882e31da96369dd09fbbb45 (diff)
Integrate build and documentation of Ltac2
Since Ltac2 cannot be put under the stdlib logical root (some file names would clash), we move it to the `user-contrib` directory, to avoid adding another hardcoded path in `coqinit.ml`, following a suggestion by @ejgallego. Thanks to @Zimmi48 for the thorough documentation review and the numerous suggestions.
Diffstat (limited to 'test-suite/ltac2/example1.v')
-rw-r--r--test-suite/ltac2/example1.v27
1 files changed, 27 insertions, 0 deletions
diff --git a/test-suite/ltac2/example1.v b/test-suite/ltac2/example1.v
new file mode 100644
index 0000000000..023791050f
--- /dev/null
+++ b/test-suite/ltac2/example1.v
@@ -0,0 +1,27 @@
+Require Import Ltac2.Ltac2.
+
+Import Ltac2.Control.
+
+(** Alternative implementation of the hyp primitive *)
+Ltac2 get_hyp_by_name x :=
+ let h := hyps () in
+ let rec find x l := match l with
+ | [] => zero Not_found
+ | p :: l =>
+ match p with
+ | (id, _, t) =>
+ match Ident.equal x id with
+ | true => t
+ | false => find x l
+ end
+ end
+ end in
+ find x h.
+
+Print Ltac2 get_hyp_by_name.
+
+Goal forall n m, n + m = 0 -> n = 0.
+Proof.
+refine (fun () => '(fun n m H => _)).
+let t := get_hyp_by_name @H in Message.print (Message.of_constr t).
+Abort.