nikita-volkov / stm-containers

Containers for STM
http://hackage.haskell.org/package/stm-containers
MIT License
66 stars 13 forks source link

Duplicated values #26

Closed adamglowacki closed 5 years ago

adamglowacki commented 5 years ago

If I understand the documentation of Bimap correctly, there mustn't be a duplicated element in any of the sets (both leftKey and rightKey). That is, if I have a Bimap with a single association (1, 3) and insert an association (either via insertLeft or insertRight): (2, 3), the previous association should be removed. The definition of "bijection" requires it, I think. But it does not:

> m <- newIO :: IO (Bimap Int Int)
> atomically $ insertRight 3 1 m
> atomically $ insertRight 3 2 m
> atomically $ lookupRight 1 m
Just 3
> atomically $ lookupRight 2 m
Just 3
> atomically $ lookupLeft 3 m
Just 2

Is it so "by design" or is it a bug - either in a documentation or in a code?

nikita-volkov commented 5 years ago

It's a bug. Thanks for reporting!

nikita-volkov commented 5 years ago

Fixed in 1.1.0.3.

I welcome you to PR with more tests ensuring that it behaves the way you expect it.