Data.Foldable.foldr1 too strict
Ian Lynagh
igloo at earth.li
Thu Sep 27 18:06:09 CEST 2012
On Thu, Sep 27, 2012 at 05:36:00PM +0200, Bertram Felgenhauer wrote:
>
> But we could define
>
> foldr1 f (x:xs) = foldr f x xs
>
> which would be more lazy. I see no advantage to defining foldr1 as
> in the standard library, am I missing anything?
That doesn't have the right behaviour:
Prelude> Data.List.foldr1 (-) [3,5]
-2
Prelude> let foldr1 f (x:xs) = foldr f x xs in foldr1 (-) [3,5]
2
Thanks
Ian
More information about the Libraries
mailing list