[Haskell-cafe] Intercept stdin in Haskell
creswick at gmail.com
Sun Jan 5 20:42:00 UTC 2014
On Sun, Jan 5, 2014 at 12:19 PM, Andrew Gibiansky <
andrew.gibiansky at gmail.com> wrote:
> That's a good idea, but there's no IPython input channel. Instead, the
> backend (my interpreter) has to *request* input from the frontend, which
> then supplies this input. The input is entered via a web browser, so
> there's not even a handle or file descriptor to speak of.
Ugh, so you really do need to trigger an event when the code in the cell
requests input. How does python handle this?
Here's a horrible idea, but in the spirit of brainstorming... you could run
the cell code in a separate app (fork off your interpreter), using ptrace
(for linux; I'm not sure how to do this on other OSes) to detect system
calls that involve stdin, and then supply input based on that.
Aside from being tricky to do for all platforms, that's also going to have
a horrible user experience for any code that loops over std in rapidly to
get what would otherwise appear as a single input to the user, but I'm
grasping at straws...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe