purescript-lists
purescript-lists copied to clipboard
Why does lazy list foldr reverse into a temporary lazy list?
I get why https://github.com/purescript/purescript-lists/blob/v6.0.0/src/Data/List/Lazy/Types.purs#L121 does what it does with reverse, but it seems to me there is no reason to create a brand new temporary lazy list just to consume it left to right. How about pushing elements left to right into a temporary JavaScript array and then going right to left in that?
No objections to optimizing by using a temporary JS array. I think the existing version was chosen just to keep the code concise at the cost of performance.
Another issue discussing improving reverse performance is #185