Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Bimap a b
- type Association a b = (Key a, Key b)
- type Key k = Key k
- new :: STM (Bimap a b)
- newIO :: IO (Bimap a b)
- insert1 :: Association a b => b -> a -> Bimap a b -> STM ()
- insert2 :: Association a b => a -> b -> Bimap a b -> STM ()
- delete1 :: Association a b => a -> Bimap a b -> STM ()
- delete2 :: Association a b => b -> Bimap a b -> STM ()
- deleteAll :: Bimap a b -> STM ()
- lookup1 :: Association a b => a -> Bimap a b -> STM (Maybe b)
- lookup2 :: Association a b => b -> Bimap a b -> STM (Maybe a)
- focus1 :: Association a b => StrategyM STM b r -> a -> Bimap a b -> STM r
- focus2 :: Association a b => StrategyM STM a r -> b -> Bimap a b -> STM r
- null :: Bimap a b -> STM Bool
- size :: Bimap a b -> STM Int
- stream :: Bimap a b -> ListT STM (a, b)
Documentation
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.
type Association a b = (Key a, Key b) Source #
A constraint for associations.
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.