[Haskell-cafe] curious about sum

Max Rabkin max.rabkin at gmail.com
Wed Jun 17 07:25:32 EDT 2009


On Wed, Jun 17, 2009 at 1:07 PM, Henk-Jan van Tuyl<hjgtuyl at chello.nl> wrote:
> On Wed, 17 Jun 2009 10:38:23 +0200, Yitzchak Gale <gale at sefer.org> wrote:
> An improved reverse function:
>    reverse' = foldl' (flip (:)) []
> There is no need for reverse to be lazy, so this one could replace the
> original one.
> reverse' is not too strict:
>    Data.List> let reverse' = foldl' (flip (:)) [] in head $ reverse'
> [undefined, 1]
>    1

Since reverse' is polymorphic in the type of list elements, the only
way it could be strict in the *elements* is if it applied seq to them.

--Max


More information about the Haskell-Cafe mailing list