-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
The library does not provide a way to insert an element near the given index. I ended up writing it myself via fold:
insertOSet :: WhereTo -> OSet a -> a -> OSet a -> OSet a
insertOSet appendOrPrepend elemsToInsert targetElem set = unbiased $ foldMap' g set
where
g e = (Bias :: a -> Bias L a) $
if e == targetElem
then if appendOrPrepend == Prepend
then elemsToInsert |> e
else e |< elemsToInsert
else
singleton e
It'd be nice to have a proper implementation of this function in the library.
webdevred
Metadata
Metadata
Assignees
Labels
No labels