Copyright | (c) Sam Truzjan 2013 |
---|---|
License | BSD3 |
Maintainer | pxqr.sta@gmail.com |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module defines a simple key/value list ordered by keys which both faster and more suitable for bencode dictionaries than just [(k,v)].
Synopsis
- type BKey = ByteString
- data BDictMap a
- empty :: BDictMap a
- singleton :: BKey -> a -> BDictMap a
- null :: BDictMap a -> Bool
- member :: BKey -> BDictMap a -> Bool
- lookup :: BKey -> BDictMap a -> Maybe a
- union :: BDictMap a -> BDictMap a -> BDictMap a
- map :: (a -> b) -> BDictMap a -> BDictMap b
- mapWithKey :: (BKey -> a -> b) -> BDictMap a -> BDictMap b
- foldMapWithKey :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m
- bifoldMap :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m
- fromAscList :: [(BKey, a)] -> BDictMap a
- toAscList :: BDictMap a -> [(BKey, a)]
Documentation
type BKey = ByteString Source #
BDictMap is an ascending list of key/value pairs sorted by keys.
Instances
Construction
Query
Combine
union :: BDictMap a -> BDictMap a -> BDictMap a Source #
O(n + m). Merge two dictionaries by taking pair from both given dictionaries. Dublicated keys are not filtered.
Maps
map :: (a -> b) -> BDictMap a -> BDictMap b Source #
O(n). Map a function over all values in the dictionary.
mapWithKey :: (BKey -> a -> b) -> BDictMap a -> BDictMap b Source #
O(n). Map a function over all keys/value pairs in the dictionary.
Folds
foldMapWithKey :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m Source #
O(n). Map each key/value pair to a monoid and fold resulting
sequnce using mappend
.
bifoldMap :: Monoid m => (BKey -> a -> m) -> BDictMap a -> m Source #
Deprecated: Use foldMapWithKey instead
O(n). Map each key/value pair to a monoid and fold resulting
sequnce using mappend
.
Conversion
fromAscList :: [(BKey, a)] -> BDictMap a Source #
O(n). Build a dictionary from a list of key/value pairs where the keys are in ascending order.