
On Fri, 2005-02-18 at 01:58 -0800, Sean Perry wrote:
I am learning Haskell, so I decided to implement everyone's favorite, overused Unix command -- cat. Below is my simple implementation, comments about style, implementation, etc. are welcomed.
In particular, is my untilEOF idiomatically ok? Is there a better way to accomplish this?
Haskell allows lazy IO. One example is hGetContents (and getContents which is specialised for stdin): hGetContents :: Handle -> IO String It looks like you get the whole file contents at once, but under the hood it is read on demand. This allows you to avoid the awkward tests for EOF. Lazy IO is not without its problems, in particular it makes life hard for the people who implement the compilers. You should look around the haskell list archives for the discussions about lazy that have happened in the past. Cheers, Bernie.