Portability | portable |
---|---|
Stability | experimental |
Maintainer | Stefan Schmidt (stefanschmidt@web.de) |
Version : 0.1
The KeyMap is derived from the Data.Map type. The keys of the Map are strings and the values can be arbitrary data objects. But you don't have to specify the keys because every value-object is able to create it's own key via the Key typeclass.
From the functionality, the KeyMap stands between a set and a Map. If you want to insert an element to the map, it behaves like a set. You don't need an additionnal key and it makes no different if you insert an object multiple times. If you want to access the objects in the KeyMap, you can lookup them via the key, so in this case this container behaves like an ordinary map.
The functions for this container are named after the standard Map and Set functions.
- data KeyMap a
- class Key n where
- empty :: KeyMap a
- null :: Key a => KeyMap a -> Bool
- insert :: Key a => a -> KeyMap a -> KeyMap a
- lookup :: (Key a, Monad m) => String -> KeyMap a -> m a
- keys :: Key a => KeyMap a -> [String]
- elems :: Key a => KeyMap a -> [a]
- memberKey :: Key a => String -> KeyMap a -> Bool
- memberElem :: Key a => a -> KeyMap a -> Bool
- deleteKey :: Key a => String -> KeyMap a -> KeyMap a
- deleteElem :: Key a => a -> KeyMap a -> KeyMap a
- fromList :: Key a => [a] -> KeyMap a
- toList :: Key a => KeyMap a -> [a]
- toAscList :: Key a => KeyMap a -> [a]
Documentation
The KeyMap datatype.
Every element of this map has to implement a key-function. which gives us the key of the element
lookup :: (Key a, Monad m) => String -> KeyMap a -> m aSource
Gets all different elements for one key or an empty set.
elems :: Key a => KeyMap a -> [a]Source
Get all different values in the map without regarding their keys.
memberElem :: Key a => a -> KeyMap a -> BoolSource
Test, if a data object is in the KeyMap.
deleteElem :: Key a => a -> KeyMap a -> KeyMap aSource
Deletes a single elemet from the KeyMap.