-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Container with element counts -- -- Container with element counts @package refcount @version 0.0.0 module Data.Refcount -- | Maintain a collection of objects with duplication counts. newtype Refcount a Refcount :: HashMap a Int -> Refcount a unRefcount :: Refcount a -> HashMap a Int -- | Retrieve the refcounted objects. refcounted :: Refcount a -> [a] -- | Insert an object and increment its count. insertRef :: (Hashable a, Eq a) => a -> Refcount a -> Refcount a -- | Remove a reference to an element and decrease its count, possibly -- removing it from the set. Returns Nothing if the element -- wasn't found, or Just set. deleteRef :: (Hashable a, Eq a) => a -> Refcount a -> Maybe (Refcount a) -- | Remove a reference to an element and decrease its count, possibly -- removing it from the set. Returns Nothing if the element -- wasn't found, or Just (wasRemoved, set). removeRef :: (Hashable a, Eq a) => a -> Refcount a -> Maybe (Bool, Refcount a) instance (Hashable a, Eq a) => Monoid (Refcount a)