
Hello apfelmus, Wednesday, January 31, 2007, 10:38:00 PM, you wrote:
while (hGetBuf h buf bufsize == bufsize) crc := updateCrc crc buf bufsize break if crc==0 print crc
I guess that the crc is a simple fold over the single bytes:
yes, but it is written in efficient C. and anyway it is monadic operation, because buffer contents are changed on each call. so that is your translation? :)
in a chunked way, just like you now manually do with hGetBuf. Lazy evaluation is very handy for separating those the two concerns of reading the chunks of bytes and presenting them in a non-chunked way.
i need to write MONADIC code. this one-liners is just an examples. i can paste my whole functions what makes much more - read files, simultaneously compress and decompress data using C libs, pass data buffers back and forth between C threads, update GUI state, so on, so on -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com