Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Multimap k v
- type Association k v = (Key k, Value v)
- type Key k = Key k
- type Value v = Element v
- new :: STM (Multimap k v)
- newIO :: IO (Multimap k v)
- insert :: Association k v => v -> k -> Multimap k v -> STM ()
- delete :: Association k v => v -> k -> Multimap k v -> STM ()
- deleteByKey :: Key k => k -> Multimap k v -> STM ()
- deleteAll :: Multimap k v -> STM ()
- lookup :: Association k v => v -> k -> Multimap k v -> STM Bool
- lookupByKey :: Key k => k -> Multimap k v -> STM (Maybe (Set v))
- focus :: Association k v => StrategyM STM () r -> v -> k -> Multimap k v -> STM r
- null :: Multimap k v -> STM Bool
- stream :: Multimap k v -> ListT STM (k, v)
- streamKeys :: Multimap k v -> ListT STM k
- streamByKey :: Association k v => k -> Multimap k v -> ListT STM v
Documentation
type Association k v = (Key k, Value v) Source #
A constraint for associations.
newIO :: IO (Multimap k v) Source #
Construct a new multimap in IO.
This is useful for creating it on a top-level using unsafePerformIO
,
because using atomically
inside unsafePerformIO
isn't possible.
delete :: Association k v => v -> k -> Multimap k v -> STM () Source #
Delete an item by a value and a key.
deleteByKey :: Key k => k -> Multimap k v -> STM () Source #
Delete all values associated with a key.
lookup :: Association k v => v -> k -> Multimap k v -> STM Bool Source #
Look up an item by a value and a key.
focus :: Association k v => StrategyM STM () r -> v -> k -> Multimap k v -> STM r Source #
Focus on an item with a strategy by a value and a key.
This function allows to perform simultaneous lookup and modification.
The strategy is over a unit since we already know, which value we're focusing on and it doesn't make sense to replace it, however we still can decide wether to keep or remove it.
stream :: Multimap k v -> ListT STM (k, v) Source #
Stream associations.
Amongst other features this function provides an interface to folding
via the fold
function.
streamByKey :: Association k v => k -> Multimap k v -> ListT STM v Source #
Stream values by a key.