[Template-haskell] RE: Question regarding template Haskell

Simon Peyton-Jones simonpj at microsoft.com
Wed Sep 17 11:45:59 EDT 2003

[I'm redirecting this to the Template Haskell mailing list, where it
more properly belongs.]

Interesting question.

Tim and I are working on revising the 'reifyType' story, but even in our
revised version, your program will be rejected with a staging error.
reifyType gives a way to consult the compiler's type environment, at the
moment when the ExpQ is run.  But at that moment 'x' isn't in scope any

[Tim: this might make a good example for the design notes you're working

You might instead wonder if you can write
	getup :: ExpQ -> ExpQ
which asks what the type of the expression passed to it is.  This one
has come up before, and I don't think we have a good answer yet.
Trouble is (a) although quoted code is type-checked, there's not enough
info to do a full type-check (b) it's not obvious how to record whatever
the type checker does discover. Still an open question, then.


| -----Original Message-----
| From: libraries-bounces at haskell.org
[mailto:libraries-bounces at haskell.org] On Behalf Of Yu Di
| Sent: 12 September 2003 03:33
| To: libraries at haskell.org
| Subject: Question regarding template Haskell
| Hi, I have a question regarding template Haskell: from
| the documentation, I have the impression that it is
| impossible to reify the type of the variable passed to
| the template function, is this true? Or, in other
| words, can I write a function like:
| getTupleCount :: a -> ExpQ
| getTupleCount x=
|   do
|      t <- (reifyType x)
|      --work on t
|      ...
| which returns an expression that is an integer for any
| tuple input, but reduces to error for any input that
| is not a tuple?
| Thanks!
| Di, Yu
| 9.11
| __________________________________
| Do you Yahoo!?
| Yahoo! SiteBuilder - Free, easy-to-use web site design software
| http://sitebuilder.yahoo.com
| _______________________________________________
| Libraries mailing list
| Libraries at haskell.org
| http://www.haskell.org/mailman/listinfo/libraries

More information about the template-haskell mailing list