Data.Foldable.foldr1 too strict

Ross Paterson ross at soi.city.ac.uk
Thu Sep 27 16:29:27 CEST 2012


On Thu, Sep 27, 2012 at 03:09:07PM +0100, Brent Yorgey wrote:
> On Thu, Sep 27, 2012 at 12:21:32AM +0200, Henning Thielemann wrote:
> > *Data.NonEmpty> foldr2 (P.++) $ "abc" : "def" : P.undefined
> > "*** Exception: Prelude.undefined
> > 
> > *Data.NonEmpty> foldr3 (P.++) $ "abc" : "def" : P.undefined
> > "abc*** Exception: Prelude.undefined
> 
> Isn't that still too strict?  I would expect to see "abcdef" before
> the exception.

No, foldr3 matches what Data.List.foldr1 does:

Prelude> foldr1 (++) $ "abc" : "def" : undefined
"abc*** Exception: Prelude.undefined

It can't decide whether "def":undefined matches [x].



More information about the Libraries mailing list