foldl' semantic change

Bart Massey bart.massey at gmail.com
Fri Jun 10 16:10:06 UTC 2016


-1 on retaining this. Part of the implied contract of Data.List is that all
functions be as lazy as possible. Besides, a change that potentially breaks
old programs that use foldl' seems like a bad idea unless there's a really
strong reason for it. I don't have an existing example offhand, but it
seems at least possible that something like

    last = foldl' (flip const) undefined

is out there...

On Fri, Jun 10, 2016 at 5:29 AM David Feuer <david.feuer at gmail.com> wrote:

> The semantics of foldl' for lists were changed between base 4.7 and base
> 4.8. Specifically, foldl' became strict in the initial value of its
> accumulator. I opened http://ghc.haskell.org/trac/ghc/ticket/12173 to
> report this. The change was entirely accidental, according to Joachim
> Breitner. However, Duncan Coutts indicated he is pleased with the change. I
> don't personally have a dog in this race, but I feel very strongly about
> three things:
>
> 1. The strictness should be fully documented, both in Haddock and the next
> Haskell Report (the Haskell 2010 Report does not go into sufficient detail
> to support either choice).
>
> 2. There should be *one* meaning of foldl' in base. Thus the default
> Foldable instance should match the ones for lists and arrays.
>
> 3. The containers package should be consistent with base in this regard.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160610/de932ada/attachment.html>


More information about the Libraries mailing list