[GHC] #11584: [Template Haskell] Language.Haskell.TH.Syntax.hs contains misleading comment
GHC
ghc-devs at haskell.org
Wed Feb 17 16:10:23 UTC 2016
#11584: [Template Haskell] Language.Haskell.TH.Syntax.hs contains misleading
comment
-------------------------------------+-------------------------------------
Reporter: bollmann | Owner: bollmann
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template Haskell | Version: 7.10.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Documentation | Unknown/Multiple
bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
I don't understand what you are all talking about :)
Try this complete program:
{{{#!hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
g = $(do
nm1 <- newName "x"
let nm2 = mkName "x"
return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2)))
)
main = putStrLn $ g "1" "2"
}}}
It outputs `2`, as advertised by the comment in question.
I happened to be looking at this the other day for unrelated reasons.
`mkName "x"` means "whatever variable of name `x` is in scope", and
`newName "x"` returns a new variable whose name is `x`. It is a different
variable than is returned by other calls to `newName "x"`, but all of them
capture the name `x` as far as `mkName` is concerned. As far as I can tell
it's all exactly as explained in that comment.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11584#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list