-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Data interning (with compact regions where possible)
--
-- Interned (UTF8) ByteStrings where the interned structure is
-- held in a compact region, if possible.
--
--
-- - Data.ByteString.Intern does *not* use compact
-- regions
--
@package InternedData
@version 0.0.0.1
-- | This module keeps a persistent bimap between
-- ByteStrings and Ints.
module Data.ByteString.Interned.Internal
type InternedBimap = Bimap (HashMap ByteString Int) (Vector ByteString)
ibsBimap :: IORef InternedBimap
-- | Add UTF8 ByteString and return Int key. Will return
-- key for existing string and thereby serves for lookup in left-to-right
-- direction.
ibsBimapAdd :: ByteString -> Int
-- | Lookup based on an Int key. Unsafe totality assumption.
ibsBimapLookupInt :: Int -> ByteString
-- | An implementation of Int-mapped ByteStrings with
-- internalization. Wrap a ByteString with ibs to receive
-- a IBS. This internalizes the given ByteString,
-- meaning that two bytestring inputs x and y will
-- yield the same IBS if they have the same bytestring
-- representation.
--
-- For convenience, conversion from and to text is possible as well and
-- uses UTF8 encoding.
--
-- Since internalized ByteString values are never released, be
-- sure to use it sparingly. I.e. to internalize words, not full
-- sentences.
--
-- NOTE Currently, we use a ByteString internally and can not
-- compact the structure. The code remains, though as comments
-- in case we switch to another structure.
module Data.ByteString.Interned
pattern V_IBS :: () => Vector Int -> Vector (IBS k_afUo)
pattern MV_IBS :: () => MVector s Int -> MVector s (IBS k_afUo)
-- | An IBS behaves much like a ByteString, but is
-- represented as an Int internally. Its phantom type is
-- polykinded, since we might want to use type-level strings to name
-- things.
newtype IBS k
IBS :: Int -> IBS k
[getIBS] :: IBS k -> Int
ibs :: ByteString -> IBS k
-- | Handy wrapper to internalize a Text and get a IBS.
ibsText :: Text -> IBS k
-- | Convert into an IBS, using a Text intermediate for
-- proper UTF8 conversion.
ibsFrom :: ConvertibleStrings x Text => x -> IBS k
ibsTo :: ConvertibleStrings Text x => IBS k -> x
ibsToText :: IBS k -> Text
ibsToUtf8 :: IBS k -> ByteString
instance forall k1 (k2 :: k1). Data.Vector.Unboxed.Base.Unbox (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). GHC.Classes.Ord (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.String.IsString (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). GHC.Show.Show (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). GHC.Read.Read (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Hashable.Class.Hashable (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Control.DeepSeq.NFData (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Binary.Class.Binary (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Serialize.Serialize (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Aeson.Types.FromJSON.FromJSON (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). Data.Aeson.Types.ToJSON.ToJSON (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). GHC.Generics.Generic (Data.ByteString.Interned.IBS k2)
instance forall k1 (k2 :: k1). GHC.Classes.Eq (Data.ByteString.Interned.IBS k2)