[Haskell-cafe] Re: Re: Re: Reflective capabilities of Haskell
(cont'd)
Martin Hofmann
martin.hofmann at uni-bamberg.de
Thu Mar 13 05:59:15 EDT 2008
On Wed, 2008-03-12 at 15:59 -0400, Jeff Polakow wrote:
> > Data.Generics allows you to do this (to a certain extent), i.e.
> > there is a function
> >
> > dataTypeConstrs :: DataType -> [Constr]
> >
> It might be hard, or even impossible, to get Data.Typeable and
> Data.Generics to play with each other. There seems to be no good way
> of converting a Data.Typeable.TypeRep to a
> Data.Generics.Basics.DataType.
>
> Another option might be to use Language.Haskell.Parser and
> Language.Haskell.Syntax, but I have little experience with this and am
> not sure if you'll be able to do what you want.
>
On Wed, 2008-03-12 at 23:08 -0700, oleg at okmij.org wrote:
> > Thanks a lot, this helps a bit, but access to function bodies is exactly
> > what I need
> Then perhaps you might like the method of reconstructing bodies (of
> possibly compiled) functions
> http://okmij.org/ftp/Computation/Generative.html#diff-th
> in the form of AST -- the template Haskell AST. The reconstructed
> bodies of functions can be arbitrarily manipulated (e.g.,
> _symbolically_ differentiated or algebraically simplified) and then
> converted `back' to the compiled code.
Thanks for the hints, they all seem to be promising, at least for some part of my problem. I'll try it out whether I can put them together.
Cheers,
Martin
More information about the Haskell-Cafe
mailing list