mstksg / nonempty-containers

Efficient non-empty variants of containers data types, with full API
http://hackage.haskell.org/package/nonempty-containers
BSD 3-Clause "New" or "Revised" License
25 stars 9 forks source link

union a NEMap / NESet with Map / Set? #16

Open aryairani opened 1 year ago

aryairani commented 1 year ago

I know it opens a can of worms in terms of naming, but I missed a union version of NEMap.insertMap which still gets the O(m*log(n/m + 1)), m <= n complexity.

I'm using something like:

unionMap1 :: Ord a => Map a b -> NEMap a b -> NEMap a b
unionMap1 m n = NEMap.withNonEmpty n (<> n) m

unionMap2 :: Ord a => NEMap a b -> Map a b -> NEMap a b
unionMap2 n m = NEMap.withNonEmpty n (n <>) m

I'm happy to open a PR if you like these, but could use some help choosing names.

mstksg commented 7 months ago

Thanks for the idea, I like it :) maybe unionMapLeft and unionMapRight?