purescript-catenable-lists icon indicating copy to clipboard operation
purescript-catenable-lists copied to clipboard

CatQueue `traverse` implementation

Open nadameu opened this issue 1 year ago • 1 comments

The traverse implementation of CatQueue iterates through every element twice.

Is this intended?

https://github.com/purescript/purescript-catenable-lists/blob/09abe1f4888bc00841ad2b59e56a9e7ce7ebd4ab/src/Data/CatQueue.purs#L166-L168

nadameu avatar Nov 28 '24 20:11 nadameu

I would imagine it's to preserve the order since foldl will reorder it (and foldl is being used because it makes the traversal stack safe), although maybe cons could be used instead to avoid the double pass. I'm not sure if there should be a preference for it to generally be cons or snoc constructed, it probably depends on the operations being run on it.

garyb avatar Nov 29 '24 01:11 garyb