| 1 |
|
| 2 |
Module Ltac1. |
| 3 |
Notation "& [ , x ; y ; .. ; z ]" := |
| 4 |
(match cons x (cons y .. (cons z nil) ..) return True with xs => ltac:(exact I) end) |
| 5 |
(only parsing). |
| 6 |
|
| 7 |
Check &[ , 0 ; 1 ]. |
| 8 |
End Ltac1. |
| 9 |
|
| 10 |
Module Ltac1Fail. |
| 11 |
Notation "& [ , x ; y ; .. ; z ]" := |
| 12 |
(match cons x (cons y .. (cons z nil) ..) return True with xs => ltac:(exact y) end) |
| 13 |
(only parsing). |
| 14 |
|
| 15 |
Fail Check &[ , 0 ; 1 ]. |
| 16 |
End Ltac1Fail. |
| 17 |
|
| 18 |
Require Import Ltac2.Ltac2. |
| 19 |
|
| 20 |
Module Ltac2. |
| 21 |
Notation "& [ , x ; y ; .. ; z ]" := |
| 22 |
(match cons x (cons y .. (cons z nil) ..) return True with xs => ltac2:(exact I) end) |
| 23 |
(only parsing). |
| 24 |
Check &[ , 0 ; 1 ]. |
| 25 |
End Ltac2. |
| 26 |
|
| 27 |
Module Ltac2Fail. |
| 28 |
(* it would be nice to error at Notation time instead of at use time |
| 29 |
but not sure how to do that with the current design of how recursive patterns are identified *) |
| 30 |
Notation "& [ , x ; y ; .. ; z ]" := |
| 31 |
(match cons x (cons y .. (cons z nil) ..) return True with xs => ltac2:(exact $preterm:y) end) |
| 32 |
(only parsing). |
| 33 |
Fail Check &[ , 0 ; 1 ]. |
| 34 |
End Ltac2Fail. |