
30 Aug
2007
30 Aug
'07
4:25 p.m.
Chad Scherrer wrote:
Is it possible to write a function
redirect :: Handle -> IO () -> IO ()
so that "redirect h action" is just like action, except that all the output written to stdout now gets sent to h instead?
No. The file descriptor used for IO is wired into a Handle, just as in a FILE * in C. You can change where stdout points using hDuplicateTo, but that affects the entire process.