stm-containers-0.1.3: Containers for STM

Safe HaskellNone

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 there this map contains one value of the right-hand type and vice versa.

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

A standard constraint for associations.

new :: STM (Bimap a b)Source

Construct a new bimap.

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 rSource

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 rSource

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.

foldM :: (r -> (a, b) -> STM r) -> r -> Bimap a b -> STM rSource

Fold all the associations.

null :: Bimap a b -> STM BoolSource

Check on being empty.