On Tue, 12 Sep 2000, Jan Kort wrote:

> I can't seem to work around this behaviour, is it possible to
> force readFile to just open a file, read it entirely and close it
> before doing the next open ?

Applying seq to a list only forces its first constructor.
It does not traverse it to the end.

    foldr (\_ x -> x) (return ()) string_that_was_read_from_file
should be a better seq substitute (in a monad). When the string
is evaluated to the end, the file should get closed immediately.

Of course IMHO it's a hack and the issue should be resolved by
compilers by providing smarter I/O function implementations...

-- 
Marcin 'Qrczak' Kowalczyk


Reply via email to