identifiers-0.2.1.0: Numeric identifiers for values.

Safe HaskellNone

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 aSource

The empty Identifiers

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

New Identifiers from list

Insertion

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

Insert item into set (given it a new id)

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

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 iSource

Find id for given key

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

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 -> iSource

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

Properties

prop_hasId :: String -> BoolSource

Items inserted are given ids

prop_stableId :: String -> BoolSource

Inserted items have stable ids

prop_keyRetrieval :: [String] -> BoolSource

Given id can be used to fetch inserted item

prop_keyRetrievalUnsafe :: [String] -> BoolSource

Given id can be used to fetch inserted item

prop_idempotent :: String -> BoolSource

Inserting something more than once does not change the set