-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Map of maps using Enum types as keys -- -- This package provides 'maps of maps' using Enum types as keys. The -- code is based upon Data.IntMap in containers 5.0. @package enummapmap @version 0.0.2 module Data.EnumMapMap.Strict -- | No subtrees should be empty. Returns True if one is. emptySubTrees :: IsEmm k => EnumMapMap k v -> Bool -- | Multiple keys are joined by the (:&) constructor and -- terminated with K. -- --
--   multiKey :: Int :& Int :& K Int
--   multiKey = 5 :& 6 :& K 5
--   
data (:&) k t (:&) :: !k -> !t -> :& k t -- | Keys are terminated with the K type -- --
--   singleKey :: K Int
--   singleKey = K 5
--   
data K k K :: !k -> K k -- | Split after 1 key. -- --
--   emm :: EnumMapMap (T1 :& T2 :& K T3) v
--   splitKey d1 emm :: EnumMapMap (T1 :& K T2) (EnumMapMap (K T3) v)
--   
d1 :: Z -- | Split after 2 keys. -- --
--   emm :: EnumMapMap (T1 :& T2 :& K T3) v
--   splitKey d1 emm :: EnumMapMap (K T1) (EnumMapMap (T2 :& K T3) v)
--   
d2 :: N (Z) d3 :: N (N (Z)) d4 :: N (N (N (Z))) d5 :: N (N (N (N (Z)))) d6 :: N (N (N (N (N (Z))))) d7 :: N (N (N (N (N (N (Z)))))) d8 :: N (N (N (N (N (N (N (Z))))))) d9 :: N (N (N (N (N (N (N (N (Z)))))))) d10 :: N (N (N (N (N (N (N (N (N (Z))))))))) -- | Number of elements in the EnumMapMap. size :: IsEmm k => EnumMapMap k v -> Int -- | Is the EnumMapMap empty? -- -- Submaps can never be empty, so the following should always hold true: -- --
--   emm :: EnumMapMap (Int :& Int :& K ID) Bool)
--   null $ splitKey x emm == False
--   
null :: IsEmm k => EnumMapMap k v -> Bool -- | Is the key present in the EnumMapMap? member :: IsEmm k => k -> EnumMapMap k v -> Bool -- | Lookup up the value at a key in the EnumMapMap. -- --
--   emm = fromList [(3 :& K 1, "a")]
--   lookup (3 :& K 1) emm == Just "a"
--   lookup (2 :& K 1) emm == Nothing
--   
lookup :: IsEmm k => k -> EnumMapMap k v -> Maybe v -- | The empty EnumMapMap. empty :: IsEmm k => EnumMapMap k v -- | An EnumMapMap with one element -- --
--   singleton (5 :& K 3) "a" == fromList [(5 :& K 3, "a")]
--   
singleton :: IsEmm k => k -> v -> EnumMapMap k v -- | Insert a new Key/Value pair into the EnumMapMap. insert :: IsEmm k => k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Insert with a combining function. insertWith :: IsEmm k => (v -> v -> v) -> k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Insert with a combining function. insertWithKey :: IsEmm k => (k -> v -> v -> v) -> k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Remove a key and it's value from the EnumMapMap. If the key is -- not present the original EnumMapMap is returned. delete :: IsEmm k => k -> EnumMapMap k v -> EnumMapMap k v -- | The expression (alter f k emm) alters the value at -- k, or absence thereof. alter can be used to insert, -- delete, or update a value in an EnumMapMap. alter :: IsEmm k => (Maybe v -> Maybe v) -> k -> EnumMapMap k v -> EnumMapMap k v -- | The (left-biased) union of two EnumMapMaps. It prefers the -- first EnumMapMap when duplicate keys are encountered. union :: IsEmm k => EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWith :: IsEmm k => (v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWithKey :: IsEmm k => (k -> v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union of a list of maps. unions :: IsEmm k => [EnumMapMap k v] -> EnumMapMap k v -- | Difference between two EnumMapMaps (based on keys). difference :: IsEmm k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWith :: IsEmm k => (v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWithKey :: IsEmm k => (k -> v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The (left-biased) intersection of two EnumMapMap (based on -- keys). intersection :: IsEmm k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The intersection with a combining function. intersectionWith :: IsEmm k => (v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection with a combining function. intersectionWithKey :: IsEmm k => (k -> v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | Map a function over all values in the EnumMapMap. map :: IsEmm k => (v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Map a function over all key/value pairs in the EnumMapMap. mapWithKey :: IsEmm k => (k -> v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Fold the keys and values in the map using the given right-associative -- binary operator. foldrWithKey :: IsEmm k => (k -> v -> t -> t) -> t -> EnumMapMap k v -> t -- | Convert the EnumMapMap to a list of key/value pairs. toList :: IsEmm k => EnumMapMap k v -> [(k, v)] -- | Create a EnumMapMap from a list of key/value pairs. fromList :: IsEmm k => [(k, v)] -> EnumMapMap k v -- | Split a key so that an EnumMapMap becomes an EnumMapMap -- of EnumMapMaps. -- --
--   newtype ID = ID Int deriving Enum
--   emm = empty :: EnumMapMap (Int :& K ID) Bool
--   res :: EnumMapMap (K ID) Bool
--   res = lookup (K 5) $ splitKey d1 emm
--   
-- -- If the level is too high then the compilation will fail with an error -- --
--   emm = empty :: EnumMapMap (Int :& Int :& K Int) Bool -- 3 levels
--   res1 = splitKey d4 emm -- ERROR! Instance not found...
--   res2 = splitKey d3 emm -- ERROR! Instance not found...
--   res3 = splitKey d2 emm -- Good
--   
splitKey :: IsSplit k z => z -> EnumMapMap k v -> EnumMapMap (Head k z) (EnumMapMap (Tail k z) v) -- | Join a key so that an EnumMapMap of EnumMapMaps becomes -- an EnumMapMap. -- --
--   newtype ID = ID Int deriving Enum
--   emm :: EnumMapMap (K Int) (EnumMapMap (K ID) Bool)
--   res :: EnumMapMap (Int :& K ID) Bool
--   res = joinKey emm
--   
-- -- joinKey is the opposite of splitKey. -- --
--   emm = empty :: EnumMapMap (Int :& Int :& K ID) Bool)
--   emm == joinKey $ splitKey d2 emm
--   
joinKey :: (IsEmm k, IsEmm (Plus k k2)) => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v -- | Join a key so that an EnumMapMap of EnumMapMaps becomes -- an EnumMapMap. The unsafe version does not check for empty -- subtrees, so it is faster. -- --
--   newtype ID = ID Int deriving Enum
--   emm :: EnumMapMap (K Int) (EnumMapMap (K ID) Bool)
--   res :: EnumMapMap (Int :& K ID) Bool
--   res = unsafeJoinKey emm
--   
unsafeJoinKey :: IsEmm k => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v instance IsSplit (k :& t) Z instance NFData v => NFData (EnumMapMap (K k) v) instance Show v => Show (EnumMapMap (K k) v) instance Enum k => IsEmm (K k) module Data.EnumMapMap.Lazy -- | No subtrees should be empty. Returns True if one is. emptySubTrees :: IsEmm k => EnumMapMap k v -> Bool -- | Multiple keys are joined by the (:&) constructor and -- terminated with K. -- --
--   multiKey :: Int :& Int :& K Int
--   multiKey = 5 :& 6 :& K 5
--   
data (:&) k t (:&) :: !k -> !t -> :& k t -- | Keys are terminated with the K type -- --
--   singleKey :: K Int
--   singleKey = K 5
--   
data K k K :: !k -> K k -- | Split after 1 key. -- --
--   emm :: EnumMapMap (T1 :& T2 :& K T3) v
--   splitKey d1 emm :: EnumMapMap (T1 :& K T2) (EnumMapMap (K T3) v)
--   
d1 :: Z -- | Split after 2 keys. -- --
--   emm :: EnumMapMap (T1 :& T2 :& K T3) v
--   splitKey d1 emm :: EnumMapMap (K T1) (EnumMapMap (T2 :& K T3) v)
--   
d2 :: N (Z) d3 :: N (N (Z)) d4 :: N (N (N (Z))) d5 :: N (N (N (N (Z)))) d6 :: N (N (N (N (N (Z))))) d7 :: N (N (N (N (N (N (Z)))))) d8 :: N (N (N (N (N (N (N (Z))))))) d9 :: N (N (N (N (N (N (N (N (Z)))))))) d10 :: N (N (N (N (N (N (N (N (N (Z))))))))) -- | Number of elements in the EnumMapMap. size :: IsEmm k => EnumMapMap k v -> Int -- | Is the EnumMapMap empty? -- -- Submaps can never be empty, so the following should always hold true: -- --
--   emm :: EnumMapMap (Int :& Int :& K ID) Bool)
--   null $ splitKey x emm == False
--   
null :: IsEmm k => EnumMapMap k v -> Bool -- | Is the key present in the EnumMapMap? member :: IsEmm k => k -> EnumMapMap k v -> Bool -- | Lookup up the value at a key in the EnumMapMap. -- --
--   emm = fromList [(3 :& K 1, "a")]
--   lookup (3 :& K 1) emm == Just "a"
--   lookup (2 :& K 1) emm == Nothing
--   
lookup :: IsEmm k => k -> EnumMapMap k v -> Maybe v -- | The empty EnumMapMap. empty :: IsEmm k => EnumMapMap k v -- | An EnumMapMap with one element -- --
--   singleton (5 :& K 3) "a" == fromList [(5 :& K 3, "a")]
--   
singleton :: IsEmm k => k -> v -> EnumMapMap k v -- | Insert a new Key/Value pair into the EnumMapMap. insert :: IsEmm k => k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Insert with a combining function. insertWith :: IsEmm k => (v -> v -> v) -> k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Insert with a combining function. insertWithKey :: IsEmm k => (k -> v -> v -> v) -> k -> v -> EnumMapMap k v -> EnumMapMap k v -- | Remove a key and it's value from the EnumMapMap. If the key is -- not present the original EnumMapMap is returned. delete :: IsEmm k => k -> EnumMapMap k v -> EnumMapMap k v -- | The expression (alter f k emm) alters the value at -- k, or absence thereof. alter can be used to insert, -- delete, or update a value in an EnumMapMap. alter :: IsEmm k => (Maybe v -> Maybe v) -> k -> EnumMapMap k v -> EnumMapMap k v -- | The (left-biased) union of two EnumMapMaps. It prefers the -- first EnumMapMap when duplicate keys are encountered. union :: IsEmm k => EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWith :: IsEmm k => (v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWithKey :: IsEmm k => (k -> v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union of a list of maps. unions :: IsEmm k => [EnumMapMap k v] -> EnumMapMap k v -- | Difference between two EnumMapMaps (based on keys). difference :: IsEmm k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWith :: IsEmm k => (v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWithKey :: IsEmm k => (k -> v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The (left-biased) intersection of two EnumMapMap (based on -- keys). intersection :: IsEmm k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The intersection with a combining function. intersectionWith :: IsEmm k => (v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection with a combining function. intersectionWithKey :: IsEmm k => (k -> v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | Map a function over all values in the EnumMapMap. map :: IsEmm k => (v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Map a function over all key/value pairs in the EnumMapMap. mapWithKey :: IsEmm k => (k -> v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Fold the keys and values in the map using the given right-associative -- binary operator. foldrWithKey :: IsEmm k => (k -> v -> t -> t) -> t -> EnumMapMap k v -> t -- | Convert the EnumMapMap to a list of key/value pairs. toList :: IsEmm k => EnumMapMap k v -> [(k, v)] -- | Create a EnumMapMap from a list of key/value pairs. fromList :: IsEmm k => [(k, v)] -> EnumMapMap k v -- | Split a key so that an EnumMapMap becomes an EnumMapMap -- of EnumMapMaps. -- --
--   newtype ID = ID Int deriving Enum
--   emm = empty :: EnumMapMap (Int :& K ID) Bool
--   res :: EnumMapMap (K ID) Bool
--   res = lookup (K 5) $ splitKey d1 emm
--   
-- -- If the level is too high then the compilation will fail with an error -- --
--   emm = empty :: EnumMapMap (Int :& Int :& K Int) Bool -- 3 levels
--   res1 = splitKey d4 emm -- ERROR! Instance not found...
--   res2 = splitKey d3 emm -- ERROR! Instance not found...
--   res3 = splitKey d2 emm -- Good
--   
splitKey :: IsSplit k z => z -> EnumMapMap k v -> EnumMapMap (Head k z) (EnumMapMap (Tail k z) v) -- | Join a key so that an EnumMapMap of EnumMapMaps becomes -- an EnumMapMap. -- --
--   newtype ID = ID Int deriving Enum
--   emm :: EnumMapMap (K Int) (EnumMapMap (K ID) Bool)
--   res :: EnumMapMap (Int :& K ID) Bool
--   res = joinKey emm
--   
-- -- joinKey is the opposite of splitKey. -- --
--   emm = empty :: EnumMapMap (Int :& Int :& K ID) Bool)
--   emm == joinKey $ splitKey d2 emm
--   
joinKey :: (IsEmm k, IsEmm (Plus k k2)) => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v -- | Join a key so that an EnumMapMap of EnumMapMaps becomes -- an EnumMapMap. The unsafe version does not check for empty -- subtrees, so it is faster. -- --
--   newtype ID = ID Int deriving Enum
--   emm :: EnumMapMap (K Int) (EnumMapMap (K ID) Bool)
--   res :: EnumMapMap (Int :& K ID) Bool
--   res = unsafeJoinKey emm
--   
unsafeJoinKey :: IsEmm k => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v instance IsSplit (k :& t) Z instance NFData v => NFData (EnumMapMap (K k) v) instance Show v => Show (EnumMapMap (K k) v) instance Enum k => IsEmm (K k)