Malcolm Wallace <[EMAIL PROTECTED]> wrote:
>
> Bad news from the nhc98 camp on your test cases - they don't leak in
> the same way!
Actually, this is good news! The tests that ran in bounded space
under nhc98 (3a through 4b) are closer to "typical" applications
than the leaky ones, and for those, as you explained:
> Compare this with test2b, where the spike produced by `length' consists
> of mostly (+) closures, mostly retained by (+) closures, and again all
> Lag. Now clearly this is just the well-known strictness problem with
> foldl, so presumably there must be something similar happening in test
> 2a.
This is undoubtedly what's going on. The Hugs 98 Prelude defines
strict versions of 'length' and 'sum', so I didn't spot this
problem before. Changing the test driver to use length' and sum',
where:
length' :: [a] -> Integer
sum' :: [Integer] -> Integer
length' = foldl_strict (\n _ -> n + 1) 0
sum' = foldl_strict (+) 0
foldl_strict :: (a -> b -> a) -> a -> [b] -> a
foldl_strict f a [] = a
foldl_strict f a (x:xs) = (foldl_strict f $! f a x) xs
fixed these as well.
Thanks!
--Joe English
[EMAIL PROTECTED]