
Simon,
Yes, it is entirely possible to do this, and in fact we used to have such a thing (withStdout, withStderr) which got dropped when I
I assume these functions had type 'Handle -> IO a -> IO a' or something similar, where the original meaning of stdout, etc., was restored after the completion of the passed IO action? For me, this would actually be better, or at least equivalent.
re-implemented the I/O system. It's not immediately clear what the interface should be, though. If we have
setStdout :: Handle -> IO ()
what happens to the original handle?
I assumed, before looking at the GHC sources, that there were references stdinR/stdoutR which were IORef Handles and these were unsafely read by stdin and stdout (unsafely = safely because they are set at the beginning of execution, blah blah). Of course this turns out to not be the case, but the case is not completely dissimilar. Anyway, it seems something like withStdout, etc., is possible in the current scheme and this is enough for me. Is there any chance this will be possible in 5.04.1, the point about equality and two-sided handles not withstanding? - Hal