{-# LANGUAGE CPP                        #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveTraversable          #-}

-- |
-- Module      :  $Header$
-- Description :  Data.IntMap with Enum keys.
-- Copyright   :  (c) 2011-2019 Michal Terepeta
--                (c) 2019-2022 Mikolaj Konarski and others (see git history)
-- License     :  BSD3
-- Maintainer  :  mikolaj.konarski@funktory.com
-- Stability   :  alpha
-- Portability :  uses DeriveDataTypeable and GeneralizedNewtypeDeriving

module Data.EnumMap.Base
  ( EnumMap(..)

  -- * Wrapping/unwrapping
  , intMapToEnumMap
  , enumMapToIntMap

  -- * Operators
  , (!)
  , (\\)

  -- * Query
  , null
  , size
  , member
  , notMember
  , lookup
  , findWithDefault
  , lookupLT
  , lookupGT
  , lookupLE
  , lookupGE

  -- * Construction
  , empty
  , singleton

  -- ** Insertion
  , insert
  , insertWith
  , insertWithKey
  , insertLookupWithKey

  -- ** Delete\/Update
  , delete
  , adjust
  , adjustWithKey
  , update
  , updateWithKey
  , updateLookupWithKey
  , alter
  , alterF

  -- * Combine

  -- ** Union
  , union
  , unionWith
  , unionWithKey
  , unions
  , unionsWith

  -- ** Difference
  , difference
  , differenceWith
  , differenceWithKey

  -- ** Intersection
  , intersection
  , intersectionWith
  , intersectionWithKey

  -- ** Universal combining function
  , mergeWithKey

  -- * Traversal
  -- ** Map
  , map
  , mapWithKey
  , traverseWithKey
  , mapAccum
  , mapAccumWithKey
  , mapAccumRWithKey
  , mapKeys
  , mapKeysWith
  , mapKeysMonotonic

  -- * Folds
  , foldr
  , foldl
  , foldrWithKey
  , foldlWithKey
  -- ** Strict folds
  , foldr'
  , foldl'
  , foldrWithKey'
  , foldlWithKey'

  -- * Conversion
  , elems
  , keys
  , assocs
  , keysSet
  , fromSet

  -- ** Lists
  , toList
  , fromList
  , fromListWith
  , fromListWithKey

  -- ** Ordered lists
  , toAscList
  , toDescList
  , fromAscList
  , fromAscListWith
  , fromAscListWithKey
  , fromDistinctAscList

  -- * Filter
  , filter
  , filterWithKey
#if (MIN_VERSION_containers(0,5,8))
  , restrictKeys
  , withoutKeys
#endif
  , partition
  , partitionWithKey

  , mapMaybe
  , mapMaybeWithKey
  , mapEither
  , mapEitherWithKey

  , split
  , splitLookup

  -- * Submap
  , isSubmapOf
  , isSubmapOfBy
  , isProperSubmapOf
  , isProperSubmapOfBy

  -- * Min\/Max
  , lookupMin
  , lookupMax
  , findMin
  , findMax
  , deleteMin
  , deleteMax
  , deleteFindMin
  , deleteFindMax
  , updateMin
  , updateMax
  , updateMinWithKey
  , updateMaxWithKey
  , minView
  , maxView
  , minViewWithKey
  , maxViewWithKey
  ) where

import Prelude hiding ( filter, foldr, foldl, lookup, map, null )
import qualified Prelude as P

import Control.Applicative ( Applicative, liftA )

import Data.IntMap.Lazy ( IntMap )
import qualified Data.IntMap.Lazy as I

import Data.EnumSet ( EnumSet )
import qualified Data.EnumSet as EnumSet

import Control.Arrow ( first, second, (***) )
import Control.DeepSeq ( NFData )
import Data.Foldable ( Foldable )
import Data.Monoid ( Monoid )
import Data.Semigroup ( Semigroup )
import Data.Traversable ( Traversable )
import Data.Typeable ( Typeable )
import Data.Aeson ( FromJSON(..), ToJSON(..) )
import Text.Read

-- | Wrapper for 'IntMap' with 'Enum' keys.
newtype EnumMap k a = EnumMap { forall k a. EnumMap k a -> IntMap a
unWrap :: IntMap a }
  deriving (EnumMap k a -> EnumMap k a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k a. Eq a => EnumMap k a -> EnumMap k a -> Bool
/= :: EnumMap k a -> EnumMap k a -> Bool
$c/= :: forall k a. Eq a => EnumMap k a -> EnumMap k a -> Bool
== :: EnumMap k a -> EnumMap k a -> Bool
$c== :: forall k a. Eq a => EnumMap k a -> EnumMap k a -> Bool
Eq, forall a. Eq a => a -> EnumMap k a -> Bool
forall a. Num a => EnumMap k a -> a
forall a. Ord a => EnumMap k a -> a
forall m. Monoid m => EnumMap k m -> m
forall a. EnumMap k a -> Bool
forall a. EnumMap k a -> Int
forall a. EnumMap k a -> [a]
forall a. (a -> a -> a) -> EnumMap k a -> a
forall k a. Eq a => a -> EnumMap k a -> Bool
forall k a. Num a => EnumMap k a -> a
forall k a. Ord a => EnumMap k a -> a
forall m a. Monoid m => (a -> m) -> EnumMap k a -> m
forall k m. Monoid m => EnumMap k m -> m
forall k a. EnumMap k a -> Bool
forall k a. EnumMap k a -> Int
forall k a. EnumMap k a -> [a]
forall b a. (b -> a -> b) -> b -> EnumMap k a -> b
forall a b. (a -> b -> b) -> b -> EnumMap k a -> b
forall k a. (a -> a -> a) -> EnumMap k a -> a
forall k m a. Monoid m => (a -> m) -> EnumMap k a -> m
forall k b a. (b -> a -> b) -> b -> EnumMap k a -> b
forall k a b. (a -> b -> b) -> b -> EnumMap k a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => EnumMap k a -> a
$cproduct :: forall k a. Num a => EnumMap k a -> a
sum :: forall a. Num a => EnumMap k a -> a
$csum :: forall k a. Num a => EnumMap k a -> a
minimum :: forall a. Ord a => EnumMap k a -> a
$cminimum :: forall k a. Ord a => EnumMap k a -> a
maximum :: forall a. Ord a => EnumMap k a -> a
$cmaximum :: forall k a. Ord a => EnumMap k a -> a
elem :: forall a. Eq a => a -> EnumMap k a -> Bool
$celem :: forall k a. Eq a => a -> EnumMap k a -> Bool
length :: forall a. EnumMap k a -> Int
$clength :: forall k a. EnumMap k a -> Int
null :: forall a. EnumMap k a -> Bool
$cnull :: forall k a. EnumMap k a -> Bool
toList :: forall a. EnumMap k a -> [a]
$ctoList :: forall k a. EnumMap k a -> [a]
foldl1 :: forall a. (a -> a -> a) -> EnumMap k a -> a
$cfoldl1 :: forall k a. (a -> a -> a) -> EnumMap k a -> a
foldr1 :: forall a. (a -> a -> a) -> EnumMap k a -> a
$cfoldr1 :: forall k a. (a -> a -> a) -> EnumMap k a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> EnumMap k a -> b
$cfoldl' :: forall k b a. (b -> a -> b) -> b -> EnumMap k a -> b
foldl :: forall b a. (b -> a -> b) -> b -> EnumMap k a -> b
$cfoldl :: forall k b a. (b -> a -> b) -> b -> EnumMap k a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> EnumMap k a -> b
$cfoldr' :: forall k a b. (a -> b -> b) -> b -> EnumMap k a -> b
foldr :: forall a b. (a -> b -> b) -> b -> EnumMap k a -> b
$cfoldr :: forall k a b. (a -> b -> b) -> b -> EnumMap k a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> EnumMap k a -> m
$cfoldMap' :: forall k m a. Monoid m => (a -> m) -> EnumMap k a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> EnumMap k a -> m
$cfoldMap :: forall k m a. Monoid m => (a -> m) -> EnumMap k a -> m
fold :: forall m. Monoid m => EnumMap k m -> m
$cfold :: forall k m. Monoid m => EnumMap k m -> m
Foldable, forall a b. a -> EnumMap k b -> EnumMap k a
forall a b. (a -> b) -> EnumMap k a -> EnumMap k b
forall k a b. a -> EnumMap k b -> EnumMap k a
forall k a b. (a -> b) -> EnumMap k a -> EnumMap k b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> EnumMap k b -> EnumMap k a
$c<$ :: forall k a b. a -> EnumMap k b -> EnumMap k a
fmap :: forall a b. (a -> b) -> EnumMap k a -> EnumMap k b
$cfmap :: forall k a b. (a -> b) -> EnumMap k a -> EnumMap k b
Functor, EnumMap k a -> EnumMap k a -> Bool
EnumMap k a -> EnumMap k a -> Ordering
EnumMap k a -> EnumMap k a -> EnumMap k a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {k} {a}. Ord a => Eq (EnumMap k a)
forall k a. Ord a => EnumMap k a -> EnumMap k a -> Bool
forall k a. Ord a => EnumMap k a -> EnumMap k a -> Ordering
forall k a. Ord a => EnumMap k a -> EnumMap k a -> EnumMap k a
min :: EnumMap k a -> EnumMap k a -> EnumMap k a
$cmin :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> EnumMap k a
max :: EnumMap k a -> EnumMap k a -> EnumMap k a
$cmax :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> EnumMap k a
>= :: EnumMap k a -> EnumMap k a -> Bool
$c>= :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> Bool
> :: EnumMap k a -> EnumMap k a -> Bool
$c> :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> Bool
<= :: EnumMap k a -> EnumMap k a -> Bool
$c<= :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> Bool
< :: EnumMap k a -> EnumMap k a -> Bool
$c< :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> Bool
compare :: EnumMap k a -> EnumMap k a -> Ordering
$ccompare :: forall k a. Ord a => EnumMap k a -> EnumMap k a -> Ordering
Ord, NonEmpty (EnumMap k a) -> EnumMap k a
EnumMap k a -> EnumMap k a -> EnumMap k a
forall b. Integral b => b -> EnumMap k a -> EnumMap k a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall k a. NonEmpty (EnumMap k a) -> EnumMap k a
forall k a. EnumMap k a -> EnumMap k a -> EnumMap k a
forall k a b. Integral b => b -> EnumMap k a -> EnumMap k a
stimes :: forall b. Integral b => b -> EnumMap k a -> EnumMap k a
$cstimes :: forall k a b. Integral b => b -> EnumMap k a -> EnumMap k a
sconcat :: NonEmpty (EnumMap k a) -> EnumMap k a
$csconcat :: forall k a. NonEmpty (EnumMap k a) -> EnumMap k a
<> :: EnumMap k a -> EnumMap k a -> EnumMap k a
$c<> :: forall k a. EnumMap k a -> EnumMap k a -> EnumMap k a
Semigroup, EnumMap k a
[EnumMap k a] -> EnumMap k a
EnumMap k a -> EnumMap k a -> EnumMap k a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall k a. Semigroup (EnumMap k a)
forall k a. EnumMap k a
forall k a. [EnumMap k a] -> EnumMap k a
forall k a. EnumMap k a -> EnumMap k a -> EnumMap k a
mconcat :: [EnumMap k a] -> EnumMap k a
$cmconcat :: forall k a. [EnumMap k a] -> EnumMap k a
mappend :: EnumMap k a -> EnumMap k a -> EnumMap k a
$cmappend :: forall k a. EnumMap k a -> EnumMap k a -> EnumMap k a
mempty :: EnumMap k a
$cmempty :: forall k a. EnumMap k a
Monoid,
            forall k. Functor (EnumMap k)
forall k. Foldable (EnumMap k)
forall k (m :: * -> *) a.
Monad m =>
EnumMap k (m a) -> m (EnumMap k a)
forall k (f :: * -> *) a.
Applicative f =>
EnumMap k (f a) -> f (EnumMap k a)
forall k (m :: * -> *) a b.
Monad m =>
(a -> m b) -> EnumMap k a -> m (EnumMap k b)
forall k (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EnumMap k a -> f (EnumMap k b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EnumMap k a -> f (EnumMap k b)
sequence :: forall (m :: * -> *) a.
Monad m =>
EnumMap k (m a) -> m (EnumMap k a)
$csequence :: forall k (m :: * -> *) a.
Monad m =>
EnumMap k (m a) -> m (EnumMap k a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> EnumMap k a -> m (EnumMap k b)
$cmapM :: forall k (m :: * -> *) a b.
Monad m =>
(a -> m b) -> EnumMap k a -> m (EnumMap k b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
EnumMap k (f a) -> f (EnumMap k a)
$csequenceA :: forall k (f :: * -> *) a.
Applicative f =>
EnumMap k (f a) -> f (EnumMap k a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EnumMap k a -> f (EnumMap k b)
$ctraverse :: forall k (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> EnumMap k a -> f (EnumMap k b)
Traversable, Typeable, EnumMap k a -> ()
forall a. (a -> ()) -> NFData a
forall k a. NFData a => EnumMap k a -> ()
rnf :: EnumMap k a -> ()
$crnf :: forall k a. NFData a => EnumMap k a -> ()
NFData)

instance (Enum k, Show k, Show a) => Show (EnumMap k a) where
  showsPrec :: Int -> EnumMap k a -> ShowS
showsPrec Int
p EnumMap k a
em = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString String
"fromList " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> ShowS
shows (forall k a. Enum k => EnumMap k a -> [(k, a)]
toList EnumMap k a
em)

instance (Enum k, Read k, Read a) => Read (EnumMap k a) where
  readPrec :: ReadPrec (EnumMap k a)
readPrec = forall a. ReadPrec a -> ReadPrec a
parens forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
10 forall a b. (a -> b) -> a -> b
$ do
    Ident String
"fromList" <- ReadPrec Lexeme
lexP
    forall k a. Enum k => [(k, a)] -> EnumMap k a
fromList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Read a => ReadPrec a
readPrec

instance (ToJSON a) => ToJSON (EnumMap k a) where
    toJSON :: EnumMap k a -> Value
toJSON = forall a. ToJSON a => a -> Value
toJSON forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
    toEncoding :: EnumMap k a -> Encoding
toEncoding = forall a. ToJSON a => a -> Encoding
toEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap

instance (FromJSON a) => FromJSON (EnumMap k a) where
    parseJSON :: Value -> Parser (EnumMap k a)
parseJSON = 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 a. [(Int, a)] -> IntMap a
I.fromList) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. FromJSON a => Value -> Parser a
parseJSON

--
-- Conversion to/from 'IntMap'.
--

-- | Wrap 'IntMap'.
intMapToEnumMap :: IntMap a -> EnumMap k a
intMapToEnumMap :: forall a k. IntMap a -> EnumMap k a
intMapToEnumMap = forall k a. IntMap a -> EnumMap k a
EnumMap
{-# INLINE intMapToEnumMap #-}

-- | Unwrap 'IntMap'.
enumMapToIntMap :: EnumMap k a -> IntMap a
enumMapToIntMap :: forall k a. EnumMap k a -> IntMap a
enumMapToIntMap = forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE enumMapToIntMap #-}

--
-- Here begins the main part.
--

(!) :: (Enum k) => EnumMap k a -> k -> a
(EnumMap IntMap a
im) ! :: forall k a. Enum k => EnumMap k a -> k -> a
! k
k = IntMap a
im forall a. IntMap a -> Int -> a
I.! (forall a. Enum a => a -> Int
fromEnum k
k)
{-# INLINE (!) #-}

(\\) :: EnumMap k a -> EnumMap k b -> EnumMap k a
(EnumMap IntMap a
im1) \\ :: forall k a b. EnumMap k a -> EnumMap k b -> EnumMap k a
\\ (EnumMap IntMap b
im2) = forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ IntMap a
im1 forall a b. IntMap a -> IntMap b -> IntMap a
I.\\ IntMap b
im2
{-# INLINE (\\) #-}

null :: EnumMap k a -> Bool
null :: forall k a. EnumMap k a -> Bool
null = forall a. IntMap a -> Bool
I.null forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE null #-}

size :: EnumMap k a -> Int
size :: forall k a. EnumMap k a -> Int
size = forall a. IntMap a -> Int
I.size forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE size #-}

member :: (Enum k) => k -> EnumMap k a -> Bool
member :: forall k a. Enum k => k -> EnumMap k a -> Bool
member k
k = forall a. Int -> IntMap a -> Bool
I.member (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE member #-}

notMember :: (Enum k) => k -> EnumMap k a -> Bool
notMember :: forall k a. Enum k => k -> EnumMap k a -> Bool
notMember k
k = forall a. Int -> IntMap a -> Bool
I.notMember (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE notMember #-}

lookup :: (Enum k) => k -> EnumMap k a -> Maybe a
lookup :: forall k a. Enum k => k -> EnumMap k a -> Maybe a
lookup k
k = forall a. Int -> IntMap a -> Maybe a
I.lookup (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookup #-}

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 -> Int -> IntMap a -> a
I.findWithDefault a
def (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE findWithDefault #-}

lookupLT :: (Enum k) => k -> EnumMap k a -> Maybe (k, a)
lookupLT :: forall k a. Enum k => k -> EnumMap k a -> Maybe (k, a)
lookupLT k
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> Maybe (Int, a)
I.lookupLT (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupLT #-}

lookupGT :: (Enum k) => k -> EnumMap k a -> Maybe (k, a)
lookupGT :: forall k a. Enum k => k -> EnumMap k a -> Maybe (k, a)
lookupGT k
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> Maybe (Int, a)
I.lookupGT (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupGT #-}

lookupLE :: (Enum k) => k -> EnumMap k a -> Maybe (k, a)
lookupLE :: forall k a. Enum k => k -> EnumMap k a -> Maybe (k, a)
lookupLE k
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> Maybe (Int, a)
I.lookupLE (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupLE #-}

lookupGE :: (Enum k) => k -> EnumMap k a -> Maybe (k, a)
lookupGE :: forall k a. Enum k => k -> EnumMap k a -> Maybe (k, a)
lookupGE k
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> Maybe (Int, a)
I.lookupGE (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupGE #-}

empty :: EnumMap k a
empty :: forall k a. EnumMap k a
empty = forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a. IntMap a
I.empty
{-# INLINE empty #-}

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. Int -> a -> IntMap a
I.singleton (forall a. Enum a => a -> Int
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. Int -> a -> IntMap a -> IntMap a
I.insert (forall a. Enum a => a -> Int
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) -> Int -> a -> IntMap a -> IntMap a
I.insertWith a -> a -> a
f (forall a. Enum a => a -> Int
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. (Int -> a -> a -> a) -> Int -> 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 => Int -> a
toEnum) (forall a. Enum a => a -> Int
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.
(Int -> a -> a -> a) -> Int -> 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 => Int -> a
toEnum) (forall a. Enum a => a -> Int
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 #-}

delete :: (Enum k) => k -> EnumMap k a -> EnumMap k a
delete :: forall k a. Enum k => k -> EnumMap k a -> EnumMap k a
delete k
k = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> IntMap a
I.delete (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE delete #-}

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) -> Int -> IntMap a -> IntMap a
I.adjust a -> a
f (forall a. Enum a => a -> Int
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. (Int -> a -> a) -> Int -> IntMap a -> IntMap a
I.adjustWithKey (k -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE adjustWithKey #-}

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) -> Int -> IntMap a -> IntMap a
I.update a -> Maybe a
f (forall a. Enum a => a -> Int
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. (Int -> a -> Maybe a) -> Int -> 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 => Int -> a
toEnum) (forall a. Enum a => a -> Int
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.
(Int -> a -> Maybe a) -> Int -> 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 => Int -> a
toEnum) (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateLookupWithKey #-}

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) -> Int -> IntMap a -> IntMap a
I.alter Maybe a -> Maybe a
f (forall a. Enum a => a -> Int
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)) -> Int -> IntMap a -> f (IntMap a)
I.alterF Maybe a -> f (Maybe a)
f (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE alterF #-}

unions :: [EnumMap k a] -> EnumMap k a
unions :: forall k a. [EnumMap k a] -> EnumMap k a
unions = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Foldable f => f (IntMap a) -> IntMap a
I.unions 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 unions #-}

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 #-}

union :: EnumMap k a -> EnumMap k a -> EnumMap k a
union :: forall k a. EnumMap k a -> EnumMap k a -> EnumMap k a
union (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. IntMap a -> IntMap a -> IntMap a
I.union IntMap a
im1 IntMap a
im2
{-# INLINE union #-}

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. (Int -> 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 => Int -> a
toEnum) IntMap a
im1 IntMap a
im2
{-# INLINE unionWithKey #-}

difference :: EnumMap k a -> EnumMap k b -> EnumMap k a
difference :: forall k a b. EnumMap k a -> EnumMap k b -> EnumMap k a
difference (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. IntMap a -> IntMap b -> IntMap a
I.difference IntMap a
im1 IntMap b
im2
{-# INLINE difference #-}

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.
(Int -> 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 => Int -> a
toEnum) IntMap a
im1 IntMap b
im2
{-# INLINE differenceWithKey #-}

intersection :: EnumMap k a -> EnumMap k b -> EnumMap k a
intersection :: forall k a b. EnumMap k a -> EnumMap k b -> EnumMap k a
intersection (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. IntMap a -> IntMap b -> IntMap a
I.intersection IntMap a
im1 IntMap b
im2
{-# INLINE intersection #-}

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.
(Int -> 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 => Int -> 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.
(Int -> 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 => Int -> 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 #-}

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. (Int -> 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 => Int -> 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. (Int -> 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE updateMaxWithKey #-}

maxViewWithKey :: (Enum k) => EnumMap k a -> Maybe ((k, a), EnumMap k a)
maxViewWithKey :: forall k a. Enum k => EnumMap k a -> Maybe ((k, a), EnumMap k a)
maxViewWithKey = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {a} {k}.
Enum a =>
((Int, b), IntMap a) -> ((a, b), EnumMap k a)
wrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> Maybe ((Int, a), IntMap a)
I.maxViewWithKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
  where
    wrap :: ((Int, b), IntMap a) -> ((a, b), EnumMap k a)
wrap ((Int
i, b
a), IntMap a
im) = ((forall a. Enum a => Int -> a
toEnum Int
i, b
a), forall k a. IntMap a -> EnumMap k a
EnumMap IntMap a
im)
{-# INLINE maxViewWithKey #-}

minViewWithKey :: (Enum k) => EnumMap k a -> Maybe ((k, a), EnumMap k a)
minViewWithKey :: forall k a. Enum k => EnumMap k a -> Maybe ((k, a), EnumMap k a)
minViewWithKey =  forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall {a} {b} {a} {k}.
Enum a =>
((Int, b), IntMap a) -> ((a, b), EnumMap k a)
wrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> Maybe ((Int, a), IntMap a)
I.minViewWithKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
  where
    wrap :: ((Int, b), IntMap a) -> ((a, b), EnumMap k a)
wrap ((Int
i, b
a), IntMap a
imap) = ((forall a. Enum a => Int -> a
toEnum Int
i, b
a), forall k a. IntMap a -> EnumMap k a
EnumMap IntMap a
imap)
{-# INLINE minViewWithKey #-}

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 #-}

maxView :: EnumMap k a -> Maybe (a, EnumMap k a)
maxView :: forall k a. EnumMap k a -> Maybe (a, EnumMap k a)
maxView = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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. IntMap a -> Maybe (a, IntMap a)
I.maxView forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE maxView #-}

minView :: EnumMap k a -> Maybe (a, EnumMap k a)
minView :: forall k a. EnumMap k a -> Maybe (a, EnumMap k a)
minView = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (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. IntMap a -> Maybe (a, IntMap a)
I.minView forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE minView #-}

deleteFindMax :: (Enum k) => EnumMap k a -> ((k, a), EnumMap k a)
deleteFindMax :: forall k a. Enum k => EnumMap k a -> ((k, a), EnumMap k a)
deleteFindMax = (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum 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. IntMap a -> ((Int, a), IntMap a)
I.deleteFindMax forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE deleteFindMax #-}

deleteFindMin :: (Enum k) => EnumMap k a -> ((k, a), EnumMap k a)
deleteFindMin :: forall k a. Enum k => EnumMap k a -> ((k, a), EnumMap k a)
deleteFindMin = (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum 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. IntMap a -> ((Int, a), IntMap a)
I.deleteFindMin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE deleteFindMin #-}

lookupMin :: (Enum k) => EnumMap k a -> Maybe (k, a)
lookupMin :: forall k a. Enum k => EnumMap k a -> Maybe (k, a)
lookupMin = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> Maybe (Int, a)
I.lookupMin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupMin #-}

lookupMax :: (Enum k) => EnumMap k a -> Maybe (k, a)
lookupMax :: forall k a. Enum k => EnumMap k a -> Maybe (k, a)
lookupMax = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> Maybe (Int, a)
I.lookupMax forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE lookupMax #-}

findMin :: (Enum k) => EnumMap k a -> (k, a)
findMin :: forall k a. Enum k => EnumMap k a -> (k, a)
findMin = forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> (Int, a)
I.findMin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE findMin #-}

findMax :: (Enum k) => EnumMap k a -> (k, a)
findMax :: forall k a. Enum k => EnumMap k a -> (k, a)
findMax = forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall a. Enum a => Int -> a
toEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> (Int, a)
I.findMax forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE findMax #-}

deleteMin :: EnumMap k a -> EnumMap k a
deleteMin :: forall k a. EnumMap k a -> EnumMap k a
deleteMin = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> IntMap a
I.deleteMin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE deleteMin #-}

deleteMax :: EnumMap k a -> EnumMap k a
deleteMax :: forall k a. EnumMap k a -> EnumMap k a
deleteMax = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> IntMap a
I.deleteMax forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE deleteMax #-}

isProperSubmapOf :: (Eq a) => EnumMap k a -> EnumMap k a -> Bool
isProperSubmapOf :: forall a k. Eq a => EnumMap k a -> EnumMap k a -> Bool
isProperSubmapOf (EnumMap IntMap a
im1) (EnumMap IntMap a
im2) = forall a. Eq a => IntMap a -> IntMap a -> Bool
I.isProperSubmapOf IntMap a
im1 IntMap a
im2
{-# INLINE isProperSubmapOf #-}

isProperSubmapOfBy :: (a -> b -> Bool) -> EnumMap k a -> EnumMap k b -> Bool
isProperSubmapOfBy :: forall a b k.
(a -> b -> Bool) -> EnumMap k a -> EnumMap k b -> Bool
isProperSubmapOfBy a -> b -> Bool
p (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) = forall a b. (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool
I.isProperSubmapOfBy a -> b -> Bool
p IntMap a
im1 IntMap b
im2
{-# INLINE isProperSubmapOfBy #-}

isSubmapOf :: Eq a => EnumMap k a -> EnumMap k a -> Bool
isSubmapOf :: forall a k. Eq a => EnumMap k a -> EnumMap k a -> Bool
isSubmapOf (EnumMap IntMap a
im1) (EnumMap IntMap a
im2) = forall a. Eq a => IntMap a -> IntMap a -> Bool
I.isSubmapOf IntMap a
im1 IntMap a
im2
{-# INLINE isSubmapOf #-}

isSubmapOfBy :: (a -> b -> Bool) -> EnumMap k a -> EnumMap k b -> Bool
isSubmapOfBy :: forall a b k.
(a -> b -> Bool) -> EnumMap k a -> EnumMap k b -> Bool
isSubmapOfBy a -> b -> Bool
p (EnumMap IntMap a
im1) (EnumMap IntMap b
im2) = forall a b. (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool
I.isSubmapOfBy a -> b -> Bool
p IntMap a
im1 IntMap b
im2
{-# INLINE isSubmapOfBy #-}

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. (Int -> 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapWithKey #-}

traverseWithKey :: (Applicative t, Enum k)
  => (k -> a -> t b) -> EnumMap k a -> t (EnumMap k b)
traverseWithKey :: forall (t :: * -> *) k a b.
(Applicative t, Enum k) =>
(k -> a -> t b) -> EnumMap k a -> t (EnumMap k b)
traverseWithKey k -> a -> t b
f = forall (f :: * -> *) a b. Applicative f => (a -> b) -> f a -> f b
liftA forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b.
Applicative t =>
(Int -> a -> t b) -> IntMap a -> t (IntMap b)
I.traverseWithKey (k -> a -> t b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE traverseWithKey #-}

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 -> Int -> 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 => Int -> 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 -> Int -> 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 => Int -> 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 #-}

mapKeys :: (Enum k) => (k -> k) -> EnumMap k a -> EnumMap k a
mapKeys :: forall k a. Enum k => (k -> k) -> EnumMap k a -> EnumMap k a
mapKeys k -> k
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Int -> Int) -> IntMap a -> IntMap a
I.mapKeys (forall a. Enum a => a -> Int
fromEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> k
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapKeys #-}

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) -> (Int -> Int) -> IntMap a -> IntMap a
I.mapKeysWith a -> a -> a
f (forall a. Enum a => a -> Int
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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapKeysWith #-}

mapKeysMonotonic :: (Enum k) => (k -> k) -> EnumMap k a -> EnumMap k a
mapKeysMonotonic :: forall k a. Enum k => (k -> k) -> EnumMap k a -> EnumMap k a
mapKeysMonotonic k -> k
f = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Int -> Int) -> IntMap a -> IntMap a
I.mapKeysMonotonic (forall a. Enum a => a -> Int
fromEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. k -> k
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapKeysMonotonic #-}

filter :: (a -> Bool) -> EnumMap k a -> EnumMap k a
filter :: forall a k. (a -> Bool) -> EnumMap k a -> EnumMap k a
filter a -> Bool
p = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> IntMap a -> IntMap a
I.filter a -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE filter #-}

filterWithKey :: (Enum k) => (k -> a -> Bool) -> EnumMap k a -> EnumMap k a
filterWithKey :: forall k a.
Enum k =>
(k -> a -> Bool) -> EnumMap k a -> EnumMap k a
filterWithKey k -> a -> Bool
p = forall k a. IntMap a -> EnumMap k a
EnumMap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (Int -> a -> Bool) -> IntMap a -> IntMap a
I.filterWithKey (k -> a -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE filterWithKey #-}

#if (MIN_VERSION_containers(0,5,8))
restrictKeys :: (Enum k) => EnumMap k a -> EnumSet k -> EnumMap k a
restrictKeys :: forall k a. Enum k => EnumMap k a -> EnumSet k -> EnumMap k a
restrictKeys EnumMap k a
m EnumSet k
s =
  forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a. IntMap a -> IntSet -> IntMap a
I.restrictKeys (forall k a. EnumMap k a -> IntMap a
unWrap EnumMap k a
m) (forall k. EnumSet k -> IntSet
EnumSet.enumSetToIntSet EnumSet k
s)
{-# INLINE restrictKeys #-}

withoutKeys :: (Enum k) => EnumMap k a -> EnumSet k -> EnumMap k a
withoutKeys :: forall k a. Enum k => EnumMap k a -> EnumSet k -> EnumMap k a
withoutKeys EnumMap k a
m EnumSet k
s =
  forall k a. IntMap a -> EnumMap k a
EnumMap forall a b. (a -> b) -> a -> b
$ forall a. IntMap a -> IntSet -> IntMap a
I.withoutKeys (forall k a. EnumMap k a -> IntMap a
unWrap EnumMap k a
m) (forall k. EnumSet k -> IntSet
EnumSet.enumSetToIntSet EnumSet k
s)
{-# INLINE withoutKeys #-}
#endif

partition :: (a -> Bool) -> EnumMap k a -> (EnumMap k a, EnumMap k a)
partition :: forall a k.
(a -> Bool) -> EnumMap k a -> (EnumMap k a, EnumMap k a)
partition a -> Bool
p = (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. (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
I.partition a -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE partition #-}

partitionWithKey :: (Enum k)
   => (k -> a -> Bool) -> EnumMap k a -> (EnumMap k a, EnumMap k a)
partitionWithKey :: forall k a.
Enum k =>
(k -> a -> Bool) -> EnumMap k a -> (EnumMap k a, EnumMap k a)
partitionWithKey k -> a -> Bool
p =
  (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. (Int -> a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
I.partitionWithKey (k -> a -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE partitionWithKey #-}

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. (Int -> 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 => Int -> 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.
(Int -> 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE mapEitherWithKey #-}

split :: (Enum k) => k -> EnumMap k a -> (EnumMap k a, EnumMap k a)
split :: forall k a.
Enum k =>
k -> EnumMap k a -> (EnumMap k a, EnumMap k a)
split k
k = (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. Int -> IntMap a -> (IntMap a, IntMap a)
I.split (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE split #-}

splitLookup :: (Enum k) => k -> EnumMap k a -> (EnumMap k a, Maybe a, EnumMap k a)
splitLookup :: forall k a.
Enum k =>
k -> EnumMap k a -> (EnumMap k a, Maybe a, EnumMap k a)
splitLookup k
k = forall {a} {b} {a} {k} {k}.
(IntMap a, b, IntMap a) -> (EnumMap k a, b, EnumMap k a)
wrap forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IntMap a -> (IntMap a, Maybe a, IntMap a)
I.splitLookup (forall a. Enum a => a -> Int
fromEnum k
k) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
  where
    wrap :: (IntMap a, b, IntMap a) -> (EnumMap k a, b, EnumMap k a)
wrap (IntMap a
im1, b
ma, IntMap a
im2) = (forall k a. IntMap a -> EnumMap k a
EnumMap IntMap a
im1, b
ma, forall k a. IntMap a -> EnumMap k a
EnumMap IntMap a
im2)
{-# INLINE splitLookup #-}

foldr :: (a -> b -> b) -> b -> EnumMap k a -> b
foldr :: forall a b k. (a -> b -> b) -> b -> EnumMap k a -> b
foldr a -> b -> b
f b
a = forall a b. (a -> b -> b) -> b -> IntMap a -> b
I.foldr a -> b -> b
f b
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldr #-}

foldl :: (a -> b -> a) -> a -> EnumMap k b -> a
foldl :: forall a b k. (a -> b -> a) -> a -> EnumMap k b -> a
foldl a -> b -> a
f a
a = forall a b. (a -> b -> a) -> a -> IntMap b -> a
I.foldl a -> b -> a
f a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldl #-}

foldrWithKey :: (Enum k) => (k -> a -> b -> b) -> b -> EnumMap k a -> b
foldrWithKey :: forall k a b. Enum k => (k -> a -> b -> b) -> b -> EnumMap k a -> b
foldrWithKey k -> a -> b -> b
f b
a = forall a b. (Int -> a -> b -> b) -> b -> IntMap a -> b
I.foldrWithKey (k -> a -> b -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) b
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldrWithKey #-}

foldlWithKey :: (Enum k) => (a -> k -> b -> a) -> a -> EnumMap k b -> a
foldlWithKey :: forall k a b. Enum k => (a -> k -> b -> a) -> a -> EnumMap k b -> a
foldlWithKey a -> k -> b -> a
f a
a = forall a b. (a -> Int -> b -> a) -> a -> IntMap b -> a
I.foldlWithKey (\a
a' -> a -> k -> b -> a
f a
a' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldlWithKey #-}

foldr' :: (a -> b -> b) -> b -> EnumMap k a -> b
foldr' :: forall a b k. (a -> b -> b) -> b -> EnumMap k a -> b
foldr' a -> b -> b
f b
a = forall a b. (a -> b -> b) -> b -> IntMap a -> b
I.foldr' a -> b -> b
f b
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldr' #-}

foldl' :: (a -> b -> a) -> a -> EnumMap k b -> a
foldl' :: forall a b k. (a -> b -> a) -> a -> EnumMap k b -> a
foldl' a -> b -> a
f a
a = forall a b. (a -> b -> a) -> a -> IntMap b -> a
I.foldl' a -> b -> a
f a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldl' #-}

foldrWithKey' :: (Enum k) => (k -> a -> b -> b) -> b -> EnumMap k a -> b
foldrWithKey' :: forall k a b. Enum k => (k -> a -> b -> b) -> b -> EnumMap k a -> b
foldrWithKey' k -> a -> b -> b
f b
a = forall a b. (Int -> a -> b -> b) -> b -> IntMap a -> b
I.foldrWithKey' (k -> a -> b -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) b
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldrWithKey' #-}

foldlWithKey' :: (Enum k) => (a -> k -> b -> a) -> a -> EnumMap k b -> a
foldlWithKey' :: forall k a b. Enum k => (a -> k -> b -> a) -> a -> EnumMap k b -> a
foldlWithKey' a -> k -> b -> a
f a
a = forall a b. (a -> Int -> b -> a) -> a -> IntMap b -> a
I.foldlWithKey' (\a
a' -> a -> k -> b -> a
f a
a' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE foldlWithKey' #-}

elems :: EnumMap k a -> [a]
elems :: forall k a. EnumMap k a -> [a]
elems = forall a. IntMap a -> [a]
I.elems forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE elems #-}

keys :: (Enum k) => EnumMap k a -> [k]
keys :: forall k a. Enum k => EnumMap k a -> [k]
keys = forall a b. (a -> b) -> [a] -> [b]
P.map forall a. Enum a => Int -> a
toEnum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> [Int]
I.keys forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE keys #-}

keysSet :: (Enum k) => EnumMap k a -> EnumSet k
keysSet :: forall k a. Enum k => EnumMap k a -> EnumSet k
keysSet = forall k. Enum k => [k] -> EnumSet k
EnumSet.fromDistinctAscList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Enum k => EnumMap k a -> [k]
keys
{-# INLINE keysSet #-}

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. (Int -> a) -> IntSet -> IntMap a
I.fromSet (k -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k. EnumSet k -> IntSet
EnumSet.enumSetToIntSet
{-# INLINE fromSet #-}

assocs :: (Enum k) => EnumMap k a -> [(k, a)]
assocs :: forall k a. Enum k => EnumMap k a -> [(k, a)]
assocs = 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> [(Int, a)]
I.assocs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE assocs #-}

toList :: (Enum k) => EnumMap k a -> [(k, a)]
toList :: forall k a. Enum k => EnumMap k a -> [(k, a)]
toList = 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> [(Int, a)]
I.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE toList #-}

toAscList :: (Enum k) => EnumMap k a -> [(k, a)]
toAscList :: forall k a. Enum k => EnumMap k a -> [(k, a)]
toAscList = 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> [(Int, a)]
I.toAscList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE toAscList #-}

toDescList :: (Enum k) => EnumMap k a -> [(k, a)]
toDescList :: forall k a. Enum k => EnumMap k a -> [(k, a)]
toDescList = 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 => Int -> a
toEnum) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IntMap a -> [(Int, a)]
I.toDescList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. EnumMap k a -> IntMap a
unWrap
{-# INLINE toDescList #-}

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. [(Int, 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 -> Int
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) -> [(Int, 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 -> Int
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. (Int -> a -> a -> a) -> [(Int, a)] -> IntMap a
I.fromListWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> 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 -> Int
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. [(Int, 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 -> Int
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) -> [(Int, 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 -> Int
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. (Int -> a -> a -> a) -> [(Int, a)] -> IntMap a
I.fromAscListWithKey (k -> a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => Int -> 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 -> Int
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. [(Int, 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 -> Int
fromEnum)
{-# INLINE fromDistinctAscList #-}