
| The problem is that the RdrNames carried in the HsExpr are not found | in the Renamer environment. To give you an example | | foobar = | $(return (InternalE (HsVar (mkUnqual varName | (mkFastString "myfoo"))))) | | which should in the overall result "foobar = myfoo" | | Running this gives me a "Not in scope" error but the myfoo variable is | obviously in the global environment as running this with | -ddump-rn-trace shows: Well that is indeed puzzling, but you are doing something quite tricky here. In TH, a TH splice uses only data types and functions declared in the TH library. But your splices use data types declared in GHC itself. I'm not quite sure how you make the compilation and linking stuff work out, but you certainly need to take great care that the TH splice code is uses the same data types, compiled in the same way, as the compiler it's linked with. Yes, it's hard to think about; I don't have it fully paged in myself. So the ice is thin. I can't account for the behaviour you are seeing -- but I can't see how to help you more. Perhaps do the HsVar and VarE thing in the *same* expression (in a pair, say), and confirm that they do generate the same HsExpr. Then start tracing the global envt lookup and its results. Simon | | test.hs:49:7: | Not in scope: `myfoo{v}' | Global envt is: | [cut] | myfoo{v}: main:MyAdd.myfoo{v rI9} imported from MyAdd at test.hs:13:20-24 | [cut] | | In contrast, the TH variant works without any flaws: | | $(return (VarE (mkName "myfoo"))) | | I assert that the VarE variant and the InternalE variant are converted | to exactly the same HsExpr by hsSyn/Convert.lhs. Using -ddump-slices | -dppr-debug shows that both splices generate "myfoo{v}". | | Using a few more hacks, I even made sure that the printed FastStrings | "myfoo" are equal in terms of "getKey# (getUnique str)", this pretty | much rules out a bug in UniqFM.hs. | | Does anyone (especially the developers that are intimate with TH and | HsSyn) know what could be the cause? I spent twelve fruitless hours | searching for the cause. | | Many thanks in advance, | --- | Fruhwirth Clemens - http://clemens.endorphin.org | for robots: sp4mtrap@endorphin.org | | | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users