-- 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.4.0 -- | Based on Data.IntSet, this module provides multi-dimensional -- sets of Enums. Keys are built using :& and -- terminated with S. They are stored using Ints so 2 keys -- that Enum to the same Int value will overwrite each -- other. The intension is that the Enum types will actually be -- newtype Ints. -- --
--   newtype AppleID = AppleID Int
--   newtype TreeID = TreeID Int
--   type Orchard = EnumMapSet (TreeID :& S AppleID)
--   applePresent = member (TreeID 4 :& K AppleID 32) orchard
--   
module Data.EnumMapSet type EnumMapSet k = EnumMapMap k () -- | Keys are terminated with the S type. -- --
--   singleKey :: S Int
--   singleKey = S 5
--   
newtype S k S :: k -> S k -- | Multiple keys are joined by the (:&) constructor. -- --
--   multiKey :: Int :& Int :& K Int
--   multiKey = 5 :& 6 :& K 5
--   
data (:&) k t (:&) :: !k -> !t -> :& k t null :: IsKey k => EnumMapSet k -> Bool size :: IsKey k => EnumMapSet k -> Int member :: (SubKey k1 k2 (), IsKey k1, IsKey k2) => k1 -> EnumMapSet k2 -> Bool -- | Lookup a subtree in an EnumMapSet. -- --
--   ems = fromList [1 :& 2 :& K 3, 1 :& 2 :& K 4]
--   lookup (1 :& K 2) ems == fromList [K 3, K 4]
--   lookup (1 :& 2 :& K 3) -- ERROR: Use 'member' to check for a key.
--   
lookup :: (SubKey k1 k2 (), IsKey k1, IsKey k2) => k1 -> EnumMapSet k2 -> Maybe (Result k1 k2 ()) empty :: IsKey k => EnumMapSet k singleton :: (IsKey k, SubKey k k (), Result k k () ~ ()) => k -> EnumMapSet k insert :: (IsKey k, SubKey k k (), Result k k () ~ ()) => k -> EnumMapSet k -> EnumMapSet k delete :: (SubKey k1 k2 (), IsKey k1, IsKey k2) => k1 -> EnumMapSet k2 -> EnumMapSet k2 union :: IsKey k => EnumMapSet k -> EnumMapSet k -> EnumMapSet k difference :: IsKey k => EnumMapSet k -> EnumMapSet k -> EnumMapSet k intersection :: IsKey k => EnumMapSet k -> EnumMapSet k -> EnumMapSet k -- | map f s is the set obtained by applying f to -- each element of s. -- -- It's worth noting that the size of the result may be smaller if, for -- some (x,y), x /= y && f x == f y map :: (IsKey k1, IsKey k2, SubKey k2 k2 (), Result k2 k2 () ~ ()) => (k1 -> k2) -> EnumMapSet k1 -> EnumMapSet k2 foldr :: IsKey k => (k -> t -> t) -> t -> EnumMapSet k -> t toList :: IsKey k => EnumMapSet k -> [k] fromList :: (IsKey k, SubKey k k (), Result k k () ~ ()) => [k] -> EnumMapSet k keys :: IsKey k => EnumMapSet k -> [k] -- | Strict EnumMapMap. Based upon Data.IntMap.Strict, this -- version uses multi dimensional keys and Enum types instead of -- Ints. Keys are built using the :& operator and -- terminated with K. They are stored using Ints so 2 keys -- that Enum to the same Int value will overwrite each -- other. The intension is that the Enum types will actually be -- newtype Ints. -- --
--   newtype AppleID = AppleID Int
--   newtype TreeID = TreeID Int
--   type Orchard = EnumMapMap (TreeID :& K AppleID) Apple
--   apple = lookup (TreeID 4 :& K AppleID 32) orchard
--   
-- -- The K type is different to that used in -- Data.EnumMapMap.Lazy so only strict operations can be performed -- on a strict EnumMapMap. -- -- The functions are strict on values and keys. module Data.EnumMapMap.Strict -- | No subtrees should be empty. Returns True if one is. emptySubTrees :: IsKey k => EnumMapMap k v -> Bool -- | Multiple keys are joined by the (:&) constructor. -- --
--   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
--   
newtype 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 :: IsKey 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 :: IsKey k => EnumMapMap k v -> Bool -- | Is the key present in the EnumMapMap? member :: SubKey k1 k2 v => k1 -> EnumMapMap k2 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
--   
-- -- If the given key has less dimensions then the EnumMapMap then a -- submap is returned. -- --
--   emm2 = fromList [(3 :& 2 :& K 1, "a"), (3 :& 2 :& K 4, "a")]
--   lookup (3 :& K 2) emm2 == Just $ fromList [(K 1, "a"), (K 4, "a")]
--   
lookup :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> EnumMapMap k2 v -> Maybe (Result k1 k2 v) -- | The empty EnumMapMap. empty :: IsKey k => EnumMapMap k v -- | An EnumMapMap with one element -- --
--   singleton (5 :& K 3) "a" == fromList [(5 :& K 3, "a")]
--   singleton (K 5) $ singleton (K 2) "a" == fromList [(5 :& K 3, "a")]
--   
singleton :: SubKey k1 k2 v => k1 -> Result k1 k2 v -> EnumMapMap k2 v -- | Insert a new key/value pair into the EnumMapMap. Can also -- insert submaps. insert :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Insert with a combining function. Can also insert submaps. insertWith :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => (Result k1 k2 v -> Result k1 k2 v -> Result k1 k2 v) -> k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Insert with a combining function. Can also insert submaps. insertWithKey :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => (k1 -> Result k1 k2 v -> Result k1 k2 v -> Result k1 k2 v) -> k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Remove a key and it's value from the EnumMapMap. If the key is -- not present the original EnumMapMap is returned. delete :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> EnumMapMap k2 v -> EnumMapMap k2 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 :: IsKey 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 :: IsKey k => EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWith :: IsKey k => (v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWithKey :: IsKey k => (k -> v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union of a list of maps. unions :: IsKey k => [EnumMapMap k v] -> EnumMapMap k v -- | Difference between two EnumMapMaps (based on keys). difference :: IsKey k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWith :: IsKey k => (v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWithKey :: IsKey k => (k -> v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The difference between an EnumMapMap and an -- EnumMapSet. If a key is present in the EnumMapSet it -- will not be present in the result. differenceSet :: (SubKeyS k s, IsKey k, IsKey s) => EnumMapMap k v -> EnumMapMap s () -> EnumMapMap k v -- | The (left-biased) intersection of two EnumMapMap (based on -- keys). intersection :: IsKey k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The intersection with a combining function. intersectionWith :: IsKey k => (v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection with a combining function. intersectionWithKey :: IsKey k => (k -> v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection of an EnumMapMap and an EnumMapSet. -- If a key is present in the EnumMapSet then it will be present in the -- resulting EnumMapMap. Works with EnumMapSets that are -- submaps of the EnumMapMap. intersectSet :: (SubKeyS k s, IsKey k, IsKey s) => EnumMapMap k v -> EnumMapMap s () -> EnumMapMap k v -- | Map a function over all values in the EnumMapMap. map :: IsKey k => (v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Map a function over all key/value pairs in the EnumMapMap. mapWithKey :: IsKey k => (k -> v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Fold the values in the EnumMapMap using the given -- right-associative binary operator foldr :: IsKey k => (v -> t -> t) -> t -> EnumMapMap k v -> t -- | Fold the keys and values in the EnumMapMap using the given -- right-associative binary operator. foldrWithKey :: IsKey k => (k -> v -> t -> t) -> t -> EnumMapMap k v -> t -- | Convert the EnumMapMap to a list of key/value pairs. toList :: (IsKey k, SubKey k k v) => EnumMapMap k v -> [(k, v)] -- | Create a EnumMapMap from a list of key/value pairs. fromList :: (IsKey k, SubKey k k v, Result k k v ~ v) => [(k, v)] -> EnumMapMap k v -- | List of keys keys :: IsKey k => EnumMapMap k v -> [k] -- | List of elements in ascending order of keys elems :: IsKey k => EnumMapMap k v -> [v] -- | The EnumMapSet of the keys. EnumMapMap keys can be -- converted into EnumMapSet keys using toS, and back again -- using toK. keysSet :: (IsKey k, HasSKey k) => EnumMapMap k v -> EnumMapMap (Skey k) () -- | Build an EnumMapMap from an EnumMapSet and a function -- which for each key computes it's value fromSet :: (IsKey k, HasSKey k) => (k -> v) -> EnumMapMap (Skey k) () -> EnumMapMap k v -- | Convert a key terminated with S into one terminated with -- K. -- --
--   s = 1 :& 2 :& S 3
--   toK s == 1 :& 2 :& K 3
--   
toK :: HasSKey k => Skey k -> k -- | Convert a key terminated with K into one terminated with -- S. -- --
--   k = 1 :& 2 :& 'K' 3
--   toS k == 1 :& 2 :& 'S' 3
--   
toS :: HasSKey k => k -> Skey k -- | 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 :: (IsKey k, IsKey (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 :: IsKey k => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v instance Show k => Show (K k) instance Eq k => Eq (K k) instance Enum k => SubKeyS (K k) (S k) instance (Enum k1, k1 ~ k2) => SubKeyS (k1 :& t) (S k2) instance Enum k => SubKey (K k) (K k) v instance (Enum k1, k1 ~ k2) => SubKey (K k1) (k2 :& t2) v instance IsSplit (k :& t) Z instance HasSKey (K k) instance NFData k => NFData (K k) instance NFData v => NFData (EnumMapMap (K k) v) instance Show v => Show (EnumMapMap (K k) v) instance (Enum k, Eq k) => IsKey (K k) -- | Lazy EnumMapMap. Based upon Data.IntMap.Lazy, this -- version uses multi dimensional keys and Enum types instead of -- Ints. Keys are built using the :& operator and -- terminated with K. They are stored using Ints so 2 keys -- that Enum to the same Int value will overwrite each -- other. The intension is that the Enum types will actually be -- newtype Ints. -- --
--   newtype AppleID = AppleID Int
--   newtype TreeID = TreeID Int
--   type Orchard = EnumMapMap (TreeID :& K AppleID) Apple
--   apple = lookup (TreeID 4 :& K AppleID 32) orchard
--   
-- -- The K type is different to that used in -- Data.EnumMapMap.Strict so only lazy operations can be performed -- on a lazy EnumMapMap. -- -- The functions are lazy on values, but strict on keys. module Data.EnumMapMap.Lazy -- | No subtrees should be empty. Returns True if one is. emptySubTrees :: IsKey k => EnumMapMap k v -> Bool -- | Multiple keys are joined by the (:&) constructor. -- --
--   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
--   
newtype 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 :: IsKey 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 :: IsKey k => EnumMapMap k v -> Bool -- | Is the key present in the EnumMapMap? member :: SubKey k1 k2 v => k1 -> EnumMapMap k2 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
--   
-- -- If the given key has less dimensions then the EnumMapMap then a -- submap is returned. -- --
--   emm2 = fromList [(3 :& 2 :& K 1, "a"), (3 :& 2 :& K 4, "a")]
--   lookup (3 :& K 2) emm2 == Just $ fromList [(K 1, "a"), (K 4, "a")]
--   
lookup :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> EnumMapMap k2 v -> Maybe (Result k1 k2 v) -- | The empty EnumMapMap. empty :: IsKey k => EnumMapMap k v -- | An EnumMapMap with one element -- --
--   singleton (5 :& K 3) "a" == fromList [(5 :& K 3, "a")]
--   singleton (K 5) $ singleton (K 2) "a" == fromList [(5 :& K 3, "a")]
--   
singleton :: SubKey k1 k2 v => k1 -> Result k1 k2 v -> EnumMapMap k2 v -- | Insert a new key/value pair into the EnumMapMap. Can also -- insert submaps. insert :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Insert with a combining function. Can also insert submaps. insertWith :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => (Result k1 k2 v -> Result k1 k2 v -> Result k1 k2 v) -> k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Insert with a combining function. Can also insert submaps. insertWithKey :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => (k1 -> Result k1 k2 v -> Result k1 k2 v -> Result k1 k2 v) -> k1 -> Result k1 k2 v -> EnumMapMap k2 v -> EnumMapMap k2 v -- | Remove a key and it's value from the EnumMapMap. If the key is -- not present the original EnumMapMap is returned. delete :: (SubKey k1 k2 v, IsKey k1, IsKey k2) => k1 -> EnumMapMap k2 v -> EnumMapMap k2 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 :: IsKey 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 :: IsKey k => EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWith :: IsKey k => (v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union with a combining function. unionWithKey :: IsKey k => (k -> v -> v -> v) -> EnumMapMap k v -> EnumMapMap k v -> EnumMapMap k v -- | The union of a list of maps. unions :: IsKey k => [EnumMapMap k v] -> EnumMapMap k v -- | Difference between two EnumMapMaps (based on keys). difference :: IsKey k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWith :: IsKey k => (v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | Difference with a combining function. differenceWithKey :: IsKey k => (k -> v1 -> v2 -> Maybe v1) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The difference between an EnumMapMap and an -- EnumMapSet. If a key is present in the EnumMapSet it -- will not be present in the result. differenceSet :: (SubKeyS k s, IsKey k, IsKey s) => EnumMapMap k v -> EnumMapMap s () -> EnumMapMap k v -- | The (left-biased) intersection of two EnumMapMap (based on -- keys). intersection :: IsKey k => EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v1 -- | The intersection with a combining function. intersectionWith :: IsKey k => (v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection with a combining function. intersectionWithKey :: IsKey k => (k -> v1 -> v2 -> v3) -> EnumMapMap k v1 -> EnumMapMap k v2 -> EnumMapMap k v3 -- | The intersection of an EnumMapMap and an EnumMapSet. -- If a key is present in the EnumMapSet then it will be present in the -- resulting EnumMapMap. Works with EnumMapSets that are -- submaps of the EnumMapMap. intersectSet :: (SubKeyS k s, IsKey k, IsKey s) => EnumMapMap k v -> EnumMapMap s () -> EnumMapMap k v -- | Map a function over all values in the EnumMapMap. map :: IsKey k => (v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Map a function over all key/value pairs in the EnumMapMap. mapWithKey :: IsKey k => (k -> v -> t) -> EnumMapMap k v -> EnumMapMap k t -- | Fold the values in the EnumMapMap using the given -- right-associative binary operator foldr :: IsKey k => (v -> t -> t) -> t -> EnumMapMap k v -> t -- | Fold the keys and values in the EnumMapMap using the given -- right-associative binary operator. foldrWithKey :: IsKey k => (k -> v -> t -> t) -> t -> EnumMapMap k v -> t -- | Convert the EnumMapMap to a list of key/value pairs. toList :: (IsKey k, SubKey k k v) => EnumMapMap k v -> [(k, v)] -- | Create a EnumMapMap from a list of key/value pairs. fromList :: (IsKey k, SubKey k k v, Result k k v ~ v) => [(k, v)] -> EnumMapMap k v -- | List of keys keys :: IsKey k => EnumMapMap k v -> [k] -- | List of elements in ascending order of keys elems :: IsKey k => EnumMapMap k v -> [v] -- | The EnumMapSet of the keys. EnumMapMap keys can be -- converted into EnumMapSet keys using toS, and back again -- using toK. keysSet :: (IsKey k, HasSKey k) => EnumMapMap k v -> EnumMapMap (Skey k) () -- | Build an EnumMapMap from an EnumMapSet and a function -- which for each key computes it's value fromSet :: (IsKey k, HasSKey k) => (k -> v) -> EnumMapMap (Skey k) () -> EnumMapMap k v -- | Convert a key terminated with S into one terminated with -- K. -- --
--   s = 1 :& 2 :& S 3
--   toK s == 1 :& 2 :& K 3
--   
toK :: HasSKey k => Skey k -> k -- | Convert a key terminated with K into one terminated with -- S. -- --
--   k = 1 :& 2 :& 'K' 3
--   toS k == 1 :& 2 :& 'S' 3
--   
toS :: HasSKey k => k -> Skey k -- | 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 :: (IsKey k, IsKey (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 :: IsKey k => EnumMapMap k (EnumMapMap k2 v) -> EnumMapMap (Plus k k2) v instance Show k => Show (K k) instance Eq k => Eq (K k) instance Enum k => SubKeyS (K k) (S k) instance (Enum k1, k1 ~ k2) => SubKeyS (k1 :& t) (S k2) instance Enum k => SubKey (K k) (K k) v instance (Enum k1, k1 ~ k2) => SubKey (K k1) (k2 :& t2) v instance IsSplit (k :& t) Z instance HasSKey (K k) instance NFData k => NFData (K k) instance NFData v => NFData (EnumMapMap (K k) v) instance Show v => Show (EnumMapMap (K k) v) instance (Enum k, Eq k) => IsKey (K k)