<div dir="ltr">Fair enough --- though it's annoying that GHC can offer me exactly the information I want in an error message, but then force me to duplicate the logic to find those things for myself!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 29, 2019 at 12:20 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">





<div lang="EN-GB">
<div class="gmail-m_-1515017381312084082WordSection1">
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:36pt">
Simon, my reasoning here is that holes are the only place GHC will mention relevant bindings. I'd definitely prefer to put all of the relevant local bindings in scope for _every_ HsVar, but that seemed less  amenable to being merged :)<u></u><u></u></p>
<p class="MsoNormal"><span>I didn’t explain myself well enough.  No need to merge anything. 
<b>Your tooling</b> can accumulate these bindings as it walks the tree -- no need for GHC to do anything.   Eg<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>myTooling env (HsLam (HsVar x) e) = myTooling (extend env x) e<u></u><u></u></span></p>
<p class="MsoNormal"><span>myTooling env <expr of interest>    = <do something with expr of interest, knowing all in-scope binding s in env><u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>Simon<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Sandy Maguire <<a href="mailto:sandy@sandymaguire.me" target="_blank">sandy@sandymaguire.me</a>>
<br>
<b>Sent:</b> 29 August 2019 06:37<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> Sandy Maguire <<a href="mailto:sandy@sandymaguire.me" target="_blank">sandy@sandymaguire.me</a>>; <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: Getting a hole's relevant local binds?<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
Simon, my reasoning here is that holes are the only place GHC will mention relevant bindings. I'd definitely prefer to put all of the relevant local bindings in scope for _every_ HsVar, but that seemed less  amenable to being merged :)<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
On Wed, Aug 28, 2019 at 4:56 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-left:36pt">
how receptive would y'all be to a patch that puts the `TcLclEnv`, or something similar inside `XUnboundVar GhcTc`.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">That sounds plausible.   But is an unbound-var the only place an editor/IDE tooling might want to get its hands on such a thing?   ie would that solve your problem, but not the
 next person’s?<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Also note that you could easily build up a list of all the in-scope Ids simply by gathering them from the tree as you walk inwards.  There’s no actual need for a new function --
 although I can see it might be more convenient.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Simon<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>>
<b>On Behalf Of </b>Sandy Maguire<br>
<b>Sent:</b> 18 August 2019 01:28<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Getting a hole's relevant local binds?</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">Hi all,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:6pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">I'm trying to get my hands on the relevant local binds (as reported by ghc in the presence of a type hole) for editor tooling support. Tracing the code suggests that these things come
 from the `TcLclEnv`, but afaict, all remnants of `TcLclEnv` are thrown away by the time we get a `TypecheckedModule`.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">Am I mistaken in this? If not, how receptive would y'all be to a patch that puts the `TcLclEnv`, or something similar inside `XUnboundVar GhcTc`. This way editors would have an easy means
 of getting their hand on whatever is in scope at the site of a hole, without resorting to parsing error messages.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">Sandy<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:6pt"> <u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:6pt">-- <u></u>
<u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6pt">I'm currently traveling the world, sleeping on people's couches and doing full-time collaboration on Haskell projects. If this seems interesting to you, please consider signing up as a
 host! <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fisovector.github.io%2Ferdos%2F&data=02%7C01%7Csimonpj%40microsoft.com%7Cd7c51847a19c4d6aa84208d72c42e32b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637026538110642901&sdata=UClCONCXwkap3HhQ5hZroULJ67uy08UsndYgsrIcvxg%3D&reserved=0" target="_blank">https://isovector.github.io/erdos/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">I'm currently traveling the world, sleeping on people's couches and doing full-time collaboration on Haskell projects. If this seems interesting to you, please consider signing up as a host! <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fisovector.github.io%2Ferdos%2F&data=02%7C01%7Csimonpj%40microsoft.com%7Cd7c51847a19c4d6aa84208d72c42e32b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637026538110652887&sdata=koBEz03JagWpN7NeS9qbBWqpUK5psZoGoz7fwQxgGp8%3D&reserved=0" target="_blank">https://isovector.github.io/erdos/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>I'm currently traveling the world, sleeping on people's couches and doing full-time collaboration on Haskell projects. If this seems interesting to you, please consider signing up as a host! <a href="https://isovector.github.io/erdos/" target="_blank">https://isovector.github.io/erdos/</a><br></div></div></div>