Obtaining the declaration of a variable name.
Hi, The reification information of a variable is declared as: VarI Name Type (Maybe Dec) Fixity When I began using TH, I thought it was great to be able to retreive the declaration of a variable out of its name (it would have turned out to be pretty useful). However, after testing that reify returned Nothing all the time, I figured out I sadly couldn't count on that. That feature seems to be handy for my compiler again so I tried to guess what was wrong. According to Language.TH.Syntax: -- Nothing for lambda-bound variables, and -- for anything else TH can't figure out -- E.g. [| let x = 1 in $(do { d <- reify 'x; .. }) |] However, the typechecker (TcSplice module) always returns Nothing. So I guess it's simply not implemented. Am I missing something or should I add a feature request ticket? Thanks, Fons
Hi Fons, On Fri, Nov 02, 2007 at 11:36:47PM +0100, Alfonso Acosta wrote:
However, the typechecker (TcSplice module) always returns Nothing. So I guess it's simply not implemented.
Am I missing something or should I add a feature request ticket?
If you are missing it then so am I. File away! I think the idea was that if it is in the same module then we should give you the Dec, but if it is in another module then we don't (we only have the interface file so we don't know what the source code was). We could also have a flag which means the source /is/ put in the interface file. I'm not sure how useful that would be, as the bootlibs would presumably not be compiled with it. Thanks Ian
Ian, Fons, I'll let the two of you agree the details. As to whether the Lift library should be in the GHC distribution, well I don't feel strongly. We are generally moving in the direction of putting less in the distribution, and making it easier to download and install supporting packages; but the TH package isn't big and I wouldn't object. Simon | -----Original Message----- | From: template-haskell-bounces@haskell.org [mailto:template-haskell-bounces@haskell.org] On Behalf Of Ian Lynagh | Sent: 04 November 2007 01:03 | To: Alfonso Acosta | Cc: template-haskell@haskell.org | Subject: Re: [Template-haskell] Obtaining the declaration of a variable name. | | | Hi Fons, | | On Fri, Nov 02, 2007 at 11:36:47PM +0100, Alfonso Acosta wrote: | > | > However, the typechecker (TcSplice module) always returns Nothing. So | > I guess it's simply not implemented. | > | > Am I missing something or should I add a feature request ticket? | | If you are missing it then so am I. File away! | | I think the idea was that if it is in the same module then we should | give you the Dec, but if it is in another module then we don't (we only | have the interface file so we don't know what the source code was). | | We could also have a flag which means the source /is/ put in the | interface file. I'm not sure how useful that would be, as the bootlibs | would presumably not be compiled with it. | | | Thanks | Ian | | _______________________________________________ | template-haskell mailing list | template-haskell@haskell.org | http://www.haskell.org/mailman/listinfo/template-haskell
participants (3)
-
Alfonso Acosta -
Ian Lynagh -
Simon Peyton-Jones