
Hi,
the patch below is a trivial change to the merge helper function
of Data.List.sort. Its effect is that the first argument of merge
is evaluated before the second argument instead of vice versa.
I think it's obviously correct. Also, sort is necessarily strict in
the whole list, so there can be no loss of laziness.
Rationale:
The change helps to avoid a stack overflow in the common case where
each element of a list depends on the previous one. Examples for such
lists are '[1..]' or uses of 'iterate f' where f is a strict function.
I believe this case is far more common than the opposite case where
each element of the list depends on the next one, so the patch below is
an improvement.
See also
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/30598
Bertram
Wed Nov 21 11:14:58 CET 2007 Bertram Felgenhauer