StmContainers.Set

stm-containers-1.2.1: Containers for STM

Safe Haskell | None
Language | Haskell2010

StmContainers.Set

Synopsis

- data Set item
- new :: STM (Set item)
- newIO :: IO (Set item)
- null :: Set item -> STM Bool
- size :: Set item -> STM Int
- focus :: Hashable item => Focus () STM result -> item -> Set item -> STM result
- lookup :: Hashable item => item -> Set item -> STM Bool
- insert :: Hashable item => item -> Set item -> STM ()
- delete :: Hashable item => item -> Set item -> STM ()
- reset :: Set item -> STM ()
- unfoldlM :: Set item -> UnfoldlM STM item
- listT :: Set item -> ListT STM item

# Documentation

data Set item #

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

new :: STM (Set item) #

Construct a new set.

newIO :: IO (Set item) #

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.

null :: Set item -> STM Bool #

Check, whether the set is empty.

size :: Set item -> STM Int #

Get the number of elements.

focus :: Hashable item => Focus () STM result -> item -> Set item -> STM result #

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.

lookup :: Hashable item => item -> Set item -> STM Bool #

Lookup an element.

insert :: Hashable item => item -> Set item -> STM () #

Insert a new element.

delete :: Hashable item => item -> Set item -> STM () #

Delete an element.

reset :: Set item -> STM () #

Delete all the elements.

unfoldlM :: Set item -> UnfoldlM STM item #

Stream the elements actively.

Amongst other features this function provides an interface to folding.

listT :: Set item -> ListT STM item #

Stream the elements passively.