Adding `intersperse` to the API
I would like to suggest the addition of intersperse :: a -> Vector a -> Vector a to the API.
I have a prototype that I reuse in my projects, that reads:
intercalateVec :: Text -> Vector Text -> Vector Text
intercalateVec sep vector =
if V.null vector
then vector
else V.tail $ V.concatMap (\word -> V.fromList [sep, word]) vector
But I would be interested to know if a better implementation is possible.
I pretty sure it should be possible to get an efficient version implemented of this at the stream level. In fact, here is a drop in implementation for it from text:
https://github.com/haskell/text/blob/fdc938628efe9ecf86e7d11128c4c7cc66d1071a/src/Data/Text/Internal/Fusion/Common.hs#L457-L469
We should really unify streaming functions from text with vector into a single package. Have no clue how much work that would be though.
I mark this issue "help-wanted". Contributions are welcome