-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Numeric identifiers for values. -- -- This library allows you to turn costly repetitive values into numbers -- in order to save memory. An Identifiers value acts like a -- bi-directional map that allows you to effeciently toggle between a -- numeric key and the original value pushed into the map. @package identifiers @version 0.4.2.0 -- | Identifiers for ListLike values. -- -- Example usage: -- --
--   >>> xs = fromList ["foo", "bar", "baz", "foo"]
--   
--   >>> lookupId xs "baz"
--   Just 2
--   
--   >>> lookupKey xs 2
--   Just "baz"
--   
module Data.Identifiers.ListLike data Identifiers i n u -- | The empty Identifiers empty :: Identifiers i n u -- | New Identifiers from list fromList :: (ListLike n u, Eq u, Integral i) => [n] -> Identifiers i n u -- | Combine two identifier sets into one. Because the ids will change -- while combining two sets, a map is also returned that identifies the -- new location of old ids for the second set passed in. combine :: (ListLike n u, Integral i, Eq u) => Identifiers i n u -> Identifiers i n u -> (Identifiers i n u, Map i i) -- | Insert item into set (given it a new id) insert :: (ListLike n u, Eq u, Integral i) => Identifiers i n u -> n -> Identifiers i n u -- | Insert many items into set insertMany :: (ListLike n u, Eq u, Integral i) => Identifiers i n u -> [n] -> Identifiers i n u -- | Number of items in Identifiers value size :: Identifiers i n u -> Int -- | New List from Identifiers toList :: Identifiers i n u -> [n] -- | Find id for given value lookupId :: (Eq u, ListLike n u) => Identifiers i n u -> n -> Maybe i -- | Find key for given id lookupKey :: (Integral i) => Identifiers i n u -> i -> Maybe n -- | Given many ids, return many keys. Ids with no associated values will -- be omitted from the resulting list. lookupKeys :: (Integral i) => Identifiers i n u -> [i] -> [n] -- | Find numeric id for given value. Will error when the value is not a -- member of the Identifiers map. unsafeLookupId :: (ListLike n u, Eq u) => Identifiers i n u -> n -> i -- | Find id for given value. Will error when the id has no associated -- value. unsafeLookupKey :: Integral i => Identifiers i n u -> i -> n -- | Infix version of unsafeLookupKey (!) :: Integral i => Identifiers i n u -> i -> n -- | Items inserted are given ids prop_hasId :: String -> Bool -- | Inserted items have stable ids prop_stableId :: String -> Bool -- | Given id can be used to fetch inserted item prop_keyRetrieval :: [String] -> Bool -- | Given id can be used to fetch inserted item prop_keyRetrievalUnsafe :: [String] -> Bool -- | Inserting something more than once does not change the set prop_idempotent :: String -> Bool -- | Ids for the first set passed to combine remain unchanged prop_stableCombine :: [String] -> [String] -> Bool -- | Ensure the migration points to the same value in both old and new sets prop_properMigration :: [String] -> [String] -> Bool instance (GHC.Classes.Eq n, GHC.Classes.Eq i, GHC.Classes.Eq u) => GHC.Classes.Eq (Data.Identifiers.ListLike.Identifiers i n u) instance GHC.Show.Show n => GHC.Show.Show (Data.Identifiers.ListLike.Identifiers i n u) instance (Data.Binary.Class.Binary n, Data.ListLike.Base.ListLike n u, GHC.Real.Integral i, GHC.Classes.Eq u) => Data.Binary.Class.Binary (Data.Identifiers.ListLike.Identifiers i n u) instance (Data.Serialize.Serialize n, Data.ListLike.Base.ListLike n u, GHC.Real.Integral i, GHC.Classes.Eq u) => Data.Serialize.Serialize (Data.Identifiers.ListLike.Identifiers i n u) instance (Control.DeepSeq.NFData i, Control.DeepSeq.NFData n, Control.DeepSeq.NFData u) => Control.DeepSeq.NFData (Data.Identifiers.ListLike.Identifiers i n u) -- | Identifiers for Hashable values. -- -- Example usage: -- --
--   >>> xs = fromList ["foo", "bar", "baz", "foo"]
--   
--   >>> lookupId xs "baz"
--   Just 2
--   
--   >>> lookupKey xs 2
--   Just "baz"
--   
module Data.Identifiers.Hashable data Identifiers i a -- | The empty Identifiers empty :: Identifiers i a -- | New Identifiers from list fromList :: (Integral i, Hashable a, Eq a) => [a] -> Identifiers i a -- | Combine two identifier sets into one. Because the ids will change -- while combining two sets, a map is also returned that identifies the -- new location of old ids for the second set passed in. combine :: (Integral i, Hashable a, Eq a) => Identifiers i a -> Identifiers i a -> (Identifiers i a, Map i i) -- | Insert item into set (given it a new id) insert :: (Integral i, Hashable a, Eq a) => Identifiers i a -> a -> Identifiers i a -- | Insert many items into set insertMany :: (Integral i, Hashable a, Eq a) => Identifiers i a -> [a] -> Identifiers i a -- | Number of items in Identifiers value size :: Identifiers i a -> Int -- | New List from Identifiers toList :: Identifiers i a -> [a] -- | Find id for given key lookupId :: (Hashable a, Eq a) => Identifiers i a -> a -> Maybe i -- | Find key for given id lookupKey :: (Integral i) => Identifiers i a -> i -> Maybe a -- | Given many ids, return many keys lookupKeys :: (Integral i) => Identifiers i a -> [i] -> [a] -- | Find numeric id for given value. Will error when the value is not a -- member of the Identifiers map. unsafeLookupId :: (Hashable a, Eq a) => Identifiers i a -> a -> i -- | Find id for given value. Will error when the id has no associated -- value. unsafeLookupKey :: Integral i => Identifiers i a -> i -> a -- | Infix version of unsafeLookupKey (!) :: Integral i => Identifiers i a -> i -> a -- | Items inserted are given ids prop_hasId :: String -> Bool -- | Inserted items have stable ids prop_stableId :: String -> Bool -- | Given id can be used to fetch inserted item prop_keyRetrieval :: [String] -> Bool -- | Given id can be used to fetch inserted item prop_keyRetrievalUnsafe :: [String] -> Bool -- | Inserting something more than once does not change the set prop_idempotent :: String -> Bool -- | Ids for the first set passed to combine remain unchanged prop_stableCombine :: [String] -> [String] -> Bool -- | Ensure the migration points to the same value in both old and new sets prop_properMigration :: [String] -> [String] -> Bool instance (GHC.Classes.Eq i, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Identifiers.Hashable.Identifiers i a) instance GHC.Show.Show a => GHC.Show.Show (Data.Identifiers.Hashable.Identifiers i a) instance (Data.Binary.Class.Binary i, GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Data.Identifiers.Hashable.Identifiers i a) instance (Data.Serialize.Serialize i, GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Serialize.Serialize a) => Data.Serialize.Serialize (Data.Identifiers.Hashable.Identifiers i a) instance (Control.DeepSeq.NFData i, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Data.Identifiers.Hashable.Identifiers i a)