[Template-haskell] Template Haskell and Hydra

John O'Donnell jtod@dcs.gla.ac.uk
20 Jan 2003 18:03:14 +0000


Hi Tim,

Thanks for the suggestion - that certainly would be fine as
an interim solution, and I'll give it a try as soon as
the declaration brackets are implemented.  My impression is
that they aren't there yet?

For a permanent solution, it would still be nice to avoid the
extra notation, but I'd certainly like to get most of the
benefit for just a little work.

Cheers,
John

On Mon, 2003-01-20 at 17:29, Tim Sheard wrote:
> 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
> 
> _______________________________________________
> template-haskell mailing list
> template-haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/template-haskell