<div dir="ltr">I've answered all these questions (I hope) in the form of new Notes and signposts, please feel free to comment on this diff: <a href="https://phabricator.haskell.org/D2358">https://phabricator.haskell.org/D2358</a>.  I'm happy to add more if needs be.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 22 June 2016 at 16:39, Richard Eisenberg <span dir="ltr"><<a href="mailto:eir@cis.upenn.edu" target="_blank">eir@cis.upenn.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On Jun 22, 2016, at 10:38 AM, Simon Marlow <<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>> wrote:<br>
<br>
> Thanks for the feedback Richard.  It's helpful to know which parts of the implementation you found non-obvious.  I will write some more Notes, but first:<br>
<br>
</span>I think what would help most is a place that describes the little state machine that's going on here: the startTH / runTH / finishTH cycle, with possible callbacks in between. All RPC calls are blocking, yes? That certainly simplifies the matter. In the state machine, I think it would help to see clearly what causes the state transition (e.g. splice encountered during renaming, reify call made during splicing) and where the code is located (both source file/function and client vs server). There's just a bunch of moving parts here spread across a number of files and two processes.<br>
<span class=""><br>
><br>
> * On why we need a RemoteRef of an IORef - because the IORef lives on the server, so GHC has a RemoteRef to it.   Did you see Note [External GHCi pointers] in compiler/ghci/GHCi.hs?  Does that help?<br>
<br>
</span>Somewhat. So the server is sending a pointer (the IORef) to the client? Presumably this pointer is only usable on the server, so the client just ends up sending it back at some point. From the client's point of view, it's just getting an opaque key that only the server can decode. Perhaps this would all become clearer with the overall map.<br>
<span class=""><br>
>   Should I xref it from somewhere else?<br>
<br>
</span>Perhaps from libraries/ghci/GHCi/RemoteTypes.hs, on the declaration of RemoteRef.<br>
<br>
Thanks!<br>
<span class="HOEnZb"><font color="#888888">Richard</font></span></blockquote></div><br></div>