stm-containers-0.2.9: Containers for STM

Safe HaskellNone
LanguageHaskell2010

STMContainers.Bimap

Synopsis

Documentation

data Bimap a b Source

A bidirectional map. Essentially a bijection between subsets of its two argument types.

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

Instances

Typeable (* -> * -> *) Bimap 

type Association a b = (Key a, Key b) Source

A constraint for associations.

type Key k = Key k Source

A constraint for keys.

new :: STM (Bimap a b) Source

Construct a new bimap.

newIO :: IO (Bimap a b) 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.

insert1 :: Association a b => b -> a -> Bimap a b -> STM () Source

Insert an association by a left value.

insert2 :: Association a b => a -> b -> Bimap a b -> STM () Source

Insert an association by a right value.

delete1 :: Association a b => a -> Bimap a b -> STM () Source

Delete an association by a left value.

delete2 :: Association a b => b -> Bimap a b -> STM () Source

Delete an association by a right value.

lookup1 :: Association a b => a -> Bimap a b -> STM (Maybe b) Source

Look up a right value by a left value.

lookup2 :: Association a b => b -> Bimap a b -> STM (Maybe a) Source

Look up a left value by a right value.

focus1 :: Association a b => StrategyM STM b r -> a -> Bimap a b -> STM r Source

Focus on a right value by a left value with a strategy.

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.

focus2 :: Association a b => StrategyM STM a r -> b -> Bimap a b -> STM r Source

Focus on a left value by a right value with a strategy.

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.

null :: Bimap a b -> STM Bool Source

Check on being empty.

stream :: Bimap a b -> ListT STM (a, b) Source

Stream associations.

Amongst other features this function provides an interface to folding via the fold function.