generic finger-tree structure (http://staff.city.ac.uk/~ross/papers/FingerTree.html)
#3left-right (a)symmetry
from Balazs Komuves:
I'm working on a project where I use the fingertree package from Hackage, and I need some functionality which are unfortunately missing from the library. Namely, several functions only have a "left-sided" version, breaking the left-right symmetry: split, takeUntil, dropUntil, fmapWithPos and traverseWithPos are all missing a right-sided counterpart.
In my case I would need to split from both sides. I don't see any way do that right now without changing the library source code (using reverse would be very inefficient).
A trivial example where this would be useful is when the measurement is simply the set of elements appearing in the sequence, and the predicate is the membership. Then (left-) split splits on the first occurrence from the left, while right-split would split on the first occurrence from the right.
I believe adding the mirror versions of the above functions is completely uncontroversial, and would increase the utility of the library, so I would like to ask you to add them. I have no strong opinion on naming these, but I looked at some other packages having similar functions, and found that:
- Data.Text uses takeEnd, dropEnd, etc
- Data.ByteString similarly uses spanEnd and breakEnd
- Data.Sequence (based on the fingertree library) uses spanl, spanr, takeWhileL, takeWhileR, etc.
- status set to closed
The new functions search, fmapWithContext and traverseWithContext use both left and right measures.