<div dir="ltr">Hello Matthew,<div><br></div><div>Please see inline<br><div class="gmail_extra"><br><div class="gmail_quote">2017-06-30 11:57 GMT+02:00 Matthew Pickering <span dir="ltr"><<a href="mailto:matthewtpickering@gmail.com" target="_blank">matthewtpickering@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Robin,<br>
<br>
This looks really useful for developers.<br>
<br>
1. Would it be possible to provide a script which allows developers to<br>
build this index for themselves easily?<br></blockquote><div><br></div><div>First, build and install the `ghc_kythe_wrapper` (instructions at <a href="https://github.com/google/haskell-indexer">https://github.com/google/haskell-indexer</a>).</div><div><br></div><div>Then build GHC with `make`, and capture the build log. Here's the hacky script I used: <a href="https://gist.github.com/robinp/222cf3a39cc19178ec8691522056d7fe">https://gist.github.com/robinp/222cf3a39cc19178ec8691522056d7fe</a></div><div><br></div><div>It filters the log and replaces GHC calls to call the wrapper, which emits Kythe entries.</div><div><br></div><div>Finally run `serve.sh` of the repo to postprocess and serve the entries through HTTP.</div><div><br></div><div>This is all pretty new, so feedback or questions welcome. If the method distills, could try to write a more formal guide.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. Is it possible to use this tool to detect dead code? Functions<br>
which are not used anywhere in the compiler.<br></blockquote><div><br></div><div>We'll get there eventually, but for now the emitted data is not fine-grained enough. The main missing piece is recording what are exported entities of a module (Kythe schema discussion in progress). Without this, unused locals (which anyway surface with -Wall) would be presented and noisy.</div><div><br></div><div>Also, one would probably need to postprocess the data a bit for this, like loading into a graph database or other ways.</div><div><br></div><div>Did you see <a href="https://github.com/ndmitchell/weeder">https://github.com/ndmitchell/weeder</a> by the way? Might work.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
3. How are you pretty printing the output whilst retaining the source<br>
formatting? I had a quick look at the source but I couldn't see where<br>
the output was being produced.<br>
<br></blockquote><div><br></div><div>The haskell-indexer-frontend-kythe emits Kythe (<a href="http://kythe.io">http://kythe.io</a>) schema data. We just export the source offsets, and it's the Kythe postprocessing / serving pipeline that does all the formatting.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Cheers,<br>
<br>
Matt<br>
<div><div class="gmail-h5"><br>
On Fri, Jun 30, 2017 at 8:55 AM, Robin Palotai <<a href="mailto:palotai.robin@gmail.com">palotai.robin@gmail.com</a>> wrote:<br>
> Hello GHC devs,<br>
><br>
> I ran haskell-indexer [1] on the GHC 8.0.2 tarball, partly because I find<br>
> myself reading GHC source from time to time while working on the indexer,<br>
> and partly since it's fun.<br>
><br>
> First, here you can click around [2] and find where beloved functions are<br>
> called from:<br>
> <a href="http://stuff.codereview.me/#ghc/compiler/hsSyn/HsBinds.hs?corpus&signature" rel="noreferrer" target="_blank">http://stuff.codereview.me/#<wbr>ghc/compiler/hsSyn/HsBinds.hs?<wbr>corpus&signature</a><br>
> (scroll down a bit, imports are not linked yet).<br>
><br>
> Second, the way I indexed was pretty simple. I took the output of `make`,<br>
> replaced the ghc used with the ghc_kythe_wrapper, and filtered the lines<br>
> which included '-c', since I noticed that those duplicate previous large<br>
> compile lines. This only indexes the stage1 compilation AFAIU.<br>
><br>
> Feel free to suggest a better way to tap into the compilations to get<br>
> everything properly indexed (and possibly only once).<br>
><br>
> Any comments welcome!<br>
> Robin<br>
><br>
> [1]: <a href="https://github.com/google/haskell-indexer" rel="noreferrer" target="_blank">https://github.com/google/<wbr>haskell-indexer</a><br>
><br>
> [2]: TLDR UI quirks:<br>
>   - Click the :: in top-left to navigate file tree<br>
>   - Ctrl-Click (on linux) to go directly to definition (otherwise click<br>
> stuff from bottom pane)<br>
>   - Bottom pane often hides content, close it if stuck.<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> ghc-devs mailing list<br>
> <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
><br>
</blockquote></div><br></div></div></div>