<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jan 5, 2014 at 12:03 PM, Andrew Gibiansky <span dir="ltr"><<a href="mailto:andrew.gibiansky@gmail.com" target="_blank">andrew.gibiansky@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am using the GHC API extensively. The entire application is built on the GHC API, with the occasional bit of code practically stolen from GHCi :)<div>

<br></div><div>However, I don't know of a way to intercept stdin even if I am using the GHC API. Given a block of code, there is no sane static analysis than can be done to detect whether it reads from stdin, as far as I know. </div>

</div></blockquote><div><br></div><div>Could you rebind stdin to the ipython input channel every time a cell from the ipython interface is evaluated? (and then reset it, if necessary, after the cell finishes and in related exception handlers, of course).</div>

<div><br></div><div>--Rogan</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<div><br></div><div>Is there any way to check whether a process is blocked when reading from a Handle or an Fd? Maybe there are some low-level hacks with unsafeCoerce or something that would let me pass a non-handle as a Handle, and do it that way?</div>



<div><br></div><div>The only other option is just disabling all uses of stdin, or perhaps reimplementing myself the Prelude functions that use stdin. (But this would still break libraries that have already compiled in the Prelude versions.)</div>



</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jan 5, 2014 at 2:52 PM, Carter Schonwald <span dir="ltr"><<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hrm.  Have you considered using the ghc API? Ghci itself is written using it, and I imagine you could adapt that code for your purposes perhaps? <div>



<span></span><br><br>On Sunday, January 5, 2014, Andrew Gibiansky  wrote:<br>
</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">I cannot modify the Haskell code.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">
I am working on IHaskell - it is effectively a Haskell interpreter. It reads some code from the user, which may contain something like `getLine`. However, the frontend to the interpreter is not a shell but is a GUI in the web browser (IPython!). In order to do input, the interpreter sends a message to the frontend via the network saying "give me input", the frontend reads some input, and then sends things back.</div>






<div class="gmail_extra"><br></div><div class="gmail_extra">In order to do this communication, I need to know when the getLine is called so that I know I need to send the message to the frontend.</div><div class="gmail_extra">






<br></div><div class="gmail_extra">Ideas? The thing is, getLine needs to not actually read from any shell - it will read from a pipe I create, and I simply need to know when to put stuff into that pipe.</div><div class="gmail_extra">






<br></div><div class="gmail_extra">-- Andrew</div></div>
</blockquote>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div></div>