
David Place wrote:
Hi, Panagiotis.
The wc program is a good choice for a learning program, but it reveals a long-standing weakness in Haskell: Lazy-IO. I think you will find that your program will get an error if you try to run wc on many files. You will open too many files at once.
There is a solution called IterateeIO. It's extremely elegant and very good Haskell, but quite challenging to understand. So far, I have not found a good tutorial.
Personally, I think that lazy IO is not a weakness and works extremely well for prototyping. In contrast, I find IterateeIO to be ugly and non-idiomatic Haskell, since it exposes implementation details and is not built on an algebraic "combinators & laws" approach. Being challenging to understand is not a substitute for beauty. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com