[Haskell-cafe] Generating Haskell with associated types (and kind annotations)

Daniel Peebles pumpkingod at gmail.com
Fri May 8 13:46:58 EDT 2009

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,

On Fri, May 8, 2009 at 11:49 AM, Neil Mitchell <ndmitchell at gmail.com> wrote:
> 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 <pumpkingod at gmail.com> 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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list