
30 Aug
2007
30 Aug
'07
3:38 p.m.
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? Thanks, Chad

30 Aug
30 Aug
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.
6473
Age (days ago)
6473
Last active (days ago)
1 comments
2 participants
participants (2)
-
Bryan O'Sullivan
-
Chad Scherrer