aboutsummaryrefslogtreecommitdiff
path: root/test-suite/ltac2/example1.v
diff options
context:
space:
mode:
authorThéo Zimmermann2019-05-07 13:41:04 +0200
committerThéo Zimmermann2019-05-07 13:41:04 +0200
commit7602c2cb547fe6664f7a065d17717baf12b9da88 (patch)
tree1b034b3646090d35a8d730cbec6a5cf1c91da804 /test-suite/ltac2/example1.v
parent8aa64e7c4661549fef63a1c9c2e4e5284db911d8 (diff)
parent9779c0bf4945693bfd37b141e2c9f0fea200ba4d (diff)
Merge PR #10002: Integrate ltac2
Ack-by: JasonGross Reviewed-by: gares Reviewed-by: ppedrot Reviewed-by: jfehrle Ack-by: SkySkimmer Reviewed-by: Zimmi48 Reviewed-by: ejgallego
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.