{-# LANGUAGE CPP #-}
module Data.EnumMap.Strict
( EnumMap
, intMapToEnumMap
, enumMapToIntMap
, (!)
, (\\)
, null
, size
, member
, notMember
, lookup
, findWithDefault
, lookupLT
, lookupGT
, lookupLE
, lookupGE
, empty
, singleton
, insert
, insertWith
, insertWithKey
, insertLookupWithKey
, delete
, adjust
, adjustWithKey
, update
, updateWithKey
, updateLookupWithKey
, alter
, alterF
, union
, unionWith
, unionWithKey
, unions
, unionsWith
, difference
, differenceWith
, differenceWithKey
, intersection
, intersectionWith
, intersectionWithKey
, mergeWithKey
, map
, mapWithKey
, traverseWithKey
, mapAccum
, mapAccumWithKey
, mapAccumRWithKey
, mapKeys
, mapKeysWith
, mapKeysMonotonic
, foldr
, foldl
, foldrWithKey
, foldlWithKey
, foldr'
, foldl'
, foldrWithKey'
, foldlWithKey'
, elems
, keys
, assocs
, keysSet
, fromSet
, toList
, fromList
, fromListWith
, fromListWithKey
, toAscList
, toDescList
, fromAscList
, fromAscListWith
, fromAscListWithKey
, fromDistinctAscList
, filter
, filterWithKey
#if (MIN_VERSION_containers(0,5,8))
, restrictKeys
, withoutKeys
#endif
, partition
, partitionWithKey
, mapMaybe
, mapMaybeWithKey
, mapEither
, mapEitherWithKey
, split
, splitLookup
, isSubmapOf
, isSubmapOfBy
, isProperSubmapOf
, isProperSubmapOfBy
, lookupMin
, lookupMax
, findMin
, findMax
, deleteMin
, deleteMax
, deleteFindMin
, deleteFindMax
, updateMin
, updateMax
, updateMinWithKey
, updateMaxWithKey
, minView
, maxView
, minViewWithKey
, maxViewWithKey
) where
import Prelude hiding (filter, foldl, foldr, lookup, map, null)
import qualified Prelude as P
import Control.Arrow (first, second, (***))
import qualified Data.IntMap.Strict as I
import Data.EnumSet (EnumSet)
import qualified Data.EnumSet as EnumSet
import Data.EnumMap.Base hiding (adjust, adjustWithKey, alter, alterF, differenceWith,
differenceWithKey, findWithDefault, fromAscList,
fromAscListWith, fromAscListWithKey,
fromDistinctAscList, fromList, fromListWith,
fromListWithKey, fromSet, insert, insertLookupWithKey,
insertWith, insertWithKey, intersectionWith,
intersectionWithKey, map, mapAccum, mapAccumRWithKey,
mapAccumWithKey, mapEither, mapEitherWithKey,
mapKeysWith, mapMaybe, mapMaybeWithKey, mapWithKey,
mergeWithKey, singleton, unionWith, unionWithKey,
unionsWith, update, updateLookupWithKey, updateMax,
updateMaxWithKey, updateMin, updateMinWithKey,
updateWithKey)
findWithDefault :: (Enum k) => a -> k -> EnumMap k a -> a
findWithDefault :: forall k a. Enum k => a -> k -> EnumMap k a -> a
findWithDefault a
def k
k = forall a. a -> Key -> IntMap a -> a
I.findWithDefault a
def (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE findWithDefault #-}
singleton :: (Enum k) => k -> a -> EnumMap k a
singleton :: forall k a. Enum k => k -> a -> EnumMap k a
singleton k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Key -> a -> IntMap a
I.singleton (forall a. Enum a => a -> Key
fromEnum k
k)
{-# INLINE singleton #-}
insert :: (Enum k) => k -> a -> EnumMap k a -> EnumMap k a
insert :: forall k a. Enum k => k -> a -> EnumMap k a -> EnumMap k a
insert k
k a
a = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Key -> a -> IntMap a -> IntMap a
I.insert (forall a. Enum a => a -> Key
fromEnum k
k) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE insert #-}
insertWith :: (Enum k) => (a -> a -> a) -> k -> a -> EnumMap k a -> EnumMap k a
insertWith :: forall k a.
Enum k =>
(a -> a -> a) -> k -> a -> EnumMap k a -> EnumMap k a
insertWith a -> a -> a
f k
k a
a = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
I.insertWith a -> a -> a
f (forall a. Enum a => a -> Key
fromEnum k
k) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE insertWith #-}
insertWithKey :: (Enum k)
=> (k -> a -> a -> a) -> k -> a -> EnumMap k a -> EnumMap k a
insertWithKey :: forall k a.
Enum k =>
(k -> a -> a -> a) -> k -> a -> EnumMap k a -> EnumMap k a
insertWithKey k -> a -> a -> a
f k
k a
a =
forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
I.insertWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) (forall a. Enum a => a -> Key
fromEnum k
k) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE insertWithKey #-}
insertLookupWithKey :: (Enum k)
=> (k -> a -> a -> a) -> k -> a -> EnumMap k a -> (Maybe a, EnumMap k a)
insertLookupWithKey :: forall k a.
Enum k =>
(k -> a -> a -> a)
-> k -> a -> EnumMap k a -> (Maybe a, EnumMap k a)
insertLookupWithKey k -> a -> a -> a
f k
k a
a =
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
(Key -> a -> a -> a) -> Key -> a -> IntMap a -> (Maybe a, IntMap a)
I.insertLookupWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) (forall a. Enum a => a -> Key
fromEnum k
k) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE insertLookupWithKey #-}
adjust :: (Enum k) => (a -> a) -> k -> EnumMap k a -> EnumMap k a
adjust :: forall k a. Enum k => (a -> a) -> k -> EnumMap k a -> EnumMap k a
adjust a -> a
f k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a) -> Key -> IntMap a -> IntMap a
I.adjust a -> a
f (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE adjust #-}
adjustWithKey :: (Enum k) => (k -> a -> a) -> k -> EnumMap k a -> EnumMap k a
adjustWithKey :: forall k a.
Enum k =>
(k -> a -> a) -> k -> EnumMap k a -> EnumMap k a
adjustWithKey k -> a -> a
f k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> a) -> Key -> IntMap a -> IntMap a
I.adjustWithKey (k -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE adjustWithKey #-}
alter :: (Enum k) => (Maybe a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
alter :: forall k a.
Enum k =>
(Maybe a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
alter Maybe a -> Maybe a
f k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Maybe a -> Maybe a) -> Key -> IntMap a -> IntMap a
I.alter Maybe a -> Maybe a
f (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE alter #-}
alterF :: (Enum k, Functor f) => (Maybe a -> f (Maybe a)) -> k -> EnumMap k a -> f (EnumMap k a)
alterF :: forall k (f :: * -> *) a.
(Enum k, Functor f) =>
(Maybe a -> f (Maybe a)) -> k -> EnumMap k a -> f (EnumMap k a)
alterF Maybe a -> f (Maybe a)
f k
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a.
Functor f =>
(Maybe a -> f (Maybe a)) -> Key -> IntMap a -> f (IntMap a)
I.alterF Maybe a -> f (Maybe a)
f (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE alterF #-}
unionsWith :: (a -> a -> a) -> [EnumMap k a] -> EnumMap k a
unionsWith :: forall a k. (a -> a -> a) -> [EnumMap k a] -> EnumMap k a
unionsWith a -> a -> a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a.
Foldable f =>
(a -> a -> a) -> f (IntMap a) -> IntMap a
I.unionsWith a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE unionsWith #-}
unionWith :: (a -> a -> a) -> EnumMap k a -> EnumMap k a -> EnumMap k a
unionWith :: forall a k.
(a -> a -> a) -> EnumMap k a -> EnumMap k a -> EnumMap k a
unionWith a -> a -> a
f (EnumMap IntMap a
im1) (EnumMap IntMap a
im2) = forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
I.unionWith a -> a -> a
f IntMap a
im1 IntMap a
im2
{-# INLINE unionWith #-}
unionWithKey :: (Enum k)
=> (k -> a -> a -> a) -> EnumMap k a -> EnumMap k a -> EnumMap k a
unionWithKey :: forall k a.
Enum k =>
(k -> a -> a -> a) -> EnumMap k a -> EnumMap k a -> EnumMap k a
unionWithKey k -> a -> a -> a
f (EnumMap IntMap a
im1) (EnumMap IntMap a
im2) =
forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a. (Key -> a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
I.unionWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) IntMap a
im1 IntMap a
im2
{-# INLINE unionWithKey #-}
differenceWith :: (a -> b -> Maybe a) -> EnumMap k a -> EnumMap k b -> EnumMap k a
differenceWith :: forall a b k.
(a -> b -> Maybe a) -> EnumMap k a -> EnumMap k b -> EnumMap k a
differenceWith a -> b -> Maybe a
f (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) =
forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a
I.differenceWith a -> b -> Maybe a
f IntMap a
im1 IntMap b
im2
{-# INLINE differenceWith #-}
differenceWithKey :: (Enum k)
=> (k -> a -> b -> Maybe a) -> EnumMap k a -> EnumMap k b -> EnumMap k a
differenceWithKey :: forall k a b.
Enum k =>
(k -> a -> b -> Maybe a)
-> EnumMap k a -> EnumMap k b -> EnumMap k a
differenceWithKey k -> a -> b -> Maybe a
f (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) =
forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a b.
(Key -> a -> b -> Maybe a) -> IntMap a -> IntMap b -> IntMap a
I.differenceWithKey (k -> a -> b -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) IntMap a
im1 IntMap b
im2
{-# INLINE differenceWithKey #-}
intersectionWith :: (a -> b -> c) -> EnumMap k a -> EnumMap k b -> EnumMap k c
intersectionWith :: forall a b c k.
(a -> b -> c) -> EnumMap k a -> EnumMap k b -> EnumMap k c
intersectionWith a -> b -> c
f (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) =
forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
I.intersectionWith a -> b -> c
f IntMap a
im1 IntMap b
im2
{-# INLINE intersectionWith #-}
intersectionWithKey :: (Enum k)
=> (k -> a -> b -> c) -> EnumMap k a -> EnumMap k b -> EnumMap k c
intersectionWithKey :: forall k a b c.
Enum k =>
(k -> a -> b -> c) -> EnumMap k a -> EnumMap k b -> EnumMap k c
intersectionWithKey k -> a -> b -> c
f (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) =
forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a b c.
(Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
I.intersectionWithKey (k -> a -> b -> c
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) IntMap a
im1 IntMap b
im2
{-# INLINE intersectionWithKey #-}
mergeWithKey :: (Enum k)
=> (k -> a -> b -> Maybe c)
-> (EnumMap k a -> EnumMap k c)
-> (EnumMap k b -> EnumMap k c)
-> EnumMap k a
-> EnumMap k b
-> EnumMap k c
mergeWithKey :: forall k a b c.
Enum k =>
(k -> a -> b -> Maybe c)
-> (EnumMap k a -> EnumMap k c)
-> (EnumMap k b -> EnumMap k c)
-> EnumMap k a
-> EnumMap k b
-> EnumMap k c
mergeWithKey k -> a -> b -> Maybe c
f EnumMap k a -> EnumMap k c
ga EnumMap k b -> EnumMap k c
gb = \EnumMap k a
ma EnumMap k b
mb -> forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$
forall a b c.
(Key -> a -> b -> Maybe c)
-> (IntMap a -> IntMap c)
-> (IntMap b -> IntMap c)
-> IntMap a
-> IntMap b
-> IntMap c
I.mergeWithKey (k -> a -> b -> Maybe c
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum)
(forall k a. EnumMap k a -> IntMap a
unWrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. EnumMap k a -> EnumMap k c
ga forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. IntMap a -> EnumMap k a
EnumMap)
(forall k a. EnumMap k a -> IntMap a
unWrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. EnumMap k b -> EnumMap k c
gb forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. IntMap a -> EnumMap k a
EnumMap)
(forall k a. EnumMap k a -> IntMap a
unWrap EnumMap k a
ma)
(forall k a. EnumMap k a -> IntMap a
unWrap EnumMap k b
mb)
{-# INLINE mergeWithKey #-}
update :: (Enum k) => (a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
update :: forall k a.
Enum k =>
(a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
update a -> Maybe a
f k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Maybe a) -> Key -> IntMap a -> IntMap a
I.update a -> Maybe a
f (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE update #-}
updateWithKey :: (Enum k)
=> (k -> a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
updateWithKey :: forall k a.
Enum k =>
(k -> a -> Maybe a) -> k -> EnumMap k a -> EnumMap k a
updateWithKey k -> a -> Maybe a
f k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> Maybe a) -> Key -> IntMap a -> IntMap a
I.updateWithKey (k -> a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateWithKey #-}
updateLookupWithKey :: (Enum k)
=> (k -> a -> Maybe a) -> k -> EnumMap k a -> (Maybe a,EnumMap k a)
updateLookupWithKey :: forall k a.
Enum k =>
(k -> a -> Maybe a) -> k -> EnumMap k a -> (Maybe a, EnumMap k a)
updateLookupWithKey k -> a -> Maybe a
f k
k =
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a.
(Key -> a -> Maybe a) -> Key -> IntMap a -> (Maybe a, IntMap a)
I.updateLookupWithKey (k -> a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) (forall a. Enum a => a -> Key
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateLookupWithKey #-}
updateMinWithKey :: (Enum k) => (k -> a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMinWithKey :: forall k a.
Enum k =>
(k -> a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMinWithKey k -> a -> Maybe a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> Maybe a) -> IntMap a -> IntMap a
I.updateMinWithKey (k -> a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateMinWithKey #-}
updateMaxWithKey :: (Enum k) => (k -> a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMaxWithKey :: forall k a.
Enum k =>
(k -> a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMaxWithKey k -> a -> Maybe a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> Maybe a) -> IntMap a -> IntMap a
I.updateMaxWithKey (k -> a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateMaxWithKey #-}
updateMax :: (a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMax :: forall a k. (a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMax a -> Maybe a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Maybe a) -> IntMap a -> IntMap a
I.updateMax a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateMax #-}
updateMin :: (a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMin :: forall a k. (a -> Maybe a) -> EnumMap k a -> EnumMap k a
updateMin a -> Maybe a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Maybe a) -> IntMap a -> IntMap a
I.updateMin a -> Maybe a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateMin #-}
map :: (a -> b) -> EnumMap k a -> EnumMap k b
map :: forall a b k. (a -> b) -> EnumMap k a -> EnumMap k b
map a -> b
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> IntMap a -> IntMap b
I.map a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE map #-}
mapWithKey :: (Enum k) => (k -> a -> b) -> EnumMap k a -> EnumMap k b
mapWithKey :: forall k a b. Enum k => (k -> a -> b) -> EnumMap k a -> EnumMap k b
mapWithKey k -> a -> b
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Key -> a -> b) -> IntMap a -> IntMap b
I.mapWithKey (k -> a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapWithKey #-}
mapAccum :: (a -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccum :: forall a b c k.
(a -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccum a -> b -> (a, c)
f a
a = forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
I.mapAccum a -> b -> (a, c)
f a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapAccum #-}
mapAccumWithKey :: (Enum k)
=> (a -> k -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccumWithKey :: forall k a b c.
Enum k =>
(a -> k -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccumWithKey a -> k -> b -> (a, c)
f a
a =
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c.
(a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
I.mapAccumWithKey (\a
b -> a -> k -> b -> (a, c)
f a
b forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapAccumWithKey #-}
mapAccumRWithKey :: (Enum k)
=> (a -> k -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccumRWithKey :: forall k a b c.
Enum k =>
(a -> k -> b -> (a, c)) -> a -> EnumMap k b -> (a, EnumMap k c)
mapAccumRWithKey a -> k -> b -> (a, c)
f a
a =
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c.
(a -> Key -> b -> (a, c)) -> a -> IntMap b -> (a, IntMap c)
I.mapAccumRWithKey (\a
b -> a -> k -> b -> (a, c)
f a
b forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapAccumRWithKey #-}
mapKeysWith :: (Enum k) => (a -> a -> a) -> (k -> k) -> EnumMap k a -> EnumMap k a
mapKeysWith :: forall k a.
Enum k =>
(a -> a -> a) -> (k -> k) -> EnumMap k a -> EnumMap k a
mapKeysWith a -> a -> a
f k -> k
g = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> a) -> (Key -> Key) -> IntMap a -> IntMap a
I.mapKeysWith a -> a -> a
f (forall a. Enum a => a -> Key
fromEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> k
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapKeysWith #-}
mapMaybe :: (a -> Maybe b) -> EnumMap k a -> EnumMap k b
mapMaybe :: forall a b k. (a -> Maybe b) -> EnumMap k a -> EnumMap k b
mapMaybe a -> Maybe b
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> Maybe b) -> IntMap a -> IntMap b
I.mapMaybe a -> Maybe b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapMaybe #-}
mapMaybeWithKey :: (Enum k) => (k -> a -> Maybe b) -> EnumMap k a -> EnumMap k b
mapMaybeWithKey :: forall k a b.
Enum k =>
(k -> a -> Maybe b) -> EnumMap k a -> EnumMap k b
mapMaybeWithKey k -> a -> Maybe b
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Key -> a -> Maybe b) -> IntMap a -> IntMap b
I.mapMaybeWithKey (k -> a -> Maybe b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapMaybeWithKey #-}
mapEither :: (a -> Either b c) -> EnumMap k a -> (EnumMap k b, EnumMap k c)
mapEither :: forall a b c k.
(a -> Either b c) -> EnumMap k a -> (EnumMap k b, EnumMap k c)
mapEither a -> Either b c
f = (forall k a. IntMap a -> EnumMap k a
EnumMap forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** forall k a. IntMap a -> EnumMap k a
EnumMap) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)
I.mapEither a -> Either b c
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapEither #-}
mapEitherWithKey :: (Enum k)
=> (k -> a -> Either b c) -> EnumMap k a -> (EnumMap k b, EnumMap k c)
mapEitherWithKey :: forall k a b c.
Enum k =>
(k -> a -> Either b c) -> EnumMap k a -> (EnumMap k b, EnumMap k c)
mapEitherWithKey k -> a -> Either b c
f =
(forall k a. IntMap a -> EnumMap k a
EnumMap forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** forall k a. IntMap a -> EnumMap k a
EnumMap) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c.
(Key -> a -> Either b c) -> IntMap a -> (IntMap b, IntMap c)
I.mapEitherWithKey (k -> a -> Either b c
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapEitherWithKey #-}
fromSet :: (Enum k) => (k -> a) -> EnumSet k -> EnumMap k a
fromSet :: forall k a. Enum k => (k -> a) -> EnumSet k -> EnumMap k a
fromSet k -> a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a) -> IntSet -> IntMap a
I.fromSet (k -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k. EnumSet k -> IntSet
EnumSet.enumSetToIntSet
{-# INLINE fromSet #-}
fromList :: (Enum k) => [(k, a)] -> EnumMap k a
fromList :: forall k a. Enum k => [(k, a)] -> EnumMap k a
fromList = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [(Key, a)] -> IntMap a
I.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromList #-}
fromListWith :: (Enum k) => (a -> a -> a) -> [(k, a)] -> EnumMap k a
fromListWith :: forall k a. Enum k => (a -> a -> a) -> [(k, a)] -> EnumMap k a
fromListWith a -> a -> a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> a) -> [(Key, a)] -> IntMap a
I.fromListWith a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromListWith #-}
fromListWithKey :: (Enum k) => (k -> a -> a -> a) -> [(k, a)] -> EnumMap k a
fromListWithKey :: forall k a. Enum k => (k -> a -> a -> a) -> [(k, a)] -> EnumMap k a
fromListWithKey k -> a -> a -> a
f =
forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> a -> a) -> [(Key, a)] -> IntMap a
I.fromListWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromListWithKey #-}
fromAscList :: (Enum k) => [(k, a)] -> EnumMap k a
fromAscList :: forall k a. Enum k => [(k, a)] -> EnumMap k a
fromAscList = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [(Key, a)] -> IntMap a
I.fromAscList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromAscList #-}
fromAscListWith :: (Enum k) => (a -> a -> a) -> [(k, a)] -> EnumMap k a
fromAscListWith :: forall k a. Enum k => (a -> a -> a) -> [(k, a)] -> EnumMap k a
fromAscListWith a -> a -> a
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> a) -> [(Key, a)] -> IntMap a
I.fromAscListWith a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromAscListWith #-}
fromAscListWithKey :: (Enum k) => (k -> a -> a -> a) -> [(k, a)] -> EnumMap k a
fromAscListWithKey :: forall k a. Enum k => (k -> a -> a -> a) -> [(k, a)] -> EnumMap k a
fromAscListWithKey k -> a -> a -> a
f =
forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Key -> a -> a -> a) -> [(Key, a)] -> IntMap a
I.fromAscListWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Key -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromAscListWithKey #-}
fromDistinctAscList :: (Enum k) => [(k, a)] -> EnumMap k a
fromDistinctAscList :: forall k a. Enum k => [(k, a)] -> EnumMap k a
fromDistinctAscList = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [(Key, a)] -> IntMap a
I.fromDistinctAscList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
P.map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => a -> Key
fromEnum)
{-# INLINE fromDistinctAscList #-}