My module contains definitions, part of which are exported (in module
clause). I want to export Template Haskell-generated declarations too. But since there is seemingly no way to modify module
clause with TH, I cannot do this.
Is it possible to specify that TH-generated declarations should be exported at all? Or maybe there are other ways to do this?
You need to export the names of the generated TH declarations. For example, if you have a TH function that generates a
data B = C | D
declaration, you need to simply exportmodule Mymodule (B(C,D)) where ...
.If you don't specify an export list, all declarations in that module will be exported. What you can do as a little trick is to put all of your generated TH functions in one module, and then reexport that module:
This has the disadvantage that you can't put haddock documentation for generated functions, but that's not something you usually do anyways.