> 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 ? I tried a few things with seq,
> but this doesn't work:
> 
>         xs <- mapM (\x -> let y = readFile x
>                           in seq y y) (take 1000 (repeat "tmp"));
> 
> and neither does this:
> 
>         let
>           f = mapM (\x -> let y = readFile x
>                           in seq y y) (take 1000 (repeat "tmp"));
>         in do {
>                 xs <- seq f f;
>                 return ();
>         }

hGetLine is strict, in that it keeps reading until a newline or EOF is
found.  Repeated hGetLine can be used to read the entire file.  

Alternatively you could use IOExts.hGetBuf and friends to slurp the data
into a buffer and then convert the buffer into a string with one of the
CString.unpackNBytes family.

Cheers,
        Simon

Reply via email to