Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Multimap key value
- new :: STM (Multimap key value)
- newIO :: IO (Multimap key value)
- null :: Multimap key value -> STM Bool
- focus :: (Eq key, Hashable key, Eq value, Hashable value) => Focus () STM result -> value -> key -> Multimap key value -> STM result
- lookup :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM Bool
- lookupByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM (Maybe (Set value))
- insert :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM ()
- delete :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM ()
- deleteByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM ()
- reset :: Multimap key value -> STM ()
- unfoldlM :: Multimap key value -> UnfoldlM STM (key, value)
- unfoldlMKeys :: Multimap key value -> UnfoldlM STM key
- unfoldlMByKey :: (Eq key, Hashable key) => key -> Multimap key value -> UnfoldlM STM value
- listT :: Multimap key value -> ListT STM (key, value)
- listTKeys :: Multimap key value -> ListT STM key
- listTByKey :: (Eq key, Hashable key) => key -> Multimap key value -> ListT STM value
Documentation
newIO :: IO (Multimap key value) 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.
focus :: (Eq key, Hashable key, Eq value, Hashable value) => Focus () STM result -> value -> key -> Multimap key value -> STM result Source #
Focus on an item by the value and the key.
This function allows to perform simultaneous lookup and modification.
The focus 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.
lookup :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM Bool Source #
Look up an item by a value and a key.
lookupByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM (Maybe (Set value)) Source #
Look up all values by key.
insert :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM () Source #
Insert an item.
delete :: (Eq key, Hashable key, Eq value, Hashable value) => value -> key -> Multimap key value -> STM () Source #
Delete an item by a value and a key.
deleteByKey :: (Eq key, Hashable key) => key -> Multimap key value -> STM () Source #
Delete all values associated with the key.
unfoldlM :: Multimap key value -> UnfoldlM STM (key, value) Source #
Stream associations actively.
Amongst other features this function provides an interface to folding.