More crazy ideas, was Re: [Template-haskell] Pattern reification in Template Haskell

Shae Matijs Erisson shae at
Tue Oct 26 15:33:52 EDT 2004

Sean Seefried <sseefried at> writes:

> 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? 

Ok, I have no idea how to reload existing code. Shadow existing definitions and
compile more?

> 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.

True, but I can't think of another solution that carries around the entire
typechecker. Lauri Alanko mentioned that hs-plugins is only as type-safe as
Dynamics, this was my proposed improvement.

This also beats the problem of having two different type-tables, one static and
one dynamic, and never the twain shall meet.
Even so, Don's recent solution of dynloading everything on a tiny static
core is better there.
Ok, maybe it's not such a great idea :-)

So, next crazy TH idea. Can I use today's version of rType[1] to dump a
TH-evaluable type representation that I can send across a network connection?
In essence, can I make mobile types by using TH to dump the type description,
and hs-plugins to compile and load those type descriptions on another running
RTS that's never seen this type before?

Even if that works, I'm still not sure how to transport functions to actually
work on the new datatypes...

[1] see rType in this post,
Shae Matijs Erisson - Programmer -
"I will, as we say in rock 'n' roll, run until the wheels come off, 
because I love what I do." -- David Crosby

More information about the template-haskell mailing list