Hi,
In the following example, is there a way to name the subexpression (match _ with _ => _ end)
so I can have access to it?
Ltac2 foo () :=
match! goal with
| [ |- context c[ (match ?x with _ => _ end) ]] =>
printf "%t" x
end.
Something like:
| [ |- context c[ (match ?x with _ => _ end) as ?name ]] =>
You could always do it in two steps, even if that's not really elegant: you match on context c[ ?name ]
and then on name
. I don't know what that changes in terms of efficiency though (I'm guessing it can only be worse).
Thanks! That makes sense. I am wondering whether the decrease in efficiency will be too high, since we will match on every possible term inside the context and fail on most of them
Yes, I've been wondering the same myself.
Last updated: Oct 12 2024 at 12:01 UTC