stm-containers-1.1.0.2: Containers for STM

Safe HaskellNone
LanguageHaskell2010

StmContainers.Map

Synopsis

Documentation

data Map key value Source #

Hash-table, based on STM-specialized Hash Array Mapped Trie.

new :: STM (Map key value) Source #

Construct a new map.

newIO :: IO (Map key value) Source #

Construct a new map in IO.

This is useful for creating it on a top-level using unsafePerformIO, because using atomically inside unsafePerformIO isn't possible.

null :: Map key value -> STM Bool Source #

Check, whether the map is empty.

size :: Map key value -> STM Int Source #

Get the number of elements.

focus :: (Eq key, Hashable key) => Focus value STM result -> key -> Map key value -> STM result Source #

Focus on a value by the key.

This function allows to perform composite operations in a single access to the map's row. E.g., you can look up a value and delete it at the same time, or update it and return the new value.

lookup :: (Eq key, Hashable key) => key -> Map key value -> STM (Maybe value) Source #

Look up an item.

insert :: (Eq key, Hashable key) => value -> key -> Map key value -> STM () Source #

Insert a value at a key.

delete :: (Eq key, Hashable key) => key -> Map key value -> STM () Source #

Delete an item by a key.

reset :: Map key value -> STM () Source #

Delete all the associations.

unfoldlM :: Map key value -> UnfoldlM STM (key, value) Source #

Stream the associations actively.

Amongst other features this function provides an interface to folding.

listT :: Map key value -> ListT STM (key, value) Source #

Stream the associations passively.