Proposal: strictify foldl'

David Feuer david.feuer at gmail.com
Mon Nov 3 17:43:24 UTC 2014


On Mon, Nov 3, 2014 at 12:39 PM, Milan Straka <fox at ucw.cz> wrote:

> Hi all,
>
> FYI, foldl's in containers already have this property being strict in
> the initial value. Therefore,
>   Data.Map.foldl' (\_ x -> x) undefined $ Data.Map.fromList [(4,2)]
> triggers
>   *** Exception: Prelude.undefined
>

OUCH. This is a really nasty potential gotcha for Foldable users. Whichever
way things go (and I think Michael Snoyman almost has me convinced that my
proposal is bad), I think uniform treatment of the initial value across
Foldable instances would be a very good thing. If that means making the
containers ones lazier, then so be it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141103/9710e851/attachment.html>


More information about the Libraries mailing list