FW: [Template-haskell] TH restrictions

Simon Peyton-Jones simonpj at microsoft.com
Fri Nov 19 04:28:55 EST 2004


| > Does anyone care? I'm busy implementing GADTs at the moment, so TH
has a
| > somewhat back seat.  It'll probably stay that way unless there are
some
| > signs of life in the TH ranks.
| 
| For what it's worth, I think one of the biggest irritations I've had
| with writing stuff using TH is the need to split things across module
| boundaries. This often leads to things that should logically be in the
| same module being split

I agree with this; I'd like to know how much it affects other people
too.

It's tricky to implement, though.  I don't really want to compile each
definition to byte code as we encounter it, just in case the next
definition contains a splice.  (That would slow down every single
compilation, whether or not it used TH.)  I guess I could look ahead to
see if there was a splice in the next definition group, and if so
compile the entire module up to that point.  Even that isn't usually
necessary, because the splice may not call anything defined earlier.
Perhaps one could compute the transitive closure of things needed.

So it'd be real work.  What do others think?

| Also, I think this has got worse at some point. Going back over some
of
| my old code it looks like this sort of thing:
| 
|     foo = and
|     bar = [| foo |]
| 
| in one module used to be OK whereas now it gives
| 
|     No instance for (Language.Haskell.TH.Syntax.Lift ([Bool] -> Bool))

This looks like a bug -- I'll try to fix it.

Simon


More information about the template-haskell mailing list