<p dir="ltr">> The foldl builds up a very long expression and evaluates it after the last element of the list is reached (the evaluation is non-strict, or lazy). If you use foldl' (from Data.List) instead, the calculation is done per element (the evaluation is strict).<br></p>
<p dir="ltr">Is it possible to write a wrapping function (if it does not already exist) which would analyze inputs and apply appropriate fold (foldl, foldl', foldr, foldr') or safeguard (return Left warning) against following the 10Gb ram route - if this can be avoided?</p>