(Failing to) look up names generated by Template Haskell
Ranjit Jhala
jhala at cs.ucsd.edu
Fri Jan 26 00:24:50 UTC 2018
Hi all,
I am stuck on the following problem.
Suppose you have two module
Lib
Client
where Client "imports" Lib. Now, while analyzing the Core of `Client` often
I need to resolve the name of a `TyThing` defined inside `Lib`. Normally,
this is easy enough: I simply use
hscTcRcLookupName :: HscEnv
<https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/HscTypes.html#t:HscEnv>
-> Name
<https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/Name.html#t:Name>
-> IO
<https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/base-4.10.0.0/System-IO.html#t:IO>
(Maybe
<https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/base-4.10.0.0/Data-Maybe.html#t:Maybe>
TyThing
<https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/Type.html#t:TyThing>
)
defined inside HscMain.
**THE PROBLEM** However, I find that when the
relevant `Name` corresponds to something generated
by TemplateHaskell (inside `Lib`) then the above `hscTcRcLookupName` fails
to return any result!
Even more oddly, suppose the name was
BlogPostId
If there are TWO `TyThing`s with that name, e.g.
a type synonym defined
type BlogPostId = ...
and also a data constructor for a data family
instance, then `hscTcRcLookupName` only returns
the type synonym, but refuses to return the data constructor.
Does anyone know what may be going on?
Thanks!
- Ranjit Jhala.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20180125/cddae427/attachment.html>
More information about the Glasgow-haskell-users
mailing list