<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">On further inspection, the problem is not with TH but with family instances.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">That is, suppose Library.hs is has the constructors defined in the simple <br></div><div class="gmail_default" style="font-family:monospace,monospace">top-level style:<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">```<br>data EntityField typ where<br> BlobXVal :: EntityField Int<br> BlobYVal :: EntityField Int</div><div class="gmail_default" style="font-family:monospace,monospace">```</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Then when analyzing Client.hs, the lookup function `<a id="gmail-m_-6694891713276807158gmail-m_7294298460795274837gmail-v:hscTcRcLookupName" class="gmail-m_-6694891713276807158gmail-m_7294298460795274837gmail-def">hscTcRcLookupName</a>` WORKS.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">However, if instead, Library.hs defines the constructors within an instance:</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">```<br>instance PersistEntity Blob where<br> data EntityField Blob typ where<br> BlobXVal :: EntityField Blob Int<br> BlobYVal :: EntityField Blob Int<br></div><div class="gmail_default" style="font-family:monospace,monospace">```</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">then, when analyzing Client.hs, the `hscTcRcLookupName` function FAILS.<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Clearly there is some difference in how `hscTcRcLookupName` works in these two cases.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Does someone know what it is?</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Thanks in advance!</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">- Ranjit.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 25, 2018 at 4:24 PM, Ranjit Jhala <span dir="ltr"><<a href="mailto:jhala@cs.ucsd.edu" target="_blank">jhala@cs.ucsd.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div dir="ltr"><div style="font-family:monospace,monospace"><div style="font-family:monospace,monospace">Hi all,</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">I am stuck on the following problem.</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">Suppose you have two module <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace"> Lib <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace"> Client <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">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 <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace"><a id="gmail-m_-6694891713276807158gmail-m_7294298460795274837gmail-v:hscTcRcLookupName" class="gmail-m_-6694891713276807158gmail-m_7294298460795274837gmail-def"> hscTcRcLookupName</a> :: <a href="https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/HscTypes.html#t:HscEnv" target="_blank">HscEnv</a> -> <a href="https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/Name.html#t:Name" target="_blank">Name</a> -> <a href="https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/base-4.10.0.0/System-IO.html#t:IO" target="_blank">IO</a> (<a href="https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/base-4.10.0.0/Data-Maybe.html#t:Maybe" target="_blank">Maybe</a> <a href="https://downloads.haskell.org/~ghc/8.2.1/docs/html/libraries/ghc-8.2.1/Type.html#t:TyThing" target="_blank">TyThing</a>) </div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">defined inside HscMain. <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">**THE PROBLEM** However, I find that when the <br></div><div style="font-family:monospace,monospace">relevant `Name` corresponds to something generated <br></div><div style="font-family:monospace,monospace">by TemplateHaskell (inside `Lib`) then the above `hscTcRcLookupName` fails to return any result! <br></div><div style="font-family:monospace,monospace">Even more oddly, suppose the name was</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace"> BlogPostId <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">If there are TWO `TyThing`s with that name, e.g. <br></div><div style="font-family:monospace,monospace">a type synonym defined <br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace"> type BlogPostId = ...</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">and also a data constructor for a data family <br></div><div style="font-family:monospace,monospace">instance, then `hscTcRcLookupName` only returns <br></div><div style="font-family:monospace,monospace">the type synonym, but refuses to return the data constructor.</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">Does anyone know what may be going on?<br></div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">Thanks!</div><div style="font-family:monospace,monospace"><br></div><div style="font-family:monospace,monospace">- Ranjit Jhala.<div class="gmail-m_-6694891713276807158gmail-yj6qo"></div><div class="gmail-m_-6694891713276807158gmail-adL"><br></div></div><div style="font-family:monospace,monospace"><br></div><br></div></div>
</div></div></blockquote></div><br></div></div>