#4429: Ability to specify the namespace in mkName
---------------------------------+------------------------------------------
    Reporter:  reinerp           |        Owner:              
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  Template Haskell  |      Version:  6.12.3      
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Old description:

> Given
>
> {{{
> data Foo
> data Bar = Foo
> }}}
>
> If we do {{{reify (mkName "Foo")}}} then we get the information about
> "{{{Foo}}} the type", and not about "{{{Foo}}} the constructor".
>
> (This is problematic, say, for a quasiquoter
>
> {{{ [qq| ... Foo ... |] }}}
>
> because the quasiquoter is forced to use {{{mkName "Foo"}}} as the
> {{{Name}}} for reify -- the forms {{{'Foo}}} and {{{''Foo}}} are
> unavailable to it.)
>
> I would like a way around this problem. It seems like it would be enough
> to communicate the namespace to {{{mkName}}}, so that the ambiguity no
> longer exists.

New description:

 Given

 {{{
 data Foo
 data Bar = Foo
 }}}

 If we do {{{reify (mkName "Foo")}}} then we get the information about
 "{{{Foo}}} the type", and not about "{{{Foo}}} the constructor".

 (This is problematic, say, for a quasiquoter
 {{{
 [qq| ... Foo ... |]
 }}}

 because the quasiquoter is forced to use {{{mkName "Foo"}}} as the
 {{{Name}}} for reify -- the forms {{{'Foo}}} and {{{''Foo}}} are
 unavailable to it.)

 I would like a way around this problem. It seems like it would be enough
 to communicate the namespace to {{{mkName}}}, so that the ambiguity no
 longer exists.

--

Comment(by simonpj):

 I think `mkName` is the wrong thing for you here.   Fundamentally, you
 want to get the `TH.Name` of the data type called "Foo" that is currently
 in scope, yes?  You could give that `Name` to `reify`, or you could use it
 in a type.  Suppose we had
 {{{
 lookupType  :: String -> Q Name
 lookupValue :: String -> Q Name
 }}}
 that were like `mkName` except that (a) they are monadic, and (a) they
 expect the string to be in scope.  The would be the precise monadic
 equivalents of `'Foo` and `''Foo`. Would that do the job?

 Anyone else have comments?

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4429#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to