[Template-haskell] Re: template-haskell names in 6.3

Keean Schupke k.schupke at imperial.ac.uk
Fri Dec 3 09:38:01 EST 2004


Simon Peyton-Jones wrote:

>do you mean 
>	n <- newName s
>or
>	let n = mkName s
>?
>  
>
I mean the latter... or perhaps: "n <- return $ mkName s"... 

>If the latter, you will get 
>	data Foo = Foo Foo
>
>... and then I see what you want.  You want a version of mkName that is
>like giving a qualified name in Haskell.  It's dynamically scoped just
>like mkName, but it obeys the usual rules for qualified names in
>Haskell.
>
>To be totally explicit, suppose I have
>
>	foo = [| mkQualName "Foo" "baz" |]
>
>then if I call foo thus
>
>	wibble = \baz -> $foo
>
>the $foo splice will expand to "Foo.baz", and that won't see the \baz;
>it'll see whatever Foo.baz is in scope.
>  
>
This is exactly what I am after...

>Is that what you seek?  I can see it's reasonable.  I'd need to add
>
>	mkQualName :: String -> String -> Name
>
>That'd mean an extra form of Name.  Currently, if you say
>	'Foo.baz
>you'll get a Name whose nameModule isn't necessarily Foo... it'll be the
>module that baz was actually defined in.  
>  
>
I'll leave that up to you, I don't mind if this translation happens, as
long as it refers to the Foo.baz in dynamic scope the actuall name
can change.

    Keean


More information about the template-haskell mailing list