identifiers-0.4.0.0: Numeric identifiers for values.

Safe HaskellNone

Data.Identifiers.ListLike

Contents

Synopsis

Documentation

data Identifiers i n u Source

Instances

(Eq i, Eq n, Eq u) => Eq (Identifiers i n u) 
Show n => Show (Identifiers i n u) 
(Binary n, ListLike n u, Integral i, Eq u) => Binary (Identifiers i n u) 
(Serialize n, ListLike n u, Integral i, Eq u) => Serialize (Identifiers i n u) 
(NFData i, NFData n, NFData u) => NFData (Identifiers i n u) 

Construction

empty :: Identifiers i n uSource

The empty Identifiers

fromList :: (ListLike n u, Eq u, Integral i) => [n] -> Identifiers i n uSource

New Identifiers from list

Insertion

insert :: (ListLike n u, Eq u, Integral i) => Identifiers i n u -> n -> Identifiers i n uSource

Insert item into set (given it a new id)

insertMany :: (ListLike n u, Eq u, Integral i) => Identifiers i n u -> [n] -> Identifiers i n uSource

Insert many items into set

Info

Extraction

toList :: Identifiers i n u -> [n]Source

New List from Identifiers

Lookups

lookupId :: (Eq u, ListLike n u) => Identifiers i n u -> n -> Maybe iSource

Find id for given key

lookupKey :: Integral i => Identifiers i n u -> i -> Maybe nSource

Find key for given id

lookupKeys :: Integral i => Identifiers i n u -> [i] -> [n]Source

Given many ids, return many keys

unsafeLookupId :: (ListLike n u, Eq u) => Identifiers i n u -> n -> iSource

(!) :: Integral i => Identifiers i n u -> i -> nSource

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