[Template-haskell] Defining a function and using it in a splice within the same module

Alfonso Acosta alfonso.acosta at gmail.com
Mon Oct 22 21:51:04 EDT 2007


Hi,

The user guide from latest GHC release makes clear that doing what I
wrote in the subject of this message is not possible:

>From 7.6:

"You can only run a function at compile time if it is imported from
another module. That is, you can't define a function in a module, and
call it from within a splice in the same module."

Unfortunately I have encountered this problem more times than I'd like
while using TH to implement a DSL. My usual solution is to generate a
function to process the extra arguments which cannot be passed to the
splice (i.e. push the arguments out of the splice so that I can use
functions defined in the same module).

Nevertheless, I'd like to know if there are any chances of seeing this
problem solved anytime soon.

Thanks,

Alfonso


More information about the template-haskell mailing list