Consider we have a sequence of monoid elements, Data.Sequence
is great for inserting, changing elements in certain positions.
I'm concerned with the following query, sum i j sequence
, which returns the mconcat
of all elements from position i
to j
. This can be done with by using a FingerTree
with measure contain both the index and the mconcat
result in O(log n) time.
Is there already a implementation of this in some Haskell library? Or do I have to implement Data.Sequence
again with this ability with Data.FingerTree
? (Sequence
expose too little internal structure to do this effectively.)