| 1 |
Require Import Ltac2.Ltac2. |
| 2 |
|
| 3 |
Fail Ltac2 my_change1 (a : constr) (b : constr) := |
| 4 |
change $a with $b. |
| 5 |
|
| 6 |
Fail Ltac2 my_change2 (a:preterm) (b:constr) := |
| 7 |
change $preterm:a with $b. |
| 8 |
|
| 9 |
(* This is pretty bad, maybe $x should mean $pattern:x in patterns? |
| 10 |
Main question is if we allow preterm in pattern, is |
| 11 |
"fun x => let y := preterm:($x) in pattern:($preterm:y)" |
| 12 |
going to be confusing? (x must be constr, and we error at runtime??) |
| 13 |
|
| 14 |
Instead don't allow preterms, instead expose "pattern_of_preterm : preterm -> pattern", |
| 15 |
having runtime errors there seems more sensible than with the quotation. |
| 16 |
*) |
| 17 |
Ltac2 my_change3 (a:pattern) (b:constr) := |
| 18 |
change $pattern:a with $b. |
| 19 |
|
| 20 |
Fail Ltac2 dummy x := preterm:($pattern:x). |
| 21 |
|
| 22 |
Goal id True -> False. |
| 23 |
Fail match! goal with [ |- True -> False ] => () end. |
| 24 |
my_change3 pat:(id True) constr:(True). |
| 25 |
match! goal with [ |- True -> False ] => () end. |
| 26 |
|
| 27 |
Fail let a := preterm:(id True) in change $preterm:a with True. |
| 28 |
Abort. |