Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generating Template Haskell code #57

Open
wavewave opened this issue Nov 3, 2019 · 2 comments
Open

Support for generating Template Haskell code #57

wavewave opened this issue Nov 3, 2019 · 2 comments

Comments

@wavewave
Copy link
Contributor

wavewave commented Nov 3, 2019

I am wondering whether generating TH code (splice expression) is possible in current implementation, and if not, is the support for TH planned? Thanks!

@judah
Copy link
Collaborator

judah commented Nov 3, 2019

Thanks for the feature request! We don't have combinators for splices, but at first glance they look pretty reasonable to add to our API.

Out of curiosity, what is your intended use of them? In my use in the past I've been doing all of the codegen with ghc-source-gen itself, so there was no need for TH's codegen. But I can see how this would be useful to interact with another library that already provides a TH API.

@wavewave
Copy link
Contributor Author

wavewave commented Nov 3, 2019

Thank you for considering the addition!

My use case is to autogenerate of Haskell code for binding to C++ template code. C++ part is wrapped as C macro, and the TH haskell code is generating a name for FFI function. In that case, at the code gen time, there is no way to know the FFI function name, i.e. template instantiation time is after code generation. Therefore, supporting code generation of TH code is needed. (meta-meta-programming :-) )
Here is where I implemented it:
https://github.com/wavewave/fficxx/blob/21487f389b9f88cad6f506fb0db06534ed96bc28/fficxx/lib/FFICXX/Generate/Code/HsTemplate.hs#L65-L86
and here is where I need a combinator for TH.
https://github.com/wavewave/fficxx/blob/21487f389b9f88cad6f506fb0db06534ed96bc28/fficxx/lib/FFICXX/Generate/Code/Primitive.hs#L756
Thank you for your great library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants