To be able to read and write to a file with functions such as vGetContents and vPutStrLn I think it is mandatory to define some of
- withEncoding utf8
I am sure the first one is needed, I thought the other two wasn't but then I had trouble without them. The trouble is shown as a ugly message and abortion of the program at run-time:
*** Exception: illegal operation
I had to even add those layers to standard input and standard output, without them it was impossible to print and read. I ended up with something like:
inStream <- bufferBlockStream fdStdIn >>= withEncoding utf8 >>= withLocking outStream <- bufferBlockStream fdStdOut >>= withEncoding utf8 >>= withLocking
Maybe this can be improved somehow in the library, but otherwise I believe it should be documented.
I've moved this into main documentation. It is because fdStdIn/fdStdOut provides raw file descriptors, just numbers 0 and 1. So, too use buffered String I/O on them you should apply buffering transformer. Your error was not intercepted at compile time due to weak class design where any stream implements the same Stream class and illegal operations captured only at run-time. It is fixed in 0.2 version, together with providing higher-level stdin/stdout streams with buffering transformer already applied. Bulatz 20:19, 13 November 2006 (UTC)