[Template-haskell] Template Haskell and Hydra

Tim Sheard sheard@cse.ogi.edu
Mon, 20 Jan 2003 09:29:17 -0800


At 04:15 PM 1/20/2003 +0000, John O'Donnell wrote:
>To support this kind of transformation, it would be necessary to allow
>top level definitions to be reified, but I think it might be best to go
>farther, and allow an entire module to be reified.

Can I suggest a simple work around for top-level function reification that
we might strive for as an interim method. Why not do something like this

d1 = [d| f1 :: Clocked a => a -> a -> (a,a)
          f1 a b = (x, z)
            where (x,y) = (f2 a y, f3 b x)
                   z = f4 a (f5 x y) z
      |]

f1 = splice d1

I.e. for every important function that you want to reify, define its
representation, not the function itself.  Then you can get the function
by simply splicing in the representation. Now you have both the
representation and the function, and they both flow from the same
source so you know they're consistent. You can also manipulate the
representation at will.

To make this practical we have to implement the declaration brackets
[d| ... |]  and everything else follows from what's already built.

Tim Sheard