readfile not so lazy

Hal Daume III hdaume@ISI.EDU
Wed, 9 Jan 2002 10:10:35 -0800 (PST)


Why, in the following program:

> createFile = unsafePerformIO $
> 	       writeFile "test.xxx"
>		         ('1' : (take 10000000 (repeat '0')) ++ "1")
>
> processFile = 
>     unsafePerformIO   $
>     do f <- readFile "test.xxx"
>        return (dropWhile (=='0') $
> 	         dropWhile (/='0') f)

does the amount of memory used by 'processFile' depend on the size of the
file created?  that is, if the take 10000000 is replaced by 100000000, the
execution of processFile takes (around) ten times as much memory.  it
appears that it's storing all of f in memory even though all it really
needs is the last character.

how can i make this more lazy?  (this was all done in ghc)

 - Hal