
Hi, Am Freitag, den 19.01.2007, 11:19 +0100 schrieb Ferenc Wagner:
Magnus Therning
writes: Thanks for all the excellent answers to my original question. Somehow it feels like I advanced and got one level closer to a black belt in Haskell due to this; I've now legitimately used a function from System.IO.Unsafe :-)
I tried to document it all: http://therning.org/magnus/archives/249
I wonder whether the unsafeInterleaved solution is guarranteed to work as per your specification. Couldn't it read a character, write it, then read three characters, write two, read one more then write two again, and so on? It has to catch up at the end, but needn't stay synchronized during the process, perhaps...
I think it is: “unsafeInterleaveIO allows IO computation to be deferred lazily. When passed a value of type IO a, the IO will only be performed when the value of the a is demanded. This is used to implement lazy file reading, see hGetContents.”[1] If it would read a value that is not needed, it would violate the documented behaviour (the “only .. when .. demanded” is important). Greetings, Joachim [1] http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.html... -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189