[GHC] #13776: -ddump-splices produces unnecessarily qualified names for tuple and list types

Soham Chowdhury chow.soham at gmail.com
Sat Mar 17 19:17:39 UTC 2018


That sounds great! I never got around to working on this myself, feel free
:)

On Sun, Mar 18, 2018, 00:45 GHC <ghc-devs at haskell.org> wrote:

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


More information about the ghc-devs mailing list