[Haskell-cafe] Some random newbie questions

Ketil Malde ketil+haskell at ii.uib.no
Fri Jan 7 07:03:09 EST 2005


O.Chitil at kent.ac.uk writes:

> I'm constantly surprised hearing from so many people about their space
> problems. I cannot remember having space problems with my programs. I
> don't know what everybody else is doing wrong :-) 

At least two common cases.

Extracting compact data structures from large files.  The contents of
the large file is read as a linked list (ugh) of pointers (double ugh)
to 32-bit Chars (triple ugh) -- twelve times the size of the file, if
my calculations are correct.  The contents can't be GC'ed before the
extracted data is fully evaluated.  (Now if the file was an mmap'ed
array, it wouldn't be so bad, perhaps in the next generation IO that
people are discussing this will be easier?)

Naive use of foldl.  I tend to think the default foldl should be
strict (ie. replaced by foldl') -- are there important cases where it
needs to be lazy?

> I do disagree with people recommending strictness annotations (seq
> etc). In contrast, I make my programs as lazy as possible.

...but no lazier :-)

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



More information about the Haskell-Cafe mailing list