Generating Haskell with associated types (and kind annotations)

Hi all, I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations. I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds), so for now I've been using ruby with string interpolation, which feels rather ugly. It means that I have to edit the ruby script and regenerate the file in question each time I make a change, which doesn't fit in very nicely with cabal (or my patience) and so on. Ideally, I'd have something that I can write mostly like real Haskell (with "holes" to substitute values into), that can be integrated nicely into the cabal build system without using custom external preprocessors or anything like that. Any ideas? Thanks, Dan

Hi Dan,
I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations.
haskell-src-exts is the answer: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts
From the project description:
"Haskell-Source with Extensions (HSE, haskell-src-exts) is an
extension of the standard haskell-src package, and handles most common
syntactic extensions to Haskell, including: ... Indexed type families
(including associated types)"
I've used the project extensively in HLint
(http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hlint) and
it works fantastically.
Thanks
Neil
On Fri, May 8, 2009 at 4:24 PM, Daniel Peebles
Hi all,
I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds), so for now I've been using ruby with string interpolation, which feels rather ugly. It means that I have to edit the ruby script and regenerate the file in question each time I make a change, which doesn't fit in very nicely with cabal (or my patience) and so on. Ideally, I'd have something that I can write mostly like real Haskell (with "holes" to substitute values into), that can be integrated nicely into the cabal build system without using custom external preprocessors or anything like that.
Any ideas?
Thanks, Dan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Neil,
Thanks for the suggestion! I'd seen the package before, but I couldn't
figure out a good way to integrate it into my codegen situation.
I guess I should write the "skeleton" of the code I want to generate,
get HSE to parse it, and then replace the parts I want to change of
the AST with what I need? Is there a nicer way (TH-like?) to get the
modified AST into GHC than prettyprinting the AST again and asking GHC
to compile the output file?
Thank you,
Dan
On Fri, May 8, 2009 at 11:49 AM, Neil Mitchell
Hi Dan,
I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations.
haskell-src-exts is the answer: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts
From the project description:
"Haskell-Source with Extensions (HSE, haskell-src-exts) is an extension of the standard haskell-src package, and handles most common syntactic extensions to Haskell, including: ... Indexed type families (including associated types)"
I've used the project extensively in HLint (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hlint) and it works fantastically.
Thanks
Neil
On Fri, May 8, 2009 at 4:24 PM, Daniel Peebles
wrote: Hi all,
I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds), so for now I've been using ruby with string interpolation, which feels rather ugly. It means that I have to edit the ruby script and regenerate the file in question each time I make a change, which doesn't fit in very nicely with cabal (or my patience) and so on. Ideally, I'd have something that I can write mostly like real Haskell (with "holes" to substitute values into), that can be integrated nicely into the cabal build system without using custom external preprocessors or anything like that.
Any ideas?
Thanks, Dan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi
I guess I should write the "skeleton" of the code I want to generate, get HSE to parse it, and then replace the parts I want to change of the AST with what I need? Is there a nicer way (TH-like?) to get the modified AST into GHC than prettyprinting the AST again and asking GHC to compile the output file?
This package seems to do some of the bits you want. I've added it to my list of packages to look at in the future: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-meta Thanks Neil

Hi Dan,
I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations. I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds),
I implemented type families (including associated types) and kinds for TH in the HEAD. If there is anything missing that prevents you from using it, please let me know and I'll have a look at it. Manuel
participants (3)
-
Daniel Peebles
-
Manuel M T Chakravarty
-
Neil Mitchell