-- 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.4

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).
--   
--   
--   
- Chris Okasaki and Andy Gill, "Fast Mergeable Integer Maps",
--   Workshop on ML, September 1998, pages 77-86,
--   http://citeseer.ist.psu.edu/okasaki98fast.html
--   
- D.R. Morrison, "/PATRICIA -- Practical Algorithm To Retrieve
--   Information Coded In Alphanumeric/", Journal of the ACM, 15(4),
--   October 1968, pages 514-534.
--   
--   
--   Many operations have a worst-case complexity of O(min(n,W)).
--   This means that the operation can become linear in the number of
--   elements with a maximum of W -- the number of bits in an
--   Int (32 or 64).
--   
--   Unlike the reference implementation in Data.IntSet,
--   Data.Interned.IntSet uses hash consing to ensure that there is only
--   ever one copy of any given IntSet in memory. This is enabled by the
--   normal form of the PATRICIA trie.
--   
--   This can mean a drastic reduction in the memory footprint of a program
--   in exchange for much more costly set manipulation.
module Data.Interned.IntSet

-- | A set of integers.
data IntSet

-- | A unique integer ID associated with each interned set.
identity :: IntSet -> Id

-- | O(n+m). See difference.
(\\) :: IntSet -> IntSet -> IntSet
infixl 9 \\

-- | O(1). Is the set empty?
null :: IntSet -> Bool

-- | O(1). Cardinality of the set.
size :: IntSet -> Int

-- | O(min(n,W)). Is the value a member of the set?
member :: Int -> IntSet -> Bool

-- | O(min(n,W)). Is the element not in the set?
notMember :: Int -> IntSet -> Bool

-- | O(n+m). Is this a subset? (s1 isSubsetOf s2)
--   tells whether s1 is a subset of s2.
isSubsetOf :: IntSet -> IntSet -> Bool

-- | O(n+m). Is this a proper subset? (ie. a subset but not equal).
isProperSubsetOf :: IntSet -> IntSet -> Bool

-- | O(1). The empty set.
empty :: IntSet

-- | O(1). A set of one element.
singleton :: Int -> IntSet

-- | O(min(n,W)). Add a value to the set. When the value is already
--   an element of the set, it is replaced by the new one, ie.
--   insert is left-biased.
insert :: Int -> IntSet -> IntSet

-- | O(min(n,W)). Delete a value in the set. Returns the original
--   set when the value was not present.
delete :: Int -> IntSet -> IntSet

-- | O(n+m). The union of two sets.
union :: IntSet -> IntSet -> IntSet

-- | The union of a list of sets.
unions :: [IntSet] -> IntSet

-- | O(n+m). Difference between two sets.
difference :: IntSet -> IntSet -> IntSet

-- | O(n+m). The intersection of two sets.
intersection :: IntSet -> IntSet -> IntSet

-- | O(n). Filter all elements that satisfy some predicate.
filter :: (Int -> Bool) -> IntSet -> IntSet

-- | O(n). partition the set according to some predicate.
partition :: (Int -> Bool) -> IntSet -> (IntSet, IntSet)

-- | O(min(n,W)). The expression (split x set) is a
--   pair (set1,set2) where set1 comprises the elements
--   of set less than x and set2 comprises the
--   elements of set greater than x.
--   
--   
--   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
