Zulip Chat Archive
Stream: lean4
Topic: Qq footgun
Thomas Murrills (Jun 20 2024 at 21:44):
What do you think the following code does? :)
import Qq
open Lean Qq
def etaNatQ (a : Q(Nat → Nat)) : MetaM Q(Nat → Nat) := do
let a := a.eta
logInfo m!"{a}"
return q($a)
#eval etaNatQ q(fun i => Nat.succ i)
Adam Topaz (Jun 20 2024 at 22:06):
Is this a hygiene issue in Qq?
Eric Wieser (Jun 20 2024 at 22:06):
This is https://github.com/leanprover-community/quote4/pull/11 I think
Eric Wieser (Jun 20 2024 at 22:07):
Thomas Murrills (Jun 20 2024 at 22:08):
Ah, nice! I checked the issues, but not the PRs...
Eric Wieser (Jun 20 2024 at 22:11):
I think maybe the thing to do here is copy how `()
quotes work
Eric Wieser (Jun 20 2024 at 22:11):
That is, they just show the whole context:
def foo (i : String) (x : Term) : MetaM Term := `(id $x + $i)
and produce a type error on bad variables
Eric Wieser (Jun 20 2024 at 22:12):
But I guess then you lose the niceness of the Q()
wrappers going away
Last updated: May 02 2025 at 03:31 UTC