[Template-haskell] Pattern reification in Template Haskell

Sean Seefried sseefried at cse.unsw.edu.au
Thu Oct 21 00:41:32 EDT 2004


On 21/10/2004, at 11:11, Shae Matijs Erisson wrote:

> "Simon Peyton-Jones" <simonpj at microsoft.com> writes:
>
>> I do have a bunch of things on my TH to-do list.  Pattern splices 
>> aren't
>> at the top of it, in fact, but name-splicing -- the ability to splice 
>> a
>> name in a binding position -- would be very useful.   But there was so
>> little reaction to my last few messages to this list that TH has 
>> slipped
>> down my priority list.  (Currently I'm busy with GADTs.)  I'm not sure
>> whether the quietness of the TH list is because (a) TH works so well
>> that there's no need to say anything or (b) no one is using it.
>
> I had a crazy idea to emulate hs-plugins' dynamic loading in a 
> completely
> type-safe way by running an entire application in the TH compile loop.
>
> Well, maybe it can still generate code that fails type-checking, but 
> at least
> you get to carry the type-checker around with you, and you don't have 
> to worry
> about separate type tables from static and dynamic linking.
>
> But I could never figure out a good way to turn a source module into a
> template haskell structure...
>
> Also, some other people suggested that it might run very slowly.

Wow, what a crazy idea. Is the basic idea that you have a program that 
never exits the TH compile loop and when dynamic loading is required it 
reads in a source program, places it inside reification brackets and 
then tries to splice it in? Sure this might work, but what about 
unloading such code? Surely this is an important part of hs-plugins? 
This reminds me of getting C++ templates to do things they should be 
doing - it might work but it's surely not the most elegant or user 
friendly solution.

Sean



More information about the template-haskell mailing list