travitch / persistent-vector

Persistent vectors for Haskell based on array mapped tries
BSD 3-Clause "New" or "Revised" License
27 stars 4 forks source link

Think through folds #9

Closed treeowl closed 3 years ago

treeowl commented 3 years ago

The array-based part of the structure is really direction-neutral. It's happy with all the folds. The list tail is another story. Thanks to that list, the "natural" folds for Vector are foldl and foldr'—the opposite of plain lists. Unfortunately, we need foldl' to implement things like filter. My experiments so far produced wretched and complicated Core. I need something better. Next attempt: use List.reverse clunkily on the tail, then dance along the result with foldr or foldl'.