identifiers-0.3.1.0: Numeric identifiers for values.

Safe HaskellNone
LanguageHaskell2010

Data.Identifiers

Contents

Synopsis

Documentation

data Identifiers i a Source

Instances

(Eq i, Eq a) => Eq (Identifiers i a) 
Show a => Show (Identifiers i a) 
(Binary i, Eq a, Hashable a, Binary a) => Binary (Identifiers i a) 
(Serialize i, Eq a, Hashable a, Serialize a) => Serialize (Identifiers i a) 
(NFData i, NFData a) => NFData (Identifiers i a) 

Construction

empty :: Identifiers i a Source

The empty Identifiers

fromList :: (Integral i, Hashable a, Eq a) => [a] -> Identifiers i a Source

New Identifiers from list

Insertion

insert :: (Integral i, Hashable a, Eq a) => Identifiers i a -> a -> Identifiers i a Source

Insert item into set (given it a new id)

insertMany :: (Integral i, Hashable a, Eq a) => Identifiers i a -> [a] -> Identifiers i a Source

Insert many items into set

Info

Extraction

toList :: Identifiers i a -> [a] Source

New List from Identifiers

Lookups

lookupId :: (Hashable a, Eq a) => Identifiers i a -> a -> Maybe i Source

Find id for given key

lookupKey :: Integral i => Identifiers i a -> i -> Maybe a Source

Find key for given id

lookupKeys :: Integral i => Identifiers i a -> [i] -> [a] Source

Given many ids, return many keys

unsafeLookupId :: (Hashable a, Eq a) => Identifiers i a -> a -> i Source

(!) :: Integral i => Identifiers i a -> i -> a Source

Properties

prop_hasId :: String -> Bool Source

Items inserted are given ids

prop_stableId :: String -> Bool Source

Inserted items have stable ids

prop_keyRetrieval :: [String] -> Bool Source

Given id can be used to fetch inserted item

prop_keyRetrievalUnsafe :: [String] -> Bool Source

Given id can be used to fetch inserted item

prop_idempotent :: String -> Bool Source

Inserting something more than once does not change the set