From HaskellWiki
Revision as of 02:29, 13 November 2006 by Pupeno (talk | contribs)

Jump to: navigation, search

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

- bufferBlockStream

- withEncoding utf8

- withLocking

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.