[Template-haskell] Binding again

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Nov 25 18:55:38 EST 2004


I agree with Ian, newName should generate unique names that no not bind
anything else.

Duncan

On Thu, 2004-11-25 at 18:41 +0000, Ian Lynagh wrote:
> On Thu, Nov 25, 2004 at 02:06:27PM -0000, Simon Peyton-Jones wrote:
> > In looking into my TH bug stack, I've found the following question.
> 
> Here's what I think should happen:
> 
> > Suppose we have
> > 
> > d1 :: Q [Dec]
> > d1 = return [FunD (mkName "f") ...]
> > 
> > d2 :: Q [Dec]
> > d2 = do { fn <- newName "f"; return [FunD fn ...] }
> > 
> > QUESTION 1: is this OK:
> > 
> > 	$d1
> > 	h = f 3
> > 
> > QUESTION 2: What about this?
> > 
> > 	$d2
> > 	h = f 3
> > 
> > The answer to Q1 must presumably be 'yes',
> 
> Yes - mkName "f" gives you the same name as just writing f.
> 
> > but what about Q2.  "newName"
> > generates a fresh name, to be sure, but does it bind the 'f' in the
> > subsequent declaration.
> 
> No - here you have created a name that only looks a bit like f - it is
> not the same as f. In fact, were you to pprint the above you should get
> something like
> 
>     f_4 = ...
>     h = f 3
> 
> The only way to refer to a newName is with the result of that call.



More information about the template-haskell mailing list