[Haskell-cafe] Copying Arrays

Ketil Malde ketil at malde.org
Fri May 30 08:35:02 EDT 2008

"Johan Tibell" <johan.tibell at gmail.com> writes:

> Lazy I/O comes with a penalty in terms of correctness! 

Is there a page describing this in more detail?  I believe my programs
to be correct, but would like to know if there are additional
pitfalls, beyond hClosing a handle with outstanding (unevaluated)

> Lazy I/O is kinda, maybe usable for small scripts that reads a file
> or two and spits out a result but for servers it doesn't work at
> all.

So don't use it for servers, then?

> Here are two possible interfaces for safe I/O. One isstream based
> one with explicit close and the other fold based one (i.e. inversion
> of control):

Say I have two files with variable-size records, that need to be
merged.  In other words, I can do something like:

    xs <- readFile "X"
    ys <- readFile "Y"
    return $ zipWith combine (parseX xs) (parseY ys)

Clearly in the "small script" category and not "servers", but is it
still unsafe?

>> -- Stream based I/O.
>> -- Left fold/callback based I/O.

Perhaps I don't quite understand the concepts, but I don't see how to
implement the example as elegantly and simply with these approaches?

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list