It is unsafe because, in general, lazy IO is a bad idea. In particular: foo f x = do h <- openFile x ReadMode t <- hGetContents h v <- f t hClose h return t will do substantially different things depending on the strictness of 'f'. For instance, if 'f' is 'return . head', you might get a 'head:: empty list' error, while if 'f' is 'evaluate . head', you won't. -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume On Sat, 18 Oct 2003, Ben Escoto wrote:
On Sun, 19 Oct 2003 02:03:58 +0200 Nick Name <nick.name@inwind.it> wrote:
You have to use unsafeInterleaveIO, wich lazily defers the IO action passed as an argument. Look for this function in your documentation, both hugs and ghc have it.
Got it, thanks. Do you know in what sense it is "unsafe" though? Are there some pitfalls I should be aware of?
-- Ben Escoto