ekmett / folds

Folds and sequence algebras
Other
18 stars 11 forks source link

<*> for R is insufficiently lazy #2

Closed tomjaguarpaw closed 10 years ago

tomjaguarpaw commented 10 years ago

L120 of R.hs should have a lazy pattern match, that is

(\b (Pair' x y) -> Pair' (bxx b x) (byy b y))

should read

(\b ~(Pair' x y) -> Pair' (bxx b x) (byy b y))

otherwise you cannot combine folds for infinite lists.

https://github.com/ekmett/folds/blob/d72e747bbbd7e2c7d967b575905a53c8c786adfa/src/Data/Fold/R.hs#L120

tomjaguarpaw commented 10 years ago

This came up on a Stack Overflow question about implementing unzip, however with further consideration perhaps it is rather perverse to try to implement unzip with a right fold, so feel free to summarily close the issue if I've missed the point of R.

ekmett commented 10 years ago

Missed this. (github rarely actually emails me, too may repos I guess.) If you want to dig through and find other laziness problems on the R or R1 front, I'm more than happy to merge changes there.