"S.D.Mechveliani" wrote:

> I do not feel aggressive against Prelude.

So you're not advocating eliminating the current min and max functions
(and others), and leaving only list-based versions?

> Concerning                                foldl1 min,
> there is a little spot that it tends to run in  O(n)  space:
>                             foldl1 min [1..n]
> 
> While the simplest direct implementation of  minimumBy  tend to run
> in a constant space.

You're right; lazy folds tend to have space leaks.  A strict fold should
be used instead.  I think that strict versions of fold should be
exported from the prelude, along with the lazy ones.  A strict foldl' is
already used internally.  I would redefine minimum and maximum to use a
strict fold, the way sum and product do today (at least in hugs/GHC).

Strictness analysis might eliminate, or reduce, the need for special
strict & lazy versions of fold.  I wonder; is anyone working on adding
strictness analysis to any major Haskell implementation?

Regards,
Matt Harden

Reply via email to