TH generating multi module code

Hi,

I am going to generate Haskell functions for MsSql API with TemplateHaskell. Some SQL functions are supper overload with sub variants which produces thousands of Haskell functions for a single SQL function, so I would like to split functions in Haskell modules, but Haskell cannot have multiple modules in one file.
Is there a loophole for Template Haskell to include source files (not blob files)?
With IO actions such writing to files out of TH there is no problem.

Split your generator into multiple functions? You can reuse common parts if you define them in some other module.

If you really need one generator for multiple targets, consider generating a file with the source code.

1 Like