
I would like to be able to semi-permanently redirect stdout particularly. That is, say something like: main = do h <- openFile "myoutput" WriteMode setStdOut h ..crux of the program.. hClose h where any call which uses stdout either explicitly or implicitly (through putStr and the like) is redirecto to h. I didn't see anything of this sort in either the std libs IO or in the GHC.IO/IOBase modules...would such a thingbe possible? - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

Tue, Aug 20, 2002 at 04:57:21AM -0700, Hal Daume III ->
I would like to be able to semi-permanently redirect stdout particularly. That is, say something like:
main = do h <- openFile "myoutput" WriteMode setStdOut h ..crux of the program.. hClose h
where any call which uses stdout either explicitly or implicitly (through putStr and the like) is redirecto to h.
I didn't see anything of this sort in either the std libs IO or in the GHC.IO/IOBase modules...would such a thingbe possible?
If you are using UNIX the dupTo (in C dup2) function in the Posix module might do the trick. /jonas -- %http://www.dtek.chalmers.se/~d99josve/ - d99josve@dtek.chalmers.se %GPG:http://www.dtek.chalmers.se/~d99josve/pubkey.asc
participants (2)
-
Hal Daume III
-
Jonas Svensson