{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wall #-}
module GHC.Types.Unique.DFM (
UniqDFM,
emptyUDFM,
unitUDFM,
addToUDFM,
addToUDFM_C,
addToUDFM_C_Directly,
addToUDFM_Directly,
addListToUDFM,
delFromUDFM,
delListFromUDFM,
adjustUDFM,
adjustUDFM_Directly,
alterUDFM,
mapUDFM,
mapMaybeUDFM,
plusUDFM,
plusUDFM_C,
lookupUDFM, lookupUDFM_Directly,
elemUDFM,
foldUDFM,
eltsUDFM,
filterUDFM, filterUDFM_Directly,
isNullUDFM,
sizeUDFM,
intersectUDFM, udfmIntersectUFM,
disjointUDFM, disjointUdfmUfm,
equalKeysUDFM,
minusUDFM,
listToUDFM, listToUDFM_Directly,
udfmMinusUFM, ufmMinusUDFM,
partitionUDFM,
udfmRestrictKeys,
udfmRestrictKeysSet,
anyUDFM, allUDFM,
pprUniqDFM, pprUDFM,
udfmToList,
udfmToUfm,
nonDetStrictFoldUDFM,
unsafeCastUDFMKey,
alwaysUnsafeUfmToUdfm,
) where
import GHC.Prelude
import GHC.Types.Unique ( Uniquable(..), Unique, getKey )
import GHC.Utils.Outputable
import qualified Data.IntMap.Strict as MS
import qualified Data.IntMap as M
import Data.Data
import Data.Functor.Classes (Eq1 (..))
import Data.List (sortBy)
import Data.Function (on)
import GHC.Types.Unique.FM (UniqFM, nonDetUFMToList, ufmToIntMap, unsafeIntMapToUFM)
import Unsafe.Coerce
import qualified Data.IntSet as I
data TaggedVal val =
TaggedVal
!val
{-# UNPACK #-} !Int
deriving stock (TaggedVal val -> DataType
TaggedVal val -> Constr
forall {val}. Data val => Typeable (TaggedVal val)
forall val. Data val => TaggedVal val -> DataType
forall val. Data val => TaggedVal val -> Constr
forall val.
Data val =>
(forall b. Data b => b -> b) -> TaggedVal val -> TaggedVal val
forall val u.
Data val =>
Int -> (forall d. Data d => d -> u) -> TaggedVal val -> u
forall val u.
Data val =>
(forall d. Data d => d -> u) -> TaggedVal val -> [u]
forall val r r'.
Data val =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
forall val r r'.
Data val =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
forall val (m :: * -> *).
(Data val, Monad m) =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
forall val (m :: * -> *).
(Data val, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
forall val (c :: * -> *).
Data val =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val)
forall val (c :: * -> *).
Data val =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TaggedVal val -> c (TaggedVal val)
forall val (t :: * -> *) (c :: * -> *).
(Data val, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val))
forall val (t :: * -> * -> *) (c :: * -> *).
(Data val, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (TaggedVal val))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TaggedVal val -> c (TaggedVal val)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
$cgmapMo :: forall val (m :: * -> *).
(Data val, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
$cgmapMp :: forall val (m :: * -> *).
(Data val, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
$cgmapM :: forall val (m :: * -> *).
(Data val, Monad m) =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TaggedVal val -> u
$cgmapQi :: forall val u.
Data val =>
Int -> (forall d. Data d => d -> u) -> TaggedVal val -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> TaggedVal val -> [u]
$cgmapQ :: forall val u.
Data val =>
(forall d. Data d => d -> u) -> TaggedVal val -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
$cgmapQr :: forall val r r'.
Data val =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
$cgmapQl :: forall val r r'.
Data val =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
gmapT :: (forall b. Data b => b -> b) -> TaggedVal val -> TaggedVal val
$cgmapT :: forall val.
Data val =>
(forall b. Data b => b -> b) -> TaggedVal val -> TaggedVal val
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (TaggedVal val))
$cdataCast2 :: forall val (t :: * -> * -> *) (c :: * -> *).
(Data val, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (TaggedVal val))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val))
$cdataCast1 :: forall val (t :: * -> *) (c :: * -> *).
(Data val, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val))
dataTypeOf :: TaggedVal val -> DataType
$cdataTypeOf :: forall val. Data val => TaggedVal val -> DataType
toConstr :: TaggedVal val -> Constr
$ctoConstr :: forall val. Data val => TaggedVal val -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val)
$cgunfold :: forall val (c :: * -> *).
Data val =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TaggedVal val -> c (TaggedVal val)
$cgfoldl :: forall val (c :: * -> *).
Data val =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TaggedVal val -> c (TaggedVal val)
Data, forall a b. a -> TaggedVal b -> TaggedVal a
forall a b. (a -> b) -> TaggedVal a -> TaggedVal 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 -> TaggedVal b -> TaggedVal a
$c<$ :: forall a b. a -> TaggedVal b -> TaggedVal a
fmap :: forall a b. (a -> b) -> TaggedVal a -> TaggedVal b
$cfmap :: forall a b. (a -> b) -> TaggedVal a -> TaggedVal b
Functor, forall a. Eq a => a -> TaggedVal a -> Bool
forall a. Num a => TaggedVal a -> a
forall a. Ord a => TaggedVal a -> a
forall m. Monoid m => TaggedVal m -> m
forall a. TaggedVal a -> Bool
forall a. TaggedVal a -> Int
forall a. TaggedVal a -> [a]
forall a. (a -> a -> a) -> TaggedVal a -> a
forall m a. Monoid m => (a -> m) -> TaggedVal a -> m
forall b a. (b -> a -> b) -> b -> TaggedVal a -> b
forall a b. (a -> b -> b) -> b -> TaggedVal 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 => TaggedVal a -> a
$cproduct :: forall a. Num a => TaggedVal a -> a
sum :: forall a. Num a => TaggedVal a -> a
$csum :: forall a. Num a => TaggedVal a -> a
minimum :: forall a. Ord a => TaggedVal a -> a
$cminimum :: forall a. Ord a => TaggedVal a -> a
maximum :: forall a. Ord a => TaggedVal a -> a
$cmaximum :: forall a. Ord a => TaggedVal a -> a
elem :: forall a. Eq a => a -> TaggedVal a -> Bool
$celem :: forall a. Eq a => a -> TaggedVal a -> Bool
length :: forall a. TaggedVal a -> Int
$clength :: forall a. TaggedVal a -> Int
null :: forall a. TaggedVal a -> Bool
$cnull :: forall a. TaggedVal a -> Bool
toList :: forall a. TaggedVal a -> [a]
$ctoList :: forall a. TaggedVal a -> [a]
foldl1 :: forall a. (a -> a -> a) -> TaggedVal a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> TaggedVal a -> a
foldr1 :: forall a. (a -> a -> a) -> TaggedVal a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> TaggedVal a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> TaggedVal a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> TaggedVal a -> b
foldl :: forall b a. (b -> a -> b) -> b -> TaggedVal a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> TaggedVal a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> TaggedVal a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> TaggedVal a -> b
foldr :: forall a b. (a -> b -> b) -> b -> TaggedVal a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> TaggedVal a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> TaggedVal a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> TaggedVal a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> TaggedVal a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> TaggedVal a -> m
fold :: forall m. Monoid m => TaggedVal m -> m
$cfold :: forall m. Monoid m => TaggedVal m -> m
Foldable, Functor TaggedVal
Foldable TaggedVal
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 (m :: * -> *) a.
Monad m =>
TaggedVal (m a) -> m (TaggedVal a)
forall (f :: * -> *) a.
Applicative f =>
TaggedVal (f a) -> f (TaggedVal a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TaggedVal a -> m (TaggedVal b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TaggedVal a -> f (TaggedVal b)
sequence :: forall (m :: * -> *) a.
Monad m =>
TaggedVal (m a) -> m (TaggedVal a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
TaggedVal (m a) -> m (TaggedVal a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TaggedVal a -> m (TaggedVal b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TaggedVal a -> m (TaggedVal b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
TaggedVal (f a) -> f (TaggedVal a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
TaggedVal (f a) -> f (TaggedVal a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TaggedVal a -> f (TaggedVal b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TaggedVal a -> f (TaggedVal b)
Traversable)
taggedFst :: TaggedVal val -> val
taggedFst :: forall val. TaggedVal val -> val
taggedFst (TaggedVal val
v Int
_) = val
v
taggedSnd :: TaggedVal val -> Int
taggedSnd :: forall a. TaggedVal a -> Int
taggedSnd (TaggedVal val
_ Int
i) = Int
i
instance Eq val => Eq (TaggedVal val) where
(TaggedVal val
v1 Int
_) == :: TaggedVal val -> TaggedVal val -> Bool
== (TaggedVal val
v2 Int
_) = val
v1 forall a. Eq a => a -> a -> Bool
== val
v2
data UniqDFM key ele =
UDFM
!(M.IntMap (TaggedVal ele))
{-# UNPACK #-} !Int
deriving (UniqDFM key ele -> DataType
UniqDFM key ele -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {key} {ele}.
(Data key, Data ele) =>
Typeable (UniqDFM key ele)
forall key ele. (Data key, Data ele) => UniqDFM key ele -> DataType
forall key ele. (Data key, Data ele) => UniqDFM key ele -> Constr
forall key ele.
(Data key, Data ele) =>
(forall b. Data b => b -> b) -> UniqDFM key ele -> UniqDFM key ele
forall key ele u.
(Data key, Data ele) =>
Int -> (forall d. Data d => d -> u) -> UniqDFM key ele -> u
forall key ele u.
(Data key, Data ele) =>
(forall d. Data d => d -> u) -> UniqDFM key ele -> [u]
forall key ele r r'.
(Data key, Data ele) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
forall key ele r r'.
(Data key, Data ele) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
forall key ele (m :: * -> *).
(Data key, Data ele, Monad m) =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
forall key ele (m :: * -> *).
(Data key, Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
forall key ele (c :: * -> *).
(Data key, Data ele) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM key ele)
forall key ele (c :: * -> *).
(Data key, Data ele) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM key ele -> c (UniqDFM key ele)
forall key ele (t :: * -> *) (c :: * -> *).
(Data key, Data ele, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM key ele))
forall key ele (t :: * -> * -> *) (c :: * -> *).
(Data key, Data ele, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM key ele))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM key ele)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM key ele -> c (UniqDFM key ele)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM key ele))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
$cgmapMo :: forall key ele (m :: * -> *).
(Data key, Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
$cgmapMp :: forall key ele (m :: * -> *).
(Data key, Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
$cgmapM :: forall key ele (m :: * -> *).
(Data key, Data ele, Monad m) =>
(forall d. Data d => d -> m d)
-> UniqDFM key ele -> m (UniqDFM key ele)
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UniqDFM key ele -> u
$cgmapQi :: forall key ele u.
(Data key, Data ele) =>
Int -> (forall d. Data d => d -> u) -> UniqDFM key ele -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> UniqDFM key ele -> [u]
$cgmapQ :: forall key ele u.
(Data key, Data ele) =>
(forall d. Data d => d -> u) -> UniqDFM key ele -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
$cgmapQr :: forall key ele r r'.
(Data key, Data ele) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
$cgmapQl :: forall key ele r r'.
(Data key, Data ele) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r
gmapT :: (forall b. Data b => b -> b) -> UniqDFM key ele -> UniqDFM key ele
$cgmapT :: forall key ele.
(Data key, Data ele) =>
(forall b. Data b => b -> b) -> UniqDFM key ele -> UniqDFM key ele
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM key ele))
$cdataCast2 :: forall key ele (t :: * -> * -> *) (c :: * -> *).
(Data key, Data ele, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM key ele))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM key ele))
$cdataCast1 :: forall key ele (t :: * -> *) (c :: * -> *).
(Data key, Data ele, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM key ele))
dataTypeOf :: UniqDFM key ele -> DataType
$cdataTypeOf :: forall key ele. (Data key, Data ele) => UniqDFM key ele -> DataType
toConstr :: UniqDFM key ele -> Constr
$ctoConstr :: forall key ele. (Data key, Data ele) => UniqDFM key ele -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM key ele)
$cgunfold :: forall key ele (c :: * -> *).
(Data key, Data ele) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM key ele)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM key ele -> c (UniqDFM key ele)
$cgfoldl :: forall key ele (c :: * -> *).
(Data key, Data ele) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM key ele -> c (UniqDFM key ele)
Data, forall a b. a -> UniqDFM key b -> UniqDFM key a
forall a b. (a -> b) -> UniqDFM key a -> UniqDFM key b
forall key a b. a -> UniqDFM key b -> UniqDFM key a
forall key a b. (a -> b) -> UniqDFM key a -> UniqDFM key 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 -> UniqDFM key b -> UniqDFM key a
$c<$ :: forall key a b. a -> UniqDFM key b -> UniqDFM key a
fmap :: forall a b. (a -> b) -> UniqDFM key a -> UniqDFM key b
$cfmap :: forall key a b. (a -> b) -> UniqDFM key a -> UniqDFM key b
Functor)
instance Foldable (UniqDFM key) where
foldr :: forall a b. (a -> b -> b) -> b -> UniqDFM key a -> b
foldr = forall elt a key. (elt -> a -> a) -> a -> UniqDFM key elt -> a
foldUDFM
instance Traversable (UniqDFM key) where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UniqDFM key a -> f (UniqDFM key b)
traverse a -> f b
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall elt key. [(Unique, elt)] -> UniqDFM key elt
listToUDFM_Directly
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\(Unique
u,a
a) -> (Unique
u,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall key elt. UniqDFM key elt -> [(Unique, elt)]
udfmToList
emptyUDFM :: UniqDFM key elt
emptyUDFM :: forall key elt. UniqDFM key elt
emptyUDFM = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM forall a. IntMap a
M.empty Int
0
unitUDFM :: Uniquable key => key -> elt -> UniqDFM key elt
unitUDFM :: forall key elt. Uniquable key => key -> elt -> UniqDFM key elt
unitUDFM key
k elt
v = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. Int -> a -> IntMap a
M.singleton (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) (forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
0)) Int
1
addToUDFM :: Uniquable key => UniqDFM key elt -> key -> elt -> UniqDFM key elt
addToUDFM :: forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> elt -> UniqDFM key elt
addToUDFM UniqDFM key elt
m key
k elt
v = forall key elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_Directly UniqDFM key elt
m (forall a. Uniquable a => a -> Unique
getUnique key
k) elt
v
addToUDFM_Directly :: UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_Directly :: forall key elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_Directly (UDFM IntMap (TaggedVal elt)
m Int
i) Unique
u elt
v
= forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
MS.insertWith forall {val} {val}. TaggedVal val -> TaggedVal val -> TaggedVal val
tf (Unique -> Int
getKey Unique
u) (forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
i) IntMap (TaggedVal elt)
m) (Int
i forall a. Num a => a -> a -> a
+ Int
1)
where
tf :: TaggedVal val -> TaggedVal val -> TaggedVal val
tf (TaggedVal val
new_v Int
_) (TaggedVal val
_ Int
old_i) = forall val. val -> Int -> TaggedVal val
TaggedVal val
new_v Int
old_i
addToUDFM_C_Directly
:: (elt -> elt -> elt)
-> UniqDFM key elt
-> Unique -> elt
-> UniqDFM key elt
addToUDFM_C_Directly :: forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_C_Directly elt -> elt -> elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) Unique
u elt
v
= forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
MS.insertWith TaggedVal elt -> TaggedVal elt -> TaggedVal elt
tf (Unique -> Int
getKey Unique
u) (forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
i) IntMap (TaggedVal elt)
m) (Int
i forall a. Num a => a -> a -> a
+ Int
1)
where
tf :: TaggedVal elt -> TaggedVal elt -> TaggedVal elt
tf (TaggedVal elt
new_v Int
_) (TaggedVal elt
old_v Int
old_i)
= forall val. val -> Int -> TaggedVal val
TaggedVal (elt -> elt -> elt
f elt
old_v elt
new_v) Int
old_i
addToUDFM_C
:: Uniquable key => (elt -> elt -> elt)
-> UniqDFM key elt
-> key -> elt
-> UniqDFM key elt
addToUDFM_C :: forall key elt.
Uniquable key =>
(elt -> elt -> elt)
-> UniqDFM key elt -> key -> elt -> UniqDFM key elt
addToUDFM_C elt -> elt -> elt
f UniqDFM key elt
m key
k elt
v = forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_C_Directly elt -> elt -> elt
f UniqDFM key elt
m (forall a. Uniquable a => a -> Unique
getUnique key
k) elt
v
addListToUDFM :: Uniquable key => UniqDFM key elt -> [(key,elt)] -> UniqDFM key elt
addListToUDFM :: forall key elt.
Uniquable key =>
UniqDFM key elt -> [(key, elt)] -> UniqDFM key elt
addListToUDFM = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM key elt
m (key
k, elt
v) -> forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> elt -> UniqDFM key elt
addToUDFM UniqDFM key elt
m key
k elt
v)
addListToUDFM_Directly :: UniqDFM key elt -> [(Unique,elt)] -> UniqDFM key elt
addListToUDFM_Directly :: forall key elt.
UniqDFM key elt -> [(Unique, elt)] -> UniqDFM key elt
addListToUDFM_Directly = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM key elt
m (Unique
k, elt
v) -> forall key elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_Directly UniqDFM key elt
m Unique
k elt
v)
addListToUDFM_Directly_C
:: (elt -> elt -> elt) -> UniqDFM key elt -> [(Unique,elt)] -> UniqDFM key elt
addListToUDFM_Directly_C :: forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> [(Unique, elt)] -> UniqDFM key elt
addListToUDFM_Directly_C elt -> elt -> elt
f = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM key elt
m (Unique
k, elt
v) -> forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_C_Directly elt -> elt -> elt
f UniqDFM key elt
m Unique
k elt
v)
delFromUDFM :: Uniquable key => UniqDFM key elt -> key -> UniqDFM key elt
delFromUDFM :: forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> UniqDFM key elt
delFromUDFM (UDFM IntMap (TaggedVal elt)
m Int
i) key
k = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. Int -> IntMap a -> IntMap a
M.delete (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) Int
i
plusUDFM_C :: (elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
plusUDFM_C :: forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
plusUDFM_C elt -> elt -> elt
f udfml :: UniqDFM key elt
udfml@(UDFM IntMap (TaggedVal elt)
_ Int
i) udfmr :: UniqDFM key elt
udfmr@(UDFM IntMap (TaggedVal elt)
_ Int
j)
| Int
i forall a. Ord a => a -> a -> Bool
> Int
j = forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM key elt
udfml UniqDFM key elt
udfmr
| Bool
otherwise = forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM key elt
udfmr UniqDFM key elt
udfml
plusUDFM :: UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
plusUDFM :: forall key elt.
UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
plusUDFM udfml :: UniqDFM key elt
udfml@(UDFM IntMap (TaggedVal elt)
_ Int
i) udfmr :: UniqDFM key elt
udfmr@(UDFM IntMap (TaggedVal elt)
_ Int
j)
| Int
i forall a. Ord a => a -> a -> Bool
> Int
j = forall key elt.
UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft UniqDFM key elt
udfml UniqDFM key elt
udfmr
| Bool
otherwise = forall key elt.
UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft UniqDFM key elt
udfmr UniqDFM key elt
udfml
insertUDFMIntoLeft :: UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft :: forall key elt.
UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft UniqDFM key elt
udfml UniqDFM key elt
udfmr = forall key elt.
UniqDFM key elt -> [(Unique, elt)] -> UniqDFM key elt
addListToUDFM_Directly UniqDFM key elt
udfml forall a b. (a -> b) -> a -> b
$ forall key elt. UniqDFM key elt -> [(Unique, elt)]
udfmToList UniqDFM key elt
udfmr
insertUDFMIntoLeft_C
:: (elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft_C :: forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM key elt
udfml UniqDFM key elt
udfmr =
forall elt key.
(elt -> elt -> elt)
-> UniqDFM key elt -> [(Unique, elt)] -> UniqDFM key elt
addListToUDFM_Directly_C elt -> elt -> elt
f UniqDFM key elt
udfml forall a b. (a -> b) -> a -> b
$ forall key elt. UniqDFM key elt -> [(Unique, elt)]
udfmToList UniqDFM key elt
udfmr
lookupUDFM :: Uniquable key => UniqDFM key elt -> key -> Maybe elt
lookupUDFM :: forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> Maybe elt
lookupUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) key
k = forall val. TaggedVal val -> val
taggedFst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Int -> IntMap a -> Maybe a
M.lookup (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m
lookupUDFM_Directly :: UniqDFM key elt -> Unique -> Maybe elt
lookupUDFM_Directly :: forall key elt. UniqDFM key elt -> Unique -> Maybe elt
lookupUDFM_Directly (UDFM IntMap (TaggedVal elt)
m Int
_i) Unique
k = forall val. TaggedVal val -> val
taggedFst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a. Int -> IntMap a -> Maybe a
M.lookup (Unique -> Int
getKey Unique
k) IntMap (TaggedVal elt)
m
elemUDFM :: Uniquable key => key -> UniqDFM key elt -> Bool
elemUDFM :: forall key elt. Uniquable key => key -> UniqDFM key elt -> Bool
elemUDFM key
k (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall a. Int -> IntMap a -> Bool
M.member (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m
foldUDFM :: (elt -> a -> a) -> a -> UniqDFM key elt -> a
foldUDFM :: forall elt a key. (elt -> a -> a) -> a -> UniqDFM key elt -> a
foldUDFM elt -> a -> a
k a
z UniqDFM key elt
m = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr elt -> a -> a
k a
z (forall key a. UniqDFM key a -> [a]
eltsUDFM UniqDFM key elt
m)
nonDetStrictFoldUDFM :: (elt -> a -> a) -> a -> UniqDFM key elt -> a
nonDetStrictFoldUDFM :: forall elt a key. (elt -> a -> a) -> a -> UniqDFM key elt -> a
nonDetStrictFoldUDFM elt -> a -> a
k a
z (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' a -> TaggedVal elt -> a
k' a
z IntMap (TaggedVal elt)
m
where
k' :: a -> TaggedVal elt -> a
k' a
acc (TaggedVal elt
v Int
_) = elt -> a -> a
k elt
v a
acc
eltsUDFM :: UniqDFM key elt -> [elt]
{-# INLINE eltsUDFM #-}
eltsUDFM :: forall key a. UniqDFM key a -> [a]
eltsUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall a b. (a -> b) -> [a] -> [b]
map forall val. TaggedVal val -> val
taggedFst (forall elt. IntMap (TaggedVal elt) -> [TaggedVal elt]
sort_it IntMap (TaggedVal elt)
m)
sort_it :: M.IntMap (TaggedVal elt) -> [TaggedVal elt]
sort_it :: forall elt. IntMap (TaggedVal elt) -> [TaggedVal elt]
sort_it IntMap (TaggedVal elt)
m = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a. TaggedVal a -> Int
taggedSnd) (forall a. IntMap a -> [a]
M.elems IntMap (TaggedVal elt)
m)
filterUDFM :: (elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
filterUDFM :: forall elt key. (elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
filterUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (a -> Bool) -> IntMap a -> IntMap a
M.filter (\(TaggedVal elt
v Int
_) -> elt -> Bool
p elt
v) IntMap (TaggedVal elt)
m) Int
i
filterUDFM_Directly :: (Unique -> elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
filterUDFM_Directly :: forall elt key.
(Unique -> elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
filterUDFM_Directly Unique -> elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (Int -> a -> Bool) -> IntMap a -> IntMap a
M.filterWithKey Int -> TaggedVal elt -> Bool
p' IntMap (TaggedVal elt)
m) Int
i
where
p' :: Int -> TaggedVal elt -> Bool
p' Int
k (TaggedVal elt
v Int
_) = Unique -> elt -> Bool
p (forall a. Uniquable a => a -> Unique
getUnique Int
k) elt
v
udfmRestrictKeys :: UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt
udfmRestrictKeys :: forall key elt elt2.
UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt
udfmRestrictKeys (UDFM IntMap (TaggedVal elt)
a Int
i) (UDFM IntMap (TaggedVal elt2)
b Int
_) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. IntMap a -> IntSet -> IntMap a
M.restrictKeys IntMap (TaggedVal elt)
a (forall a. IntMap a -> IntSet
M.keysSet IntMap (TaggedVal elt2)
b)) Int
i
udfmRestrictKeysSet :: UniqDFM key elt -> I.IntSet -> UniqDFM key elt
udfmRestrictKeysSet :: forall key elt. UniqDFM key elt -> IntSet -> UniqDFM key elt
udfmRestrictKeysSet (UDFM IntMap (TaggedVal elt)
val_set Int
i) IntSet
set =
let key_set :: IntSet
key_set = IntSet
set
in forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. IntMap a -> IntSet -> IntMap a
M.restrictKeys IntMap (TaggedVal elt)
val_set IntSet
key_set) Int
i
udfmToList :: UniqDFM key elt -> [(Unique, elt)]
udfmToList :: forall key elt. UniqDFM key elt -> [(Unique, elt)]
udfmToList (UDFM IntMap (TaggedVal elt)
m Int
_i) =
[ (forall a. Uniquable a => a -> Unique
getUnique Int
k, forall val. TaggedVal val -> val
taggedFst TaggedVal elt
v)
| (Int
k, TaggedVal elt
v) <- forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (forall a. TaggedVal a -> Int
taggedSnd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd)) forall a b. (a -> b) -> a -> b
$ forall a. IntMap a -> [(Int, a)]
M.toList IntMap (TaggedVal elt)
m ]
equalKeysUDFM :: UniqDFM key a -> UniqDFM key b -> Bool
equalKeysUDFM :: forall key a b. UniqDFM key a -> UniqDFM key b -> Bool
equalKeysUDFM (UDFM IntMap (TaggedVal a)
m1 Int
_) (UDFM IntMap (TaggedVal b)
m2 Int
_) = forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq (\TaggedVal a
_ TaggedVal b
_ -> Bool
True) IntMap (TaggedVal a)
m1 IntMap (TaggedVal b)
m2
isNullUDFM :: UniqDFM key elt -> Bool
isNullUDFM :: forall key a. UniqDFM key a -> Bool
isNullUDFM (UDFM IntMap (TaggedVal elt)
m Int
_) = forall a. IntMap a -> Bool
M.null IntMap (TaggedVal elt)
m
sizeUDFM :: UniqDFM key elt -> Int
sizeUDFM :: forall key a. UniqDFM key a -> Int
sizeUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall a. IntMap a -> Int
M.size IntMap (TaggedVal elt)
m
intersectUDFM :: UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
intersectUDFM :: forall key elt.
UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
intersectUDFM (UDFM IntMap (TaggedVal elt)
x Int
i) (UDFM IntMap (TaggedVal elt)
y Int
_j) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt)
x IntMap (TaggedVal elt)
y) Int
i
udfmIntersectUFM :: UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
udfmIntersectUFM :: forall key elt1 elt2.
UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
udfmIntersectUFM (UDFM IntMap (TaggedVal elt1)
x Int
i) UniqFM key elt2
y = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt1)
x (forall key elt. UniqFM key elt -> IntMap elt
ufmToIntMap UniqFM key elt2
y)) Int
i
disjointUDFM :: UniqDFM key elt -> UniqDFM key elt -> Bool
disjointUDFM :: forall key elt. UniqDFM key elt -> UniqDFM key elt -> Bool
disjointUDFM (UDFM IntMap (TaggedVal elt)
x Int
_i) (UDFM IntMap (TaggedVal elt)
y Int
_j) = forall a b. IntMap a -> IntMap b -> Bool
M.disjoint IntMap (TaggedVal elt)
x IntMap (TaggedVal elt)
y
disjointUdfmUfm :: UniqDFM key elt -> UniqFM key elt2 -> Bool
disjointUdfmUfm :: forall key elt elt2. UniqDFM key elt -> UniqFM key elt2 -> Bool
disjointUdfmUfm (UDFM IntMap (TaggedVal elt)
x Int
_i) UniqFM key elt2
y = forall a b. IntMap a -> IntMap b -> Bool
M.disjoint IntMap (TaggedVal elt)
x (forall key elt. UniqFM key elt -> IntMap elt
ufmToIntMap UniqFM key elt2
y)
minusUDFM :: UniqDFM key elt1 -> UniqDFM key elt2 -> UniqDFM key elt1
minusUDFM :: forall key elt elt2.
UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt
minusUDFM (UDFM IntMap (TaggedVal elt1)
x Int
i) (UDFM IntMap (TaggedVal elt2)
y Int
_j) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. IntMap a -> IntMap b -> IntMap a
M.difference IntMap (TaggedVal elt1)
x IntMap (TaggedVal elt2)
y) Int
i
udfmMinusUFM :: UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
udfmMinusUFM :: forall key elt1 elt2.
UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
udfmMinusUFM (UDFM IntMap (TaggedVal elt1)
x Int
i) UniqFM key elt2
y = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. IntMap a -> IntMap b -> IntMap a
M.difference IntMap (TaggedVal elt1)
x (forall key elt. UniqFM key elt -> IntMap elt
ufmToIntMap UniqFM key elt2
y)) Int
i
ufmMinusUDFM :: UniqFM key elt1 -> UniqDFM key elt2 -> UniqFM key elt1
ufmMinusUDFM :: forall key elt1 elt2.
UniqFM key elt1 -> UniqDFM key elt2 -> UniqFM key elt1
ufmMinusUDFM UniqFM key elt1
x (UDFM IntMap (TaggedVal elt2)
y Int
_i) = forall elt key. IntMap elt -> UniqFM key elt
unsafeIntMapToUFM (forall a b. IntMap a -> IntMap b -> IntMap a
M.difference (forall key elt. UniqFM key elt -> IntMap elt
ufmToIntMap UniqFM key elt1
x) IntMap (TaggedVal elt2)
y)
partitionUDFM :: (elt -> Bool) -> UniqDFM key elt -> (UniqDFM key elt, UniqDFM key elt)
partitionUDFM :: forall elt key.
(elt -> Bool)
-> UniqDFM key elt -> (UniqDFM key elt, UniqDFM key elt)
partitionUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) =
case forall a. (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
M.partition (elt -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall val. TaggedVal val -> val
taggedFst) IntMap (TaggedVal elt)
m of
(IntMap (TaggedVal elt)
left, IntMap (TaggedVal elt)
right) -> (forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM IntMap (TaggedVal elt)
left Int
i, forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM IntMap (TaggedVal elt)
right Int
i)
delListFromUDFM :: Uniquable key => UniqDFM key elt -> [key] -> UniqDFM key elt
delListFromUDFM :: forall key elt.
Uniquable key =>
UniqDFM key elt -> [key] -> UniqDFM key elt
delListFromUDFM = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> UniqDFM key elt
delFromUDFM
udfmToUfm :: UniqDFM key elt -> UniqFM key elt
udfmToUfm :: forall key elt. UniqDFM key elt -> UniqFM key elt
udfmToUfm (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall elt key. IntMap elt -> UniqFM key elt
unsafeIntMapToUFM (forall a b. (a -> b) -> IntMap a -> IntMap b
M.map forall val. TaggedVal val -> val
taggedFst IntMap (TaggedVal elt)
m)
listToUDFM :: Uniquable key => [(key,elt)] -> UniqDFM key elt
listToUDFM :: forall key elt. Uniquable key => [(key, elt)] -> UniqDFM key elt
listToUDFM = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM key elt
m (key
k, elt
v) -> forall key elt.
Uniquable key =>
UniqDFM key elt -> key -> elt -> UniqDFM key elt
addToUDFM UniqDFM key elt
m key
k elt
v) forall key elt. UniqDFM key elt
emptyUDFM
listToUDFM_Directly :: [(Unique, elt)] -> UniqDFM key elt
listToUDFM_Directly :: forall elt key. [(Unique, elt)] -> UniqDFM key elt
listToUDFM_Directly = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM key elt
m (Unique
u, elt
v) -> forall key elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
addToUDFM_Directly UniqDFM key elt
m Unique
u elt
v) forall key elt. UniqDFM key elt
emptyUDFM
adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM key elt -> key -> UniqDFM key elt
adjustUDFM :: forall key elt.
Uniquable key =>
(elt -> elt) -> UniqDFM key elt -> key -> UniqDFM key elt
adjustUDFM elt -> elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) key
k = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (a -> a) -> Int -> IntMap a -> IntMap a
M.adjust (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap elt -> elt
f) (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) Int
i
adjustUDFM_Directly :: (elt -> elt) -> UniqDFM key elt -> Unique -> UniqDFM key elt
adjustUDFM_Directly :: forall elt key.
(elt -> elt) -> UniqDFM key elt -> Unique -> UniqDFM key elt
adjustUDFM_Directly elt -> elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) Unique
k = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (a -> a) -> Int -> IntMap a -> IntMap a
M.adjust (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap elt -> elt
f) (Unique -> Int
getKey Unique
k) IntMap (TaggedVal elt)
m) Int
i
alterUDFM
:: Uniquable key
=> (Maybe elt -> Maybe elt)
-> UniqDFM key elt
-> key
-> UniqDFM key elt
alterUDFM :: forall key elt.
Uniquable key =>
(Maybe elt -> Maybe elt)
-> UniqDFM key elt -> key -> UniqDFM key elt
alterUDFM Maybe elt -> Maybe elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) key
k =
forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a. (Maybe a -> Maybe a) -> Int -> IntMap a -> IntMap a
M.alter Maybe (TaggedVal elt) -> Maybe (TaggedVal elt)
alterf (Unique -> Int
getKey forall a b. (a -> b) -> a -> b
$ forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) (Int
i forall a. Num a => a -> a -> a
+ Int
1)
where
alterf :: Maybe (TaggedVal elt) -> Maybe (TaggedVal elt)
alterf Maybe (TaggedVal elt)
Nothing = Maybe elt -> Maybe (TaggedVal elt)
inject forall a b. (a -> b) -> a -> b
$ Maybe elt -> Maybe elt
f forall a. Maybe a
Nothing
alterf (Just (TaggedVal elt
v Int
_)) = Maybe elt -> Maybe (TaggedVal elt)
inject forall a b. (a -> b) -> a -> b
$ Maybe elt -> Maybe elt
f (forall a. a -> Maybe a
Just elt
v)
inject :: Maybe elt -> Maybe (TaggedVal elt)
inject Maybe elt
Nothing = forall a. Maybe a
Nothing
inject (Just elt
v) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
i
mapUDFM :: (elt1 -> elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
mapUDFM :: forall elt1 elt2 key.
(elt1 -> elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
mapUDFM elt1 -> elt2
f (UDFM IntMap (TaggedVal elt1)
m Int
i) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. (a -> b) -> IntMap a -> IntMap b
MS.map (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap elt1 -> elt2
f) IntMap (TaggedVal elt1)
m) Int
i
mapMaybeUDFM :: forall elt1 elt2 key.
(elt1 -> Maybe elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
mapMaybeUDFM :: forall elt1 elt2 key.
(elt1 -> Maybe elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
mapMaybeUDFM elt1 -> Maybe elt2
f (UDFM IntMap (TaggedVal elt1)
m Int
i) = forall key ele. IntMap (TaggedVal ele) -> Int -> UniqDFM key ele
UDFM (forall a b. (a -> Maybe b) -> IntMap a -> IntMap b
M.mapMaybe (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse elt1 -> Maybe elt2
f) IntMap (TaggedVal elt1)
m) Int
i
anyUDFM :: (elt -> Bool) -> UniqDFM key elt -> Bool
anyUDFM :: forall elt key. (elt -> Bool) -> UniqDFM key elt -> Bool
anyUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall a b. (a -> b -> b) -> b -> IntMap a -> b
M.foldr (Bool -> Bool -> Bool
(||) forall b c a. (b -> c) -> (a -> b) -> a -> c
. elt -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall val. TaggedVal val -> val
taggedFst) Bool
False IntMap (TaggedVal elt)
m
allUDFM :: (elt -> Bool) -> UniqDFM key elt -> Bool
allUDFM :: forall elt key. (elt -> Bool) -> UniqDFM key elt -> Bool
allUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
_i) = forall a b. (a -> b -> b) -> b -> IntMap a -> b
M.foldr (Bool -> Bool -> Bool
(&&) forall b c a. (b -> c) -> (a -> b) -> a -> c
. elt -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall val. TaggedVal val -> val
taggedFst) Bool
True IntMap (TaggedVal elt)
m
alwaysUnsafeUfmToUdfm :: UniqFM key elt -> UniqDFM key elt
alwaysUnsafeUfmToUdfm :: forall key elt. UniqFM key elt -> UniqDFM key elt
alwaysUnsafeUfmToUdfm = forall elt key. [(Unique, elt)] -> UniqDFM key elt
listToUDFM_Directly forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall key elt. UniqFM key elt -> [(Unique, elt)]
nonDetUFMToList
unsafeCastUDFMKey :: UniqDFM key1 elt -> UniqDFM key2 elt
unsafeCastUDFMKey :: forall key1 elt key2. UniqDFM key1 elt -> UniqDFM key2 elt
unsafeCastUDFMKey = forall a b. a -> b
unsafeCoerce
instance Outputable a => Outputable (UniqDFM key a) where
ppr :: UniqDFM key a -> SDoc
ppr UniqDFM key a
ufm = forall a key. (a -> SDoc) -> UniqDFM key a -> SDoc
pprUniqDFM forall a. Outputable a => a -> SDoc
ppr UniqDFM key a
ufm
pprUniqDFM :: (a -> SDoc) -> UniqDFM key a -> SDoc
pprUniqDFM :: forall a key. (a -> SDoc) -> UniqDFM key a -> SDoc
pprUniqDFM a -> SDoc
ppr_elt UniqDFM key a
ufm
= forall doc. IsLine doc => doc -> doc
brackets forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
fsep forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc -> [doc] -> [doc]
punctuate forall doc. IsLine doc => doc
comma forall a b. (a -> b) -> a -> b
$
[ forall a. Outputable a => a -> SDoc
ppr Unique
uq forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
":->" forall doc. IsLine doc => doc -> doc -> doc
<+> a -> SDoc
ppr_elt a
elt
| (Unique
uq, a
elt) <- forall key elt. UniqDFM key elt -> [(Unique, elt)]
udfmToList UniqDFM key a
ufm ]
pprUDFM :: UniqDFM key a
-> ([a] -> SDoc)
-> SDoc
pprUDFM :: forall key a. UniqDFM key a -> ([a] -> SDoc) -> SDoc
pprUDFM UniqDFM key a
ufm [a] -> SDoc
pp = [a] -> SDoc
pp (forall key a. UniqDFM key a -> [a]
eltsUDFM UniqDFM key a
ufm)