Proposal: Strict scanl, scanl1 and mapAccumL

Thomas Schilling nominolo at
Thu Nov 15 16:46:53 CET 2012

Yes, GHC will rewrite this to

    force x = x

I'm also not sure if we really want "seq" in all of these cases, or if we
want stronger guarantees.  For example, GHC can (and often will) rewrite

    f x y = x `seq` y `seq` x


    f x y = y `seq` x

This changes the order of evaluation. For pure computations this is
semantically sound. However, it can change the space behaviour of the
program, which defeats the point of using "seq" in the first place
(usually). If forcing "x" to be evaluated before "y" is the goal, then
"pseq" must be used. I think it's worthwhile to consider introducing
high-level combinators for this use case as well.

On 15 November 2012 15:38, Johan Tibell <johan.tibell at> wrote:

> On Thu, Nov 15, 2012 at 2:38 AM, Henning Thielemann <
> lemming at> wrote:
>>  On Mon, 12 Nov 2012, Bas van Dijk wrote:
>>> force :: WHNFData a => a -> a
>>> force x = x `seq` x
>> Does this function do something?
> No. It says "when x is evaluated, evaluate x".
> _______________________________________________
> Libraries mailing list
> Libraries at

Push the envelope. Watch it bend.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list