[Haskell-cafe] redirecting stdout

Bryan O'Sullivan bos at serpentine.com
Thu Aug 30 16:25:04 EDT 2007


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.

	<b


More information about the Haskell-Cafe mailing list