<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI Emoji";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.Code, li.Code, div.Code
        {mso-style-name:Code;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:9.0pt;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.gmail-im
        {mso-style-name:gmail-im;}
span.gmail-
        {mso-style-name:gmail-;}
span.gmail-hoenzb
        {mso-style-name:gmail-hoenzb;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-top:6.0pt;
        margin-right:0cm;
        margin-bottom:6.0pt;
        margin-left:0cm;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:36.0pt">Mainly, we need information on every Token that appears in the original source.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Good idea.  Alan Zimmerman’s exact-print stuff has precisely that goal, I believe.   So it’d be worth talking to him; perhaps by working together you can make much more rapid progress.  Or not – but a conversation
 would be helpful in any case.  I’m very happy to see more attention and effort being devoted to this space.  Thank you!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Zubin Duggal <zubin.duggal@gmail.com>
<br>
<b>Sent:</b> 15 May 2018 10:13<br>
<b>To:</b> Simon Peyton Jones <simonpj@microsoft.com><br>
<b>Cc:</b> Gershom B <gershomb@gmail.com>; ghc-devs@haskell.org; Joachim Breitner <mail@joachim-breitner.de>; Shayan Najd <sh.najd@gmail.com>; Alan & Kim Zimmerman <alan.zimm@gmail.com><br>
<b>Subject:</b> Re: HIE Files<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
And that in turn raises the questions of WHAT syntax tree.  HsSyn?  Template Haskell?  Haskell-src-exts?  Or something new?   Shayan and Alan are busy parameterising HsSyn to make it non-GHC-specific, and directly usable for this kind of endeavour ("Trees that
 grow").  It'd be great to build on their work.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
Mainly, we need information on every Token that appears in the original source. My plan is to further group Tokens into a simple rose-tree based on how they occur in HsSyn. We intentionally want to avoid capturing too much information so the format doesn't
 change much with changes to the GHC AST. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I've made a file describing roughly what the data structures involved should look like<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fwz1000%2Fedf14747bd890b08c01c226d5bc6a1d6&data=02%7C01%7Csimonpj%40microsoft.com%7C5801941ba48648e4206008d5ba441605%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636619723949664358&sdata=PR4Y9%2FYfXl5ubStTbKXRkmtosP%2Fn9GiXRhZrfokwfZY%3D&reserved=0">https://gist.github.com/wz1000/edf14747bd890b08c01c226d5bc6a1d6</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
The plan is to group the Tokens together in a tree in way similar to what structured-haskell-mode does. (The gifs in the following link might provide some idea)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fchrisdone%2Fstructured-haskell-mode%2F&data=02%7C01%7Csimonpj%40microsoft.com%7C5801941ba48648e4206008d5ba441605%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636619723949674367&sdata=sQzFKVRTcL82CNIxFi2A7fbdP4zyzReXPM1kkUoiaN0%3D&reserved=0">https://github.com/chrisdone/structured-haskell-mode/</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
For example, here is what structured-haskell-mode outputs for a small snippet of code:
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fwz1000%2Fdb42d4f533ba7d2345934906b312f743&data=02%7C01%7Csimonpj%40microsoft.com%7C5801941ba48648e4206008d5ba441605%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636619723949684376&sdata=e9OoLIRFfa2JCmLAf99LfT1Sqc8UFMDN2lIIu10QVBg%3D&reserved=0">
https://gist.github.com/wz1000/db42d4f533ba7d2345934906b312f743</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm">
We want something similar for the HIE AST, but grouped into a tree, where each node(roughly corresponding to HsSyn constructors) points to all the subnodes and tokens it spans over.<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
That's great.  But would it not be good to offer a library, with a well-defined API, that allows a client (including Haddock) to parse those .hie files into syntax trees or whatever?  You'll need to do that to allow the haddock thing you describe -- and it'd
 be much better to make the parser (and doubtless lots of utility function like finding things in the tree) available to any client not just haddock.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Yes, a library to consume these files is definitely something we need, and I believe it will grow out naturally as we work out the integration with haddock and haskell-ide-engine.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<br>
On 15 May 2018 at 14:12, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<span class="gmail-">|  > Why not put the .hie-file info into the .hi file?  (Optionally, of</span><br>
<span class="gmail-">|  > course.)</span><br>
<span class="gmail-">|  ></span><br>
<span class="gmail-">|  </span><br>
<span class="gmail-">|  Simon, I'm curious what benefits you think we might get from this?</span><br>
<span class="gmail-">|  (I'm one of the mentors on this GSoC project btw).</span><br>
<br>
Well, I've always thought that we should really put the .hi file into the .o file!  Having two files risks getting things out of sync, and three makes that worse.  The file is just a place to keep a blob of info.  What's the motivation for having two .hie as
 well as .hi?<br>
<br>
<span class="gmail-">|  </span><br>
<span class="gmail-">|  > What tools/libraries do you plan to produce to allow clients to read</span><br>
<span class="gmail-">|  a .hie file and make send of the contents?</span><br>
<span class="gmail-">|  </span><br>
<span class="gmail-">|  For GSoC as a proof of concept the idea is to teach haddock's</span><br>
<span class="gmail-">|  hyperlinked-source backend to use this information to add type-</span><br>
<span class="gmail-">|  annotation-on-hover to the colorized, hyperlinked, html source.</span><br>
<br>
That's great.  But would it not be good to offer a library, with a well-defined API, that allows a client (including Haddock) to parse those .hie files into syntax trees or whatever?  You'll need to do that to allow the haddock thing you describe -- and it'd
 be much better to make the parser (and doubtless lots of utility function like finding things in the tree) available to any client not just haddock.<br>
<br>
And that in turn raises the questions of WHAT syntax tree.  HsSyn?  Template Haskell?  Haskell-src-exts?  Or something new?   Shayan and Alan are busy parameterising HsSyn to make it non-GHC-specific, and directly usable for this kind of endeavour ("Trees that
 grow").  It'd be great to build on their work.<br>
<br>
<span class="gmail-">|  with the GHC API. (This by the way is one of the key benefits of</span><br>
<span class="gmail-">|  keeping the file separate from standard hi files -- it should be</span><br>
<span class="gmail-">|  parseable and consumable without needing to link in GHC).</span><br>
<br>
Yes, not linking in GHC is a reasonable goal; but having two files and file formats is not a necessary consequence of that goal.  Nothing stops us making a library to parse .hi files -- indeed the entire iface/ directory in GHC is quite well separated for that
 precise purpose.<br>
<br>
None of this is to criticise the plan.  I think it's a great idea to make more info more readily available to more tools.   I'm just poking at it a bit
<span style="font-family:"Segoe UI Emoji",sans-serif">😊</span>.<br>
<span style="color:#888888"><br>
<span class="gmail-hoenzb">Simon</span></span><o:p></o:p></p>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>