<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Dear Joachim,</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">You are right -- some more context.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Given </div><div class="gmail_default" style="font-family:monospace,monospace"> </div><div class="gmail_default" style="font-family:monospace,monospace"> tc :: TyCon </div><div class="gmail_default" style="font-family:monospace,monospace"> m :: ModName</div><div class="gmail_default" style="font-family:monospace,monospace"> env :: HscEnv </div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">I want to get a </div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"> s :: String </div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">such that _in_ the context given by `m` and `env` I can resolve `s` to get</div><div class="gmail_default" style="font-family:monospace,monospace">back the original `TyCon`, e.g. something like</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"><div class="gmail_default"> L _ rn <- hscParseIdentifier env s</div><div class="gmail_default"> name <- lookupRdrName env modName rn</div><div class="gmail_default"><br></div><div class="gmail_default">would then return `name :: Name` which corresponds to the original `TyCon`.</div><div class="gmail_default"><br></div><div class="gmail_default">That is, the goal is _not_ pretty printing, but "serialization" into a String</div><div class="gmail_default">representation that lets me recover the original `TyCon` later.</div><div class="gmail_default"><br></div><div class="gmail_default">(Consequently, `"Data.Set.Base.Set"` doesn't work as the `Data.Set.Base` module is hidden and hence, when I try the above, GHC complains that the name is not in scope.</div><div class="gmail_default"><br></div><div class="gmail_default">Does that clarify the problem?</div><div class="gmail_default"><br></div><div class="gmail_default">Thanks!</div><div class="gmail_default"><br></div><div class="gmail_default">- Ranjit.</div><div class="gmail_default"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 24, 2017 at 6:11 PM, Joachim Breitner <span dir="ltr"><<a href="mailto:mail@joachim-breitner.de" target="_blank">mail@joachim-breitner.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ranjit,<br>
<span class=""><br>
Am Dienstag, den 24.01.2017, 16:09 -0800 schrieb Ranjit Jhala:<br>
> My goal is to write a function<br>
><br>
> tyconString :: TyCon -> String <br>
><br>
> (perhaps with extra parameters) such that given the <br>
> `TyCon` corresponding to `Set`, I get back the "original" <br>
> name `S.Set`, or even `Data.Set.Set`. <br>
><br>
> Everything I've tried, which is fiddling with different variants of<br>
> `PprStyle`, end up giving me `Data.Set.Base.Set`<br>
><br>
> Does anyone have a suggestion for how to proceed?<br>
<br>
</span>in a way, `Data.Set.Base.Set` is the “original”, proper name for Set,<br>
everything else is just a local view on the name.<br>
<br>
So, are you maybe looking for a way to get the “most natural way” to<br>
print a name in a certain module context?<br>
<br>
This functionality must exist somewhere, as ghci is printing out errors<br>
this way. But it certainly would require an additional argument to<br>
tyconString, to specify in which module to print the name.<br>
<br>
Greetings,<br>
Joachim<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Joachim “nomeata” Breitner<br>
<a href="mailto:mail@joachim-breitner.de">mail@joachim-breitner.de</a> • <a href="https://www.joachim-breitner.de/" rel="noreferrer" target="_blank">https://www.joachim-breitner.<wbr>de/</a><br>
XMPP: <a href="mailto:nomeata@joachim-breitner.de">nomeata@joachim-breitner.de</a> • OpenPGP-Key: 0xF0FBF51F<br>
Debian Developer: <a href="mailto:nomeata@debian.org">nomeata@debian.org</a></font></span><br>______________________________<wbr>_________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.<wbr>org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/glasgow-<wbr>haskell-users</a><br>
<br></blockquote></div><br></div>