stm-containers-0.2.16: Containers for STM

Safe HaskellNone
LanguageHaskell2010

STMContainers.Set

Synopsis

Documentation

data Set e Source #

A hash set, based on an STM-specialized hash array mapped trie.

type Element a = (Eq a, Hashable a) Source #

A constraint for elements.

new :: STM (Set e) Source #

Construct a new set.

newIO :: IO (Set e) Source #

Construct a new set in IO.

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

insert :: Element e => e -> Set e -> STM () Source #

Insert a new element.

delete :: Element e => e -> Set e -> STM () Source #

Delete an element.

deleteAll :: Set e -> STM () Source #

Delete all the associations.

lookup :: Element e => e -> Set e -> STM Bool Source #

Lookup an element.

focus :: Element e => StrategyM STM () r -> e -> Set e -> STM r Source #

Focus on an element with a strategy.

This function allows to perform simultaneous lookup and modification.

The strategy is over a unit since we already know, which element we're focusing on and it doesn't make sense to replace it, however we still can decide wether to keep or remove it.

null :: Set e -> STM Bool Source #

Check, whether the set is empty.

size :: Set e -> STM Int Source #

Get the number of elements.

stream :: Set e -> ListT STM e Source #

Stream elements.

Amongst other features this function provides an interface to folding via the fold function.