Re: Binding again

Duncan Coutts <[email protected]>
Newsgroups gmane.comp.lang.haskell.template
Message-ID <1101426938.15686.8.camel@localhost>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.