That sounds great! I never got around to working on this myself, feel free :)<br><br><div class="gmail_quote"><div dir="ltr">On Sun, Mar 18, 2018, 00:45 GHC <<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">#13776: -ddump-splices produces unnecessarily qualified names for tuple and list<br>
types<br>
-------------------------------------+-------------------------------------<br>
Reporter: RyanGlScott | Owner: mrkgnao<br>
Type: bug | Status: new<br>
Priority: normal | Milestone:<br>
Component: Template Haskell | Version: 8.0.1<br>
Resolution: | Keywords: newcomer<br>
Operating System: Unknown/Multiple | Architecture:<br>
| Unknown/Multiple<br>
Type of failure: None/Unknown | Test Case:<br>
Blocked By: | Blocking:<br>
Related Tickets: | Differential Rev(s):<br>
Wiki Page: |<br>
-------------------------------------+-------------------------------------<br>
<br>
Comment (by ckoparkar):<br>
<br>
I'd like to work on this, if that's OK with @mrkgnao.<br>
<br>
I have a patch on my local machine<br>
that does the right thing for the examples posted in the<br>
description (and some tests: `th/T3319`, `th/T5700`,<br>
`th/TH_foreignInterruptible`).<br>
While I work on submitting that on Phabricator, I wanted to post a summary<br>
here and get some early feedback.<br>
<br>
<br>
(1) It seems that `showName` doesn't play a role in pretty-printing the<br>
splices<br>
with `-ddump-splices`. Instead, the `Outputable` instances in GHC do most<br>
of the<br>
work. Specifically, `Outputable RdrName` is responsible for printing out<br>
the fully<br>
qualified names in question.<br>
<br>
(2) When the Renamer typechecks & runs a splice (`RnSplice.runRnSplice`),<br>
it<br>
converts the splice to `HsSyn RdrName` (hence the `Outputable RdrName`).<br>
`TcSplice.lookupThName` is involved in the process, which converts<br>
a `TH.Name` to `Name` via `Convert.thRdrNameGuesses`.<br>
<br>
(3) For primitives like `[]`, `(:)` etc. `TH.dataToQa` generates a fully<br>
qualified<br>
global name, i.e `NameG NameSpace PkgName ModName`.<br>
And the corresponding `RdrName` generated by `thRdrNameGuesses` is also<br>
fully<br>
qualified (`Orig Module OccName`). But this is not what we want for built-<br>
in syntax.<br>
<br>
(4) So the "patch" is a simple change to modify this behavior. If<br>
`thOrigRdrName` is<br>
dealing with built-in syntax, it returns an `Exact Name` instead.<br>
<br>
{{{#!haskell<br>
<br>
thOrigRdrName :: String -> TH.NameSpace -> PkgName -> ModName -> RdrName<br>
thOrigRdrName occ th_ns pkg mod =<br>
let occ' = mk_occ (mk_ghc_ns th_ns) occ<br>
in case isBuiltInOcc_maybe occ' of<br>
Just name -> nameRdrName name<br>
Nothing -> (mkOrig $! (mkModule (mk_pkg pkg) (mk_mod mod))) $! occ'<br>
<br>
}}}<br>
<br>
I ran the testsuite, and apart from some `perf` tests, almost everything<br>
else worked.<br>
<br>
These tests fail:<br>
<br>
{{{<br>
ghci/linking/ghcilink003.run ghcilink003 [bad exit code] (normal)<br>
<br>
ghci/linking/ghcilink006.run ghcilink006 [bad exit code] (normal)<br>
<br>
th/T13366.run -- (gcc: error trying to exec 'cc1plus':<br>
execvp:<br>
-- No such file or directory)<br>
}}}<br>
<br>
but there's a good chance that this is unrelated to the patch.<br>
<br>
<br>
Does the overall approach seem reasonable ? I'll submit a patch soon.<br>
<br>
--<br>
Ticket URL: <<a href="http://ghc.haskell.org/trac/ghc/ticket/13776#comment:5" rel="noreferrer" target="_blank">http://ghc.haskell.org/trac/ghc/ticket/13776#comment:5</a>><br>
GHC <<a href="http://www.haskell.org/ghc/" rel="noreferrer" target="_blank">http://www.haskell.org/ghc/</a>><br>
The Glasgow Haskell Compiler<br>
</blockquote></div>