stm-containers-1.2: Containers for STM

Safe HaskellNone
LanguageHaskell2010

StmContainers.Bimap

Synopsis

Documentation

data Bimap leftKey rightKey Source #

Bidirectional map. Essentially, a bijection between subsets of its two argument types.

For one value of the left-hand type this map contains one value of the right-hand type and vice versa.

new :: STM (Bimap leftKey rightKey) Source #

Construct a new bimap.

newIO :: IO (Bimap leftKey rightKey) Source #

Construct a new bimap in IO.

This is useful for creating it on a top-level using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.

null :: Bimap leftKey rightKey -> STM Bool Source #

Check on being empty.

size :: Bimap leftKey rightKey -> STM Int Source #

Get the number of elements.

focusLeft :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => Focus rightKey STM result -> leftKey -> Bimap leftKey rightKey -> STM result Source #

Focus on a right value by the left value.

This function allows to perform composite operations in a single access to a map item. E.g., you can look up an item and delete it at the same time, or update it and return the new value.

focusRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => Focus leftKey STM result -> rightKey -> Bimap leftKey rightKey -> STM result Source #

Focus on a left value by the right value.

This function allows to perform composite operations in a single access to a map item. E.g., you can look up an item and delete it at the same time, or update it and return the new value.

lookupLeft :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => leftKey -> Bimap leftKey rightKey -> STM (Maybe rightKey) Source #

Look up a right value by the left value.

lookupRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => rightKey -> Bimap leftKey rightKey -> STM (Maybe leftKey) Source #

Look up a left value by the right value.

insertLeft :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => rightKey -> leftKey -> Bimap leftKey rightKey -> STM () Source #

Insert the association by the left value.

insertRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => leftKey -> rightKey -> Bimap leftKey rightKey -> STM () Source #

Insert the association by the right value.

deleteLeft :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => leftKey -> Bimap leftKey rightKey -> STM () Source #

Delete the association by the left value.

deleteRight :: (Eq leftKey, Hashable leftKey, Eq rightKey, Hashable rightKey) => rightKey -> Bimap leftKey rightKey -> STM () Source #

Delete the association by the right value.

reset :: Bimap leftKey rightKey -> STM () Source #

Delete all the associations.

unfoldlM :: Bimap leftKey rightKey -> UnfoldlM STM (leftKey, rightKey) Source #

Stream associations actively.

Amongst other features this function provides an interface to folding.

listT :: Bimap key value -> ListT STM (key, value) Source #

Stream the associations passively.