[Haskell-cafe] Multiple stages in Template Haskell
Lyle Kopnicky
lists at qseep.net
Tue Oct 10 12:39:55 EDT 2006
Hi folks,
I noticed that in Template Haskell, you can only have one level of
splicing or quasi-quoting. E.g., you can't write:
$(zipN ($(sel 2 3) ("zip level",3,()))) ['a'..'Z'] [1..] (words "now
is the time")
Because you can't have a splice inside a splice. But wouldn't it be
handy to use all these macros when defining other macros?
This would be like stages in MetaML, which have no such limitation. But
all the stages but the last one would be evaluated at compile time. The
compiler would look for the deepest level of nested splices and evaluate
it first.
On the other hand, I can understand why you wouldn't include splices and
quasi-quotes in the Language.Haskell.TH.Syntax - programmers could write
functions that dynamically created arbitrarily (even infinitely) nested
splices - so it would be undecidable where to start.
I'm wondering if there's some reason this restriction is imposed. Is it
particularly difficult to implement, or are there more theoretical
problems? Does that mean I'm volunteering? ;)
- Lyle
More information about the Haskell-Cafe
mailing list