stm-containers 1.1.0.5 → 1.2
raw patch · 3 files changed
+33/−7 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- StmContainers.Multimap: unfoldMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value
- StmContainers.Multimap: unfoldMKeys :: Multimap key value -> UnfoldlM STM key
+ StmContainers.Multimap: unfoldlMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value
+ StmContainers.Multimap: unfoldlMKeys :: Multimap key value -> UnfoldlM STM key
Files
- library/StmContainers/Multimap.hs +6/−6
- stm-containers.cabal +1/−1
- test/Main/BimapTests.hs +26/−0
library/StmContainers/Multimap.hs view
@@ -12,8 +12,8 @@ deleteByKey, reset, unfoldlM,- unfoldMKeys,- unfoldMByKey,+ unfoldlMKeys,+ unfoldlMByKey, listT, listTKeys, listTByKey,@@ -149,14 +149,14 @@ -- | -- Stream keys actively.-unfoldMKeys :: Multimap key value -> UnfoldlM STM key-unfoldMKeys (Multimap m) =+unfoldlMKeys :: Multimap key value -> UnfoldlM STM key+unfoldlMKeys (Multimap m) = fmap fst (A.unfoldlM m) -- | -- Stream values by a key actively.-unfoldMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value-unfoldMByKey key (Multimap m) =+unfoldlMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value+unfoldlMByKey key (Multimap m) = lift (A.lookup key m) >>= maybe mempty B.unfoldlM -- |
stm-containers.cabal view
@@ -1,5 +1,5 @@ name: stm-containers-version: 1.1.0.5+version: 1.2 synopsis: Containers for STM description: This library is based on an STM-specialized implementation of
test/Main/BimapTests.hs view
@@ -37,7 +37,33 @@ test_insertOverwrites = do m <- newIO :: IO (Bimap Int Int) atomically $ insertRight 3 1 m+ assertEqual 1 =<< atomically (size m) atomically $ insertRight 3 2 m+ assertEqual 1 =<< atomically (size m) assertEqual Nothing =<< atomically (lookupRight 1 m) assertEqual (Just 3) =<< atomically (lookupRight 2 m) assertEqual (Just 2) =<< atomically (lookupLeft 3 m)+ assertEqual Nothing =<< atomically (focusRight Focus.lookup 1 m)+ assertEqual (Just 3) =<< atomically (focusRight Focus.lookup 2 m)+ atomically $ focusRight (Focus.insert 3) 4 m+ assertEqual 1 =<< atomically (size m)+ assertEqual Nothing =<< atomically (lookupRight 1 m)+ assertEqual Nothing =<< atomically (lookupRight 2 m)+ assertEqual (Just 3) =<< atomically (lookupRight 4 m)++test_insertOverwrites' = do+ m <- newIO :: IO (Bimap Int Char)+ atomically $ insertLeft 'a' 1 m+ assertEqual 1 =<< atomically (size m)+ atomically $ insertLeft 'a' 2 m+ assertEqual 1 =<< atomically (size m)+ assertEqual Nothing =<< atomically (lookupLeft 1 m)+ assertEqual (Just 'a') =<< atomically (lookupLeft 2 m)+ assertEqual Nothing =<< atomically (focusLeft Focus.lookup 1 m)+ assertEqual (Just 'a') =<< atomically (focusLeft Focus.lookup 2 m)+ atomically $ focusLeft (Focus.insert 'a') 3 m+ assertEqual 1 =<< atomically (size m)+ assertEqual Nothing =<< atomically (lookupLeft 1 m)+ assertEqual Nothing =<< atomically (lookupLeft 2 m)+ assertEqual (Just 'a') =<< atomically (lookupLeft 3 m)+