Instant readFile

Marcin 'Qrczak' Kowalczyk
15 Nov 2000 22:10:19 GMT

Wed, 15 Nov 2000 18:42:29 +0100, George Russell <ger@Informatik.Uni-Bremen.DE> pisze:

> What I want instead is a function which
>    (a) opens the file;
>    (b) slurps the complete contents compactly into an array;
>    (c) closes the file;
>    (d) makes the contents of the array available as a String.

    foldr (\_ t -> t) (return ())
to the string (and executing this application as an IO action) will
force it to be read completely. If it came from readFile, the file
gets closed as soon as the string is evaluated up to its end.

> It all is a bit of a mystery to me how you are supposed to use Addr
> like things without space leaks.  A little more explanation in the
> documentation would not perhaps be amiss . . .

Unfortunately the design of these areas (conversion between Haskell
strings and C strings) is not yet complete. And Unicode in Haskell
strings (already implemented in GHC development versions) will make
the library more complex.

 __("<  Marcin Kowalczyk *
  ^^                      SYGNATURA ZASTĘPCZA