-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Efficient hash-consing for arbitrary data types -- -- Efficient hash-consing for arbitrary data types. @package intern @version 0.9.3 module Data.Interned.Internal class (Eq (Description t), Hashable (Description t)) => Interned t where { data family Description t; type family Uninterned t; } describe :: Interned t => Uninterned t -> Description t identify :: Interned t => Id -> Uninterned t -> t seedIdentity :: Interned t => p t -> Id cacheWidth :: Interned t => p t -> Int modifyAdvice :: Interned t => IO t -> IO t cache :: Interned t => Cache t class Interned t => Uninternable t unintern :: Uninternable t => t -> Uninterned t mkCache :: Interned t => Cache t newtype Cache t Cache :: Array Int (IORef (CacheState t)) -> Cache t [getCache] :: Cache t -> Array Int (IORef (CacheState t)) data CacheState t CacheState :: {-# UNPACK #-} !Id -> !HashMap (Description t) t -> CacheState t [fresh] :: CacheState t -> {-# UNPACK #-} !Id [content] :: CacheState t -> !HashMap (Description t) t cacheSize :: Cache t -> IO Int type Id = Int intern :: Interned t => Uninterned t -> t recover :: Interned t => Description t -> IO (Maybe t) -- | An efficient implementation of integer sets. -- -- Since many function names (but not the type name) clash with -- Prelude names, this module is usually imported -- qualified, e.g. -- --
-- import Data.IntSet (IntSet) -- import qualified Data.IntSet as IntSet ---- -- The implementation is based on big-endian patricia trees. This -- data structure performs especially well on binary operations like -- union and intersection. However, my benchmarks show that -- it is also (much) faster on insertions and deletions when compared to -- a generic size-balanced set implementation (see Data.Set). -- --
-- split 3 (fromList [1..5]) == (fromList [1,2], fromList [4,5]) --split :: Int -> IntSet -> (IntSet, IntSet) -- | O(min(n,W)). Performs a split but also returns whether -- the pivot element was found in the original set. splitMember :: Int -> IntSet -> (IntSet, Bool, IntSet) -- | O(min(n,W)). The minimal element of the set. findMin :: IntSet -> Int -- | O(min(n,W)). The maximal element of a set. findMax :: IntSet -> Int -- | O(min(n,W)). Delete the minimal element. deleteMin :: IntSet -> IntSet -- | O(min(n,W)). Delete the maximal element. deleteMax :: IntSet -> IntSet -- | O(min(n,W)). Delete and find the minimal element. -- --
-- deleteFindMin set = (findMin set, deleteMin set) --deleteFindMin :: IntSet -> (Int, IntSet) -- | O(min(n,W)). Delete and find the maximal element. -- --
-- deleteFindMax set = (findMax set, deleteMax set) --deleteFindMax :: IntSet -> (Int, IntSet) -- | O(min(n,W)). Retrieves the maximal key of the set, and the set -- stripped of that element, or Nothing if passed an empty set. maxView :: IntSet -> Maybe (Int, IntSet) -- | O(min(n,W)). Retrieves the minimal key of the set, and the set -- stripped of that element, or Nothing if passed an empty set. minView :: IntSet -> Maybe (Int, IntSet) -- | O(n*min(n,W)). map f s is the set obtained by -- applying f to each element of s. -- -- It's worth noting that the size of the result may be smaller if, for -- some (x,y), x /= y && f x == f y map :: (Int -> Int) -> IntSet -> IntSet -- | O(n). Fold over the elements of a set in an unspecified order. -- --
-- sum set == fold (+) 0 set -- elems set == fold (:) [] set --fold :: (Int -> b -> b) -> b -> IntSet -> b -- | O(n). The elements of a set. (For sets, this is equivalent to -- toList) elems :: IntSet -> [Int] -- | O(n). Convert the set to a list of elements. toList :: IntSet -> [Int] -- | O(n*min(n,W)). Create a set from a list of integers. fromList :: [Int] -> IntSet -- | O(n). Convert the set to an ascending list of elements. toAscList :: IntSet -> [Int] -- | O(n). Build a set from an ascending list of elements. The -- precondition (input list is ascending) is not checked. fromAscList :: [Int] -> IntSet -- | O(n). Build a set from an ascending list of distinct elements. -- The precondition (input list is strictly ascending) is not -- checked. fromDistinctAscList :: [Int] -> IntSet -- | O(n). Show the tree that implements the set. The tree is shown -- in a compressed, hanging format. showTree :: IntSet -> String -- | O(n). The expression (showTreeWith hang wide -- map) shows the tree that implements the set. If hang is -- True, a hanging tree is shown otherwise a rotated tree -- is shown. If wide is True, an extra wide version is -- shown. showTreeWith :: Bool -> Bool -> IntSet -> String instance GHC.Classes.Eq (Data.Interned.Internal.Description Data.Interned.IntSet.IntSet) instance Data.Interned.Internal.Interned Data.Interned.IntSet.IntSet instance Data.Interned.Internal.Uninternable Data.Interned.IntSet.IntSet instance Data.Hashable.Class.Hashable (Data.Interned.Internal.Description Data.Interned.IntSet.IntSet) instance GHC.Base.Semigroup Data.Interned.IntSet.IntSet instance GHC.Base.Monoid Data.Interned.IntSet.IntSet instance GHC.Classes.Eq Data.Interned.IntSet.IntSet instance GHC.Classes.Ord Data.Interned.IntSet.IntSet instance GHC.Show.Show Data.Interned.IntSet.IntSet instance Data.Hashable.Class.Hashable Data.Interned.IntSet.IntSet instance GHC.Read.Read Data.Interned.IntSet.IntSet module Data.Interned class (Eq (Description t), Hashable (Description t)) => Interned t where { data family Description t; type family Uninterned t; } describe :: Interned t => Uninterned t -> Description t identify :: Interned t => Id -> Uninterned t -> t seedIdentity :: Interned t => p t -> Id cacheWidth :: Interned t => p t -> Int modifyAdvice :: Interned t => IO t -> IO t cache :: Interned t => Cache t class Interned t => Uninternable t unintern :: Uninternable t => t -> Uninterned t mkCache :: Interned t => Cache t data Cache t cacheSize :: Cache t -> IO Int type Id = Int intern :: Interned t => Uninterned t -> t module Data.Interned.Internal.ByteString data InternedByteString InternedByteString :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !ByteString -> InternedByteString [internedByteStringId] :: InternedByteString -> {-# UNPACK #-} !Id [uninternByteString] :: InternedByteString -> {-# UNPACK #-} !ByteString instance Data.Hashable.Class.Hashable (Data.Interned.Internal.Description Data.Interned.Internal.ByteString.InternedByteString) instance GHC.Classes.Eq (Data.Interned.Internal.Description Data.Interned.Internal.ByteString.InternedByteString) instance Data.String.IsString Data.Interned.Internal.ByteString.InternedByteString instance GHC.Classes.Eq Data.Interned.Internal.ByteString.InternedByteString instance GHC.Classes.Ord Data.Interned.Internal.ByteString.InternedByteString instance GHC.Show.Show Data.Interned.Internal.ByteString.InternedByteString instance Data.Hashable.Class.Hashable Data.Interned.Internal.ByteString.InternedByteString instance Data.Interned.Internal.Interned Data.Interned.Internal.ByteString.InternedByteString instance Data.Interned.Internal.Uninternable Data.Interned.Internal.ByteString.InternedByteString module Data.Interned.ByteString data InternedByteString module Data.Interned.Internal.String data InternedString IS :: {-# UNPACK #-} !Id -> String -> InternedString [internedStringId] :: InternedString -> {-# UNPACK #-} !Id [uninternString] :: InternedString -> String instance GHC.Classes.Eq (Data.Interned.Internal.Description Data.Interned.Internal.String.InternedString) instance Data.String.IsString Data.Interned.Internal.String.InternedString instance GHC.Classes.Eq Data.Interned.Internal.String.InternedString instance GHC.Classes.Ord Data.Interned.Internal.String.InternedString instance GHC.Show.Show Data.Interned.Internal.String.InternedString instance Data.Hashable.Class.Hashable Data.Interned.Internal.String.InternedString instance Data.Interned.Internal.Interned Data.Interned.Internal.String.InternedString instance Data.Interned.Internal.Uninternable Data.Interned.Internal.String.InternedString instance Data.Hashable.Class.Hashable (Data.Interned.Internal.Description Data.Interned.Internal.String.InternedString) module Data.Interned.Internal.Text data InternedText InternedText :: {-# UNPACK #-} !Id -> {-# UNPACK #-} !Text -> InternedText [internedTextId] :: InternedText -> {-# UNPACK #-} !Id [uninternedText] :: InternedText -> {-# UNPACK #-} !Text instance GHC.Classes.Eq (Data.Interned.Internal.Description Data.Interned.Internal.Text.InternedText) instance Data.String.IsString Data.Interned.Internal.Text.InternedText instance GHC.Classes.Eq Data.Interned.Internal.Text.InternedText instance GHC.Classes.Ord Data.Interned.Internal.Text.InternedText instance GHC.Show.Show Data.Interned.Internal.Text.InternedText instance Data.Hashable.Class.Hashable Data.Interned.Internal.Text.InternedText instance Data.Interned.Internal.Interned Data.Interned.Internal.Text.InternedText instance Data.Interned.Internal.Uninternable Data.Interned.Internal.Text.InternedText instance Data.Hashable.Class.Hashable (Data.Interned.Internal.Description Data.Interned.Internal.Text.InternedText) module Data.Interned.String data InternedString module Data.Interned.Text data InternedText