{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wall #-}
module UniqDFM (
UniqDFM,
emptyUDFM,
unitUDFM,
addToUDFM,
addToUDFM_C,
addListToUDFM,
delFromUDFM,
delListFromUDFM,
adjustUDFM,
alterUDFM,
mapUDFM,
plusUDFM,
plusUDFM_C,
lookupUDFM, lookupUDFM_Directly,
elemUDFM,
foldUDFM,
eltsUDFM,
filterUDFM, filterUDFM_Directly,
isNullUDFM,
sizeUDFM,
intersectUDFM, udfmIntersectUFM,
intersectsUDFM,
disjointUDFM, disjointUdfmUfm,
equalKeysUDFM,
minusUDFM,
listToUDFM,
udfmMinusUFM,
partitionUDFM,
anyUDFM, allUDFM,
pprUniqDFM, pprUDFM,
udfmToList,
udfmToUfm,
nonDetFoldUDFM,
alwaysUnsafeUfmToUdfm,
) where
import GhcPrelude
import Unique ( Uniquable(..), Unique, getKey )
import Outputable
import qualified Data.IntMap as M
import Data.Data
import Data.Functor.Classes (Eq1 (..))
import Data.List (sortBy)
import Data.Function (on)
import qualified Data.Semigroup as Semi
import UniqFM (UniqFM, listToUFM_Directly, nonDetUFMToList, ufmToIntMap)
data TaggedVal val =
TaggedVal
val
{-# UNPACK #-} !Int
deriving (Typeable (TaggedVal val)
DataType
Constr
Typeable (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 (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val))
-> (TaggedVal val -> Constr)
-> (TaggedVal val -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (TaggedVal val)))
-> ((forall b. Data b => b -> b) -> TaggedVal val -> TaggedVal val)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r)
-> (forall u. (forall d. Data d => d -> u) -> TaggedVal val -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> TaggedVal val -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val))
-> Data (TaggedVal val)
TaggedVal val -> DataType
TaggedVal val -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (TaggedVal val))
(forall b. Data b => b -> b) -> TaggedVal val -> TaggedVal val
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TaggedVal val -> c (TaggedVal val)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (TaggedVal val)
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 u. Int -> (forall d. Data d => d -> u) -> TaggedVal val -> u
forall u. (forall d. Data d => d -> u) -> TaggedVal val -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TaggedVal val -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> TaggedVal val -> m (TaggedVal val)
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))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (TaggedVal val))
$cTaggedVal :: Constr
$tTaggedVal :: DataType
gmapMo :: (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 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 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 :: 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 d. Data d => d -> u) -> TaggedVal val -> [u]
$cgmapQ :: forall val u.
Data val =>
(forall d. Data d => d -> u) -> TaggedVal val -> [u]
gmapQr :: (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 :: (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 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 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 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 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)
$cp1Data :: forall val. Data val => Typeable (TaggedVal val)
Data, a -> TaggedVal b -> TaggedVal a
(a -> b) -> TaggedVal a -> TaggedVal b
(forall a b. (a -> b) -> TaggedVal a -> TaggedVal b)
-> (forall a b. a -> TaggedVal b -> TaggedVal a)
-> Functor TaggedVal
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
<$ :: a -> TaggedVal b -> TaggedVal a
$c<$ :: forall a b. a -> TaggedVal b -> TaggedVal a
fmap :: (a -> b) -> TaggedVal a -> TaggedVal b
$cfmap :: forall a b. (a -> b) -> TaggedVal a -> TaggedVal b
Functor)
taggedFst :: TaggedVal val -> val
taggedFst :: TaggedVal val -> val
taggedFst (TaggedVal val
v Int
_) = val
v
taggedSnd :: TaggedVal val -> Int
taggedSnd :: TaggedVal val -> 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 val -> val -> Bool
forall a. Eq a => a -> a -> Bool
== val
v2
data UniqDFM ele =
UDFM
!(M.IntMap (TaggedVal ele))
{-# UNPACK #-} !Int
deriving (Typeable (UniqDFM ele)
DataType
Constr
Typeable (UniqDFM ele)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele))
-> (UniqDFM ele -> Constr)
-> (UniqDFM ele -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM ele)))
-> ((forall b. Data b => b -> b) -> UniqDFM ele -> UniqDFM ele)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r)
-> (forall u. (forall d. Data d => d -> u) -> UniqDFM ele -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> UniqDFM ele -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele))
-> Data (UniqDFM ele)
UniqDFM ele -> DataType
UniqDFM ele -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele))
(forall b. Data b => b -> b) -> UniqDFM ele -> UniqDFM ele
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele)
forall ele. Data ele => Typeable (UniqDFM ele)
forall ele. Data ele => UniqDFM ele -> DataType
forall ele. Data ele => UniqDFM ele -> Constr
forall ele.
Data ele =>
(forall b. Data b => b -> b) -> UniqDFM ele -> UniqDFM ele
forall ele u.
Data ele =>
Int -> (forall d. Data d => d -> u) -> UniqDFM ele -> u
forall ele u.
Data ele =>
(forall d. Data d => d -> u) -> UniqDFM ele -> [u]
forall ele r r'.
Data ele =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
forall ele r r'.
Data ele =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
forall ele (m :: * -> *).
(Data ele, Monad m) =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
forall ele (m :: * -> *).
(Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
forall ele (c :: * -> *).
Data ele =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele)
forall ele (c :: * -> *).
Data ele =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele)
forall ele (t :: * -> *) (c :: * -> *).
(Data ele, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele))
forall ele (t :: * -> * -> *) (c :: * -> *).
(Data ele, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM ele))
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 u. Int -> (forall d. Data d => d -> u) -> UniqDFM ele -> u
forall u. (forall d. Data d => d -> u) -> UniqDFM ele -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM ele))
$cUDFM :: Constr
$tUniqDFM :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
$cgmapMo :: forall ele (m :: * -> *).
(Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
gmapMp :: (forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
$cgmapMp :: forall ele (m :: * -> *).
(Data ele, MonadPlus m) =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
gmapM :: (forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
$cgmapM :: forall ele (m :: * -> *).
(Data ele, Monad m) =>
(forall d. Data d => d -> m d) -> UniqDFM ele -> m (UniqDFM ele)
gmapQi :: Int -> (forall d. Data d => d -> u) -> UniqDFM ele -> u
$cgmapQi :: forall ele u.
Data ele =>
Int -> (forall d. Data d => d -> u) -> UniqDFM ele -> u
gmapQ :: (forall d. Data d => d -> u) -> UniqDFM ele -> [u]
$cgmapQ :: forall ele u.
Data ele =>
(forall d. Data d => d -> u) -> UniqDFM ele -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
$cgmapQr :: forall ele r r'.
Data ele =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
$cgmapQl :: forall ele r r'.
Data ele =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UniqDFM ele -> r
gmapT :: (forall b. Data b => b -> b) -> UniqDFM ele -> UniqDFM ele
$cgmapT :: forall ele.
Data ele =>
(forall b. Data b => b -> b) -> UniqDFM ele -> UniqDFM ele
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM ele))
$cdataCast2 :: forall ele (t :: * -> * -> *) (c :: * -> *).
(Data ele, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (UniqDFM ele))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele))
$cdataCast1 :: forall ele (t :: * -> *) (c :: * -> *).
(Data ele, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (UniqDFM ele))
dataTypeOf :: UniqDFM ele -> DataType
$cdataTypeOf :: forall ele. Data ele => UniqDFM ele -> DataType
toConstr :: UniqDFM ele -> Constr
$ctoConstr :: forall ele. Data ele => UniqDFM ele -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele)
$cgunfold :: forall ele (c :: * -> *).
Data ele =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (UniqDFM ele)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele)
$cgfoldl :: forall ele (c :: * -> *).
Data ele =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UniqDFM ele -> c (UniqDFM ele)
$cp1Data :: forall ele. Data ele => Typeable (UniqDFM ele)
Data, a -> UniqDFM b -> UniqDFM a
(a -> b) -> UniqDFM a -> UniqDFM b
(forall a b. (a -> b) -> UniqDFM a -> UniqDFM b)
-> (forall a b. a -> UniqDFM b -> UniqDFM a) -> Functor UniqDFM
forall a b. a -> UniqDFM b -> UniqDFM a
forall a b. (a -> b) -> UniqDFM a -> UniqDFM b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> UniqDFM b -> UniqDFM a
$c<$ :: forall a b. a -> UniqDFM b -> UniqDFM a
fmap :: (a -> b) -> UniqDFM a -> UniqDFM b
$cfmap :: forall a b. (a -> b) -> UniqDFM a -> UniqDFM b
Functor)
instance Foldable UniqDFM where
foldr :: (a -> b -> b) -> b -> UniqDFM a -> b
foldr = (a -> b -> b) -> b -> UniqDFM a -> b
forall a b. (a -> b -> b) -> b -> UniqDFM a -> b
foldUDFM
instance Traversable UniqDFM where
traverse :: (a -> f b) -> UniqDFM a -> f (UniqDFM b)
traverse a -> f b
f = ([(Unique, b)] -> UniqDFM b) -> f [(Unique, b)] -> f (UniqDFM b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Unique, b)] -> UniqDFM b
forall elt. [(Unique, elt)] -> UniqDFM elt
listToUDFM_Directly
(f [(Unique, b)] -> f (UniqDFM b))
-> (UniqDFM a -> f [(Unique, b)]) -> UniqDFM a -> f (UniqDFM b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Unique, a) -> f (Unique, b)) -> [(Unique, a)] -> f [(Unique, b)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\(Unique
u,a
a) -> (Unique
u,) (b -> (Unique, b)) -> f b -> f (Unique, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a)
([(Unique, a)] -> f [(Unique, b)])
-> (UniqDFM a -> [(Unique, a)]) -> UniqDFM a -> f [(Unique, b)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UniqDFM a -> [(Unique, a)]
forall elt. UniqDFM elt -> [(Unique, elt)]
udfmToList
emptyUDFM :: UniqDFM elt
emptyUDFM :: UniqDFM elt
emptyUDFM = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM IntMap (TaggedVal elt)
forall a. IntMap a
M.empty Int
0
unitUDFM :: Uniquable key => key -> elt -> UniqDFM elt
unitUDFM :: key -> elt -> UniqDFM elt
unitUDFM key
k elt
v = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (Int -> TaggedVal elt -> IntMap (TaggedVal elt)
forall a. Int -> a -> IntMap a
M.singleton (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) (elt -> Int -> TaggedVal elt
forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
0)) Int
1
addToUDFM :: Uniquable key => UniqDFM elt -> key -> elt -> UniqDFM elt
addToUDFM :: UniqDFM elt -> key -> elt -> UniqDFM elt
addToUDFM UniqDFM elt
m key
k elt
v = UniqDFM elt -> Unique -> elt -> UniqDFM elt
forall elt. UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly UniqDFM elt
m (key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) elt
v
addToUDFM_Directly :: UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly :: UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly (UDFM IntMap (TaggedVal elt)
m Int
i) Unique
u elt
v
= IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((TaggedVal elt -> TaggedVal elt -> TaggedVal elt)
-> Int
-> TaggedVal elt
-> IntMap (TaggedVal elt)
-> IntMap (TaggedVal elt)
forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
M.insertWith TaggedVal elt -> TaggedVal elt -> TaggedVal elt
forall val val. TaggedVal val -> TaggedVal val -> TaggedVal val
tf (Unique -> Int
getKey Unique
u) (elt -> Int -> TaggedVal elt
forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
i) IntMap (TaggedVal elt)
m) (Int
i Int -> Int -> Int
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) = val -> Int -> TaggedVal val
forall val. val -> Int -> TaggedVal val
TaggedVal val
new_v Int
old_i
addToUDFM_Directly_C
:: (elt -> elt -> elt)
-> UniqDFM elt
-> Unique -> elt
-> UniqDFM elt
addToUDFM_Directly_C :: (elt -> elt -> elt) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly_C elt -> elt -> elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) Unique
u elt
v
= IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((TaggedVal elt -> TaggedVal elt -> TaggedVal elt)
-> Int
-> TaggedVal elt
-> IntMap (TaggedVal elt)
-> IntMap (TaggedVal elt)
forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
M.insertWith TaggedVal elt -> TaggedVal elt -> TaggedVal elt
tf (Unique -> Int
getKey Unique
u) (elt -> Int -> TaggedVal elt
forall val. val -> Int -> TaggedVal val
TaggedVal elt
v Int
i) IntMap (TaggedVal elt)
m) (Int
i Int -> Int -> Int
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)
= elt -> Int -> TaggedVal elt
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 elt
-> key -> elt
-> UniqDFM elt
addToUDFM_C :: (elt -> elt -> elt) -> UniqDFM elt -> key -> elt -> UniqDFM elt
addToUDFM_C elt -> elt -> elt
f UniqDFM elt
m key
k elt
v = (elt -> elt -> elt) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
forall elt.
(elt -> elt -> elt) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly_C elt -> elt -> elt
f UniqDFM elt
m (key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) elt
v
addListToUDFM :: Uniquable key => UniqDFM elt -> [(key,elt)] -> UniqDFM elt
addListToUDFM :: UniqDFM elt -> [(key, elt)] -> UniqDFM elt
addListToUDFM = (UniqDFM elt -> (key, elt) -> UniqDFM elt)
-> UniqDFM elt -> [(key, elt)] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM elt
m (key
k, elt
v) -> UniqDFM elt -> key -> elt -> UniqDFM elt
forall key elt.
Uniquable key =>
UniqDFM elt -> key -> elt -> UniqDFM elt
addToUDFM UniqDFM elt
m key
k elt
v)
addListToUDFM_Directly :: UniqDFM elt -> [(Unique,elt)] -> UniqDFM elt
addListToUDFM_Directly :: UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
addListToUDFM_Directly = (UniqDFM elt -> (Unique, elt) -> UniqDFM elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM elt
m (Unique
k, elt
v) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
forall elt. UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly UniqDFM elt
m Unique
k elt
v)
addListToUDFM_Directly_C
:: (elt -> elt -> elt) -> UniqDFM elt -> [(Unique,elt)] -> UniqDFM elt
addListToUDFM_Directly_C :: (elt -> elt -> elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
addListToUDFM_Directly_C elt -> elt -> elt
f = (UniqDFM elt -> (Unique, elt) -> UniqDFM elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM elt
m (Unique
k, elt
v) -> (elt -> elt -> elt) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
forall elt.
(elt -> elt -> elt) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly_C elt -> elt -> elt
f UniqDFM elt
m Unique
k elt
v)
delFromUDFM :: Uniquable key => UniqDFM elt -> key -> UniqDFM elt
delFromUDFM :: UniqDFM elt -> key -> UniqDFM elt
delFromUDFM (UDFM IntMap (TaggedVal elt)
m Int
i) key
k = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (Int -> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a. Int -> IntMap a -> IntMap a
M.delete (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) Int
i
plusUDFM_C :: (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
plusUDFM_C :: (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
plusUDFM_C elt -> elt -> elt
f udfml :: UniqDFM elt
udfml@(UDFM IntMap (TaggedVal elt)
_ Int
i) udfmr :: UniqDFM elt
udfmr@(UDFM IntMap (TaggedVal elt)
_ Int
j)
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
j = (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
forall elt.
(elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM elt
udfml UniqDFM elt
udfmr
| Bool
otherwise = (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
forall elt.
(elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM elt
udfmr UniqDFM elt
udfml
plusUDFM :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
plusUDFM :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
plusUDFM udfml :: UniqDFM elt
udfml@(UDFM IntMap (TaggedVal elt)
_ Int
i) udfmr :: UniqDFM elt
udfmr@(UDFM IntMap (TaggedVal elt)
_ Int
j)
| Int
i Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
j = UniqDFM elt -> UniqDFM elt -> UniqDFM elt
forall elt. UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft UniqDFM elt
udfml UniqDFM elt
udfmr
| Bool
otherwise = UniqDFM elt -> UniqDFM elt -> UniqDFM elt
forall elt. UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft UniqDFM elt
udfmr UniqDFM elt
udfml
insertUDFMIntoLeft :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft UniqDFM elt
udfml UniqDFM elt
udfmr = UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
forall elt. UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
addListToUDFM_Directly UniqDFM elt
udfml ([(Unique, elt)] -> UniqDFM elt) -> [(Unique, elt)] -> UniqDFM elt
forall a b. (a -> b) -> a -> b
$ UniqDFM elt -> [(Unique, elt)]
forall elt. UniqDFM elt -> [(Unique, elt)]
udfmToList UniqDFM elt
udfmr
insertUDFMIntoLeft_C
:: (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft_C :: (elt -> elt -> elt) -> UniqDFM elt -> UniqDFM elt -> UniqDFM elt
insertUDFMIntoLeft_C elt -> elt -> elt
f UniqDFM elt
udfml UniqDFM elt
udfmr =
(elt -> elt -> elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
forall elt.
(elt -> elt -> elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
addListToUDFM_Directly_C elt -> elt -> elt
f UniqDFM elt
udfml ([(Unique, elt)] -> UniqDFM elt) -> [(Unique, elt)] -> UniqDFM elt
forall a b. (a -> b) -> a -> b
$ UniqDFM elt -> [(Unique, elt)]
forall elt. UniqDFM elt -> [(Unique, elt)]
udfmToList UniqDFM elt
udfmr
lookupUDFM :: Uniquable key => UniqDFM elt -> key -> Maybe elt
lookupUDFM :: UniqDFM elt -> key -> Maybe elt
lookupUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) key
k = TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst (TaggedVal elt -> elt) -> Maybe (TaggedVal elt) -> Maybe elt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Int -> IntMap (TaggedVal elt) -> Maybe (TaggedVal elt)
forall a. Int -> IntMap a -> Maybe a
M.lookup (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m
lookupUDFM_Directly :: UniqDFM elt -> Unique -> Maybe elt
lookupUDFM_Directly :: UniqDFM elt -> Unique -> Maybe elt
lookupUDFM_Directly (UDFM IntMap (TaggedVal elt)
m Int
_i) Unique
k = TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst (TaggedVal elt -> elt) -> Maybe (TaggedVal elt) -> Maybe elt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Int -> IntMap (TaggedVal elt) -> Maybe (TaggedVal elt)
forall a. Int -> IntMap a -> Maybe a
M.lookup (Unique -> Int
getKey Unique
k) IntMap (TaggedVal elt)
m
elemUDFM :: Uniquable key => key -> UniqDFM elt -> Bool
elemUDFM :: key -> UniqDFM elt -> Bool
elemUDFM key
k (UDFM IntMap (TaggedVal elt)
m Int
_i) = Int -> IntMap (TaggedVal elt) -> Bool
forall a. Int -> IntMap a -> Bool
M.member (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m
foldUDFM :: (elt -> a -> a) -> a -> UniqDFM elt -> a
foldUDFM :: (elt -> a -> a) -> a -> UniqDFM elt -> a
foldUDFM elt -> a -> a
k a
z UniqDFM elt
m = (elt -> a -> a) -> a -> [elt] -> a
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr elt -> a -> a
k a
z (UniqDFM elt -> [elt]
forall a. UniqDFM a -> [a]
eltsUDFM UniqDFM elt
m)
nonDetFoldUDFM :: (elt -> a -> a) -> a -> UniqDFM elt -> a
nonDetFoldUDFM :: (elt -> a -> a) -> a -> UniqDFM elt -> a
nonDetFoldUDFM elt -> a -> a
k a
z (UDFM IntMap (TaggedVal elt)
m Int
_i) = (elt -> a -> a) -> a -> [elt] -> a
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr elt -> a -> a
k a
z ([elt] -> a) -> [elt] -> a
forall a b. (a -> b) -> a -> b
$ (TaggedVal elt -> elt) -> [TaggedVal elt] -> [elt]
forall a b. (a -> b) -> [a] -> [b]
map TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst ([TaggedVal elt] -> [elt]) -> [TaggedVal elt] -> [elt]
forall a b. (a -> b) -> a -> b
$ IntMap (TaggedVal elt) -> [TaggedVal elt]
forall a. IntMap a -> [a]
M.elems IntMap (TaggedVal elt)
m
eltsUDFM :: UniqDFM elt -> [elt]
eltsUDFM :: UniqDFM elt -> [elt]
eltsUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) =
(TaggedVal elt -> elt) -> [TaggedVal elt] -> [elt]
forall a b. (a -> b) -> [a] -> [b]
map TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst ([TaggedVal elt] -> [elt]) -> [TaggedVal elt] -> [elt]
forall a b. (a -> b) -> a -> b
$ (TaggedVal elt -> TaggedVal elt -> Ordering)
-> [TaggedVal elt] -> [TaggedVal elt]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Int -> Int -> Ordering)
-> (TaggedVal elt -> Int)
-> TaggedVal elt
-> TaggedVal elt
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` TaggedVal elt -> Int
forall val. TaggedVal val -> Int
taggedSnd) ([TaggedVal elt] -> [TaggedVal elt])
-> [TaggedVal elt] -> [TaggedVal elt]
forall a b. (a -> b) -> a -> b
$ IntMap (TaggedVal elt) -> [TaggedVal elt]
forall a. IntMap a -> [a]
M.elems IntMap (TaggedVal elt)
m
filterUDFM :: (elt -> Bool) -> UniqDFM elt -> UniqDFM elt
filterUDFM :: (elt -> Bool) -> UniqDFM elt -> UniqDFM elt
filterUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((TaggedVal elt -> Bool)
-> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
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 elt -> UniqDFM elt
filterUDFM_Directly :: (Unique -> elt -> Bool) -> UniqDFM elt -> UniqDFM elt
filterUDFM_Directly Unique -> elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((Int -> TaggedVal elt -> Bool)
-> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a. (Int -> a -> Bool) -> IntMap a -> IntMap a
M.filterWithKey Int -> TaggedVal elt -> Bool
forall a. Uniquable a => a -> TaggedVal elt -> Bool
p' IntMap (TaggedVal elt)
m) Int
i
where
p' :: a -> TaggedVal elt -> Bool
p' a
k (TaggedVal elt
v Int
_) = Unique -> elt -> Bool
p (a -> Unique
forall a. Uniquable a => a -> Unique
getUnique a
k) elt
v
udfmToList :: UniqDFM elt -> [(Unique, elt)]
udfmToList :: UniqDFM elt -> [(Unique, elt)]
udfmToList (UDFM IntMap (TaggedVal elt)
m Int
_i) =
[ (Int -> Unique
forall a. Uniquable a => a -> Unique
getUnique Int
k, TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst TaggedVal elt
v)
| (Int
k, TaggedVal elt
v) <- ((Int, TaggedVal elt) -> (Int, TaggedVal elt) -> Ordering)
-> [(Int, TaggedVal elt)] -> [(Int, TaggedVal elt)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Int -> Int -> Ordering)
-> ((Int, TaggedVal elt) -> Int)
-> (Int, TaggedVal elt)
-> (Int, TaggedVal elt)
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (TaggedVal elt -> Int
forall val. TaggedVal val -> Int
taggedSnd (TaggedVal elt -> Int)
-> ((Int, TaggedVal elt) -> TaggedVal elt)
-> (Int, TaggedVal elt)
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, TaggedVal elt) -> TaggedVal elt
forall a b. (a, b) -> b
snd)) ([(Int, TaggedVal elt)] -> [(Int, TaggedVal elt)])
-> [(Int, TaggedVal elt)] -> [(Int, TaggedVal elt)]
forall a b. (a -> b) -> a -> b
$ IntMap (TaggedVal elt) -> [(Int, TaggedVal elt)]
forall a. IntMap a -> [(Int, a)]
M.toList IntMap (TaggedVal elt)
m ]
equalKeysUDFM :: UniqDFM a -> UniqDFM b -> Bool
equalKeysUDFM :: UniqDFM a -> UniqDFM b -> Bool
equalKeysUDFM (UDFM IntMap (TaggedVal a)
m1 Int
_) (UDFM IntMap (TaggedVal b)
m2 Int
_) = (TaggedVal a -> TaggedVal b -> Bool)
-> IntMap (TaggedVal a) -> IntMap (TaggedVal b) -> Bool
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 elt -> Bool
isNullUDFM :: UniqDFM elt -> Bool
isNullUDFM (UDFM IntMap (TaggedVal elt)
m Int
_) = IntMap (TaggedVal elt) -> Bool
forall a. IntMap a -> Bool
M.null IntMap (TaggedVal elt)
m
sizeUDFM :: UniqDFM elt -> Int
sizeUDFM :: UniqDFM elt -> Int
sizeUDFM (UDFM IntMap (TaggedVal elt)
m Int
_i) = IntMap (TaggedVal elt) -> Int
forall a. IntMap a -> Int
M.size IntMap (TaggedVal elt)
m
intersectUDFM :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
intersectUDFM :: UniqDFM elt -> UniqDFM elt -> UniqDFM elt
intersectUDFM (UDFM IntMap (TaggedVal elt)
x Int
i) (UDFM IntMap (TaggedVal elt)
y Int
_j) = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (IntMap (TaggedVal elt)
-> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt)
x IntMap (TaggedVal elt)
y) Int
i
udfmIntersectUFM :: UniqDFM elt1 -> UniqFM elt2 -> UniqDFM elt1
udfmIntersectUFM :: UniqDFM elt1 -> UniqFM elt2 -> UniqDFM elt1
udfmIntersectUFM (UDFM IntMap (TaggedVal elt1)
x Int
i) UniqFM elt2
y = IntMap (TaggedVal elt1) -> Int -> UniqDFM elt1
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (IntMap (TaggedVal elt1) -> IntMap elt2 -> IntMap (TaggedVal elt1)
forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt1)
x (UniqFM elt2 -> IntMap elt2
forall elt. UniqFM elt -> IntMap elt
ufmToIntMap UniqFM elt2
y)) Int
i
intersectsUDFM :: UniqDFM elt -> UniqDFM elt -> Bool
intersectsUDFM :: UniqDFM elt -> UniqDFM elt -> Bool
intersectsUDFM UniqDFM elt
x UniqDFM elt
y = UniqDFM elt -> Bool
forall a. UniqDFM a -> Bool
isNullUDFM (UniqDFM elt
x UniqDFM elt -> UniqDFM elt -> UniqDFM elt
forall elt. UniqDFM elt -> UniqDFM elt -> UniqDFM elt
`intersectUDFM` UniqDFM elt
y)
disjointUDFM :: UniqDFM elt -> UniqDFM elt -> Bool
disjointUDFM :: UniqDFM elt -> UniqDFM elt -> Bool
disjointUDFM (UDFM IntMap (TaggedVal elt)
x Int
_i) (UDFM IntMap (TaggedVal elt)
y Int
_j) = IntMap (TaggedVal elt) -> Bool
forall a. IntMap a -> Bool
M.null (IntMap (TaggedVal elt)
-> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt)
x IntMap (TaggedVal elt)
y)
disjointUdfmUfm :: UniqDFM elt -> UniqFM elt2 -> Bool
disjointUdfmUfm :: UniqDFM elt -> UniqFM elt2 -> Bool
disjointUdfmUfm (UDFM IntMap (TaggedVal elt)
x Int
_i) UniqFM elt2
y = IntMap (TaggedVal elt) -> Bool
forall a. IntMap a -> Bool
M.null (IntMap (TaggedVal elt) -> IntMap elt2 -> IntMap (TaggedVal elt)
forall a b. IntMap a -> IntMap b -> IntMap a
M.intersection IntMap (TaggedVal elt)
x (UniqFM elt2 -> IntMap elt2
forall elt. UniqFM elt -> IntMap elt
ufmToIntMap UniqFM elt2
y))
minusUDFM :: UniqDFM elt1 -> UniqDFM elt2 -> UniqDFM elt1
minusUDFM :: UniqDFM elt1 -> UniqDFM elt2 -> UniqDFM elt1
minusUDFM (UDFM IntMap (TaggedVal elt1)
x Int
i) (UDFM IntMap (TaggedVal elt2)
y Int
_j) = IntMap (TaggedVal elt1) -> Int -> UniqDFM elt1
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (IntMap (TaggedVal elt1)
-> IntMap (TaggedVal elt2) -> IntMap (TaggedVal elt1)
forall a b. IntMap a -> IntMap b -> IntMap a
M.difference IntMap (TaggedVal elt1)
x IntMap (TaggedVal elt2)
y) Int
i
udfmMinusUFM :: UniqDFM elt1 -> UniqFM elt2 -> UniqDFM elt1
udfmMinusUFM :: UniqDFM elt1 -> UniqFM elt2 -> UniqDFM elt1
udfmMinusUFM (UDFM IntMap (TaggedVal elt1)
x Int
i) UniqFM elt2
y = IntMap (TaggedVal elt1) -> Int -> UniqDFM elt1
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM (IntMap (TaggedVal elt1) -> IntMap elt2 -> IntMap (TaggedVal elt1)
forall a b. IntMap a -> IntMap b -> IntMap a
M.difference IntMap (TaggedVal elt1)
x (UniqFM elt2 -> IntMap elt2
forall elt. UniqFM elt -> IntMap elt
ufmToIntMap UniqFM elt2
y)) Int
i
partitionUDFM :: (elt -> Bool) -> UniqDFM elt -> (UniqDFM elt, UniqDFM elt)
partitionUDFM :: (elt -> Bool) -> UniqDFM elt -> (UniqDFM elt, UniqDFM elt)
partitionUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
i) =
case (TaggedVal elt -> Bool)
-> IntMap (TaggedVal elt)
-> (IntMap (TaggedVal elt), IntMap (TaggedVal elt))
forall a. (a -> Bool) -> IntMap a -> (IntMap a, IntMap a)
M.partition (elt -> Bool
p (elt -> Bool) -> (TaggedVal elt -> elt) -> TaggedVal elt -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst) IntMap (TaggedVal elt)
m of
(IntMap (TaggedVal elt)
left, IntMap (TaggedVal elt)
right) -> (IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM IntMap (TaggedVal elt)
left Int
i, IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM IntMap (TaggedVal elt)
right Int
i)
delListFromUDFM :: Uniquable key => UniqDFM elt -> [key] -> UniqDFM elt
delListFromUDFM :: UniqDFM elt -> [key] -> UniqDFM elt
delListFromUDFM = (UniqDFM elt -> key -> UniqDFM elt)
-> UniqDFM elt -> [key] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' UniqDFM elt -> key -> UniqDFM elt
forall key elt. Uniquable key => UniqDFM elt -> key -> UniqDFM elt
delFromUDFM
udfmToUfm :: UniqDFM elt -> UniqFM elt
udfmToUfm :: UniqDFM elt -> UniqFM elt
udfmToUfm (UDFM IntMap (TaggedVal elt)
m Int
_i) =
[(Unique, elt)] -> UniqFM elt
forall elt. [(Unique, elt)] -> UniqFM elt
listToUFM_Directly [(Int -> Unique
forall a. Uniquable a => a -> Unique
getUnique Int
k, TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst TaggedVal elt
tv) | (Int
k, TaggedVal elt
tv) <- IntMap (TaggedVal elt) -> [(Int, TaggedVal elt)]
forall a. IntMap a -> [(Int, a)]
M.toList IntMap (TaggedVal elt)
m]
listToUDFM :: Uniquable key => [(key,elt)] -> UniqDFM elt
listToUDFM :: [(key, elt)] -> UniqDFM elt
listToUDFM = (UniqDFM elt -> (key, elt) -> UniqDFM elt)
-> UniqDFM elt -> [(key, elt)] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM elt
m (key
k, elt
v) -> UniqDFM elt -> key -> elt -> UniqDFM elt
forall key elt.
Uniquable key =>
UniqDFM elt -> key -> elt -> UniqDFM elt
addToUDFM UniqDFM elt
m key
k elt
v) UniqDFM elt
forall elt. UniqDFM elt
emptyUDFM
listToUDFM_Directly :: [(Unique, elt)] -> UniqDFM elt
listToUDFM_Directly :: [(Unique, elt)] -> UniqDFM elt
listToUDFM_Directly = (UniqDFM elt -> (Unique, elt) -> UniqDFM elt)
-> UniqDFM elt -> [(Unique, elt)] -> UniqDFM elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\UniqDFM elt
m (Unique
u, elt
v) -> UniqDFM elt -> Unique -> elt -> UniqDFM elt
forall elt. UniqDFM elt -> Unique -> elt -> UniqDFM elt
addToUDFM_Directly UniqDFM elt
m Unique
u elt
v) UniqDFM elt
forall elt. UniqDFM elt
emptyUDFM
adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM elt -> key -> UniqDFM elt
adjustUDFM :: (elt -> elt) -> UniqDFM elt -> key -> UniqDFM elt
adjustUDFM elt -> elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) key
k = IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((TaggedVal elt -> TaggedVal elt)
-> Int -> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a. (a -> a) -> Int -> IntMap a -> IntMap a
M.adjust ((elt -> elt) -> TaggedVal elt -> TaggedVal elt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap elt -> elt
f) (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) Int
i
alterUDFM
:: Uniquable key
=> (Maybe elt -> Maybe elt)
-> UniqDFM elt
-> key
-> UniqDFM elt
alterUDFM :: (Maybe elt -> Maybe elt) -> UniqDFM elt -> key -> UniqDFM elt
alterUDFM Maybe elt -> Maybe elt
f (UDFM IntMap (TaggedVal elt)
m Int
i) key
k =
IntMap (TaggedVal elt) -> Int -> UniqDFM elt
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((Maybe (TaggedVal elt) -> Maybe (TaggedVal elt))
-> Int -> IntMap (TaggedVal elt) -> IntMap (TaggedVal elt)
forall a. (Maybe a -> Maybe a) -> Int -> IntMap a -> IntMap a
M.alter Maybe (TaggedVal elt) -> Maybe (TaggedVal elt)
alterf (Unique -> Int
getKey (Unique -> Int) -> Unique -> Int
forall a b. (a -> b) -> a -> b
$ key -> Unique
forall a. Uniquable a => a -> Unique
getUnique key
k) IntMap (TaggedVal elt)
m) (Int
i Int -> Int -> Int
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)
forall val. Maybe val -> Maybe (TaggedVal val)
inject (Maybe elt -> Maybe (TaggedVal elt))
-> Maybe elt -> Maybe (TaggedVal elt)
forall a b. (a -> b) -> a -> b
$ Maybe elt -> Maybe elt
f Maybe elt
forall a. Maybe a
Nothing
alterf (Just (TaggedVal elt
v Int
_)) = Maybe elt -> Maybe (TaggedVal elt)
forall val. Maybe val -> Maybe (TaggedVal val)
inject (Maybe elt -> Maybe (TaggedVal elt))
-> Maybe elt -> Maybe (TaggedVal elt)
forall a b. (a -> b) -> a -> b
$ Maybe elt -> Maybe elt
f (elt -> Maybe elt
forall a. a -> Maybe a
Just elt
v)
inject :: Maybe val -> Maybe (TaggedVal val)
inject Maybe val
Nothing = Maybe (TaggedVal val)
forall a. Maybe a
Nothing
inject (Just val
v) = TaggedVal val -> Maybe (TaggedVal val)
forall a. a -> Maybe a
Just (TaggedVal val -> Maybe (TaggedVal val))
-> TaggedVal val -> Maybe (TaggedVal val)
forall a b. (a -> b) -> a -> b
$ val -> Int -> TaggedVal val
forall val. val -> Int -> TaggedVal val
TaggedVal val
v Int
i
mapUDFM :: (elt1 -> elt2) -> UniqDFM elt1 -> UniqDFM elt2
mapUDFM :: (elt1 -> elt2) -> UniqDFM elt1 -> UniqDFM elt2
mapUDFM elt1 -> elt2
f (UDFM IntMap (TaggedVal elt1)
m Int
i) = IntMap (TaggedVal elt2) -> Int -> UniqDFM elt2
forall ele. IntMap (TaggedVal ele) -> Int -> UniqDFM ele
UDFM ((TaggedVal elt1 -> TaggedVal elt2)
-> IntMap (TaggedVal elt1) -> IntMap (TaggedVal elt2)
forall a b. (a -> b) -> IntMap a -> IntMap b
M.map ((elt1 -> elt2) -> TaggedVal elt1 -> TaggedVal elt2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap elt1 -> elt2
f) IntMap (TaggedVal elt1)
m) Int
i
anyUDFM :: (elt -> Bool) -> UniqDFM elt -> Bool
anyUDFM :: (elt -> Bool) -> UniqDFM elt -> Bool
anyUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
_i) = (TaggedVal elt -> Bool -> Bool)
-> Bool -> IntMap (TaggedVal elt) -> Bool
forall a b. (a -> b -> b) -> b -> IntMap a -> b
M.foldr (Bool -> Bool -> Bool
(||) (Bool -> Bool -> Bool)
-> (TaggedVal elt -> Bool) -> TaggedVal elt -> Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. elt -> Bool
p (elt -> Bool) -> (TaggedVal elt -> elt) -> TaggedVal elt -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst) Bool
False IntMap (TaggedVal elt)
m
allUDFM :: (elt -> Bool) -> UniqDFM elt -> Bool
allUDFM :: (elt -> Bool) -> UniqDFM elt -> Bool
allUDFM elt -> Bool
p (UDFM IntMap (TaggedVal elt)
m Int
_i) = (TaggedVal elt -> Bool -> Bool)
-> Bool -> IntMap (TaggedVal elt) -> Bool
forall a b. (a -> b -> b) -> b -> IntMap a -> b
M.foldr (Bool -> Bool -> Bool
(&&) (Bool -> Bool -> Bool)
-> (TaggedVal elt -> Bool) -> TaggedVal elt -> Bool -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. elt -> Bool
p (elt -> Bool) -> (TaggedVal elt -> elt) -> TaggedVal elt -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TaggedVal elt -> elt
forall val. TaggedVal val -> val
taggedFst) Bool
True IntMap (TaggedVal elt)
m
instance Semi.Semigroup (UniqDFM a) where
<> :: UniqDFM a -> UniqDFM a -> UniqDFM a
(<>) = UniqDFM a -> UniqDFM a -> UniqDFM a
forall elt. UniqDFM elt -> UniqDFM elt -> UniqDFM elt
plusUDFM
instance Monoid (UniqDFM a) where
mempty :: UniqDFM a
mempty = UniqDFM a
forall elt. UniqDFM elt
emptyUDFM
mappend :: UniqDFM a -> UniqDFM a -> UniqDFM a
mappend = UniqDFM a -> UniqDFM a -> UniqDFM a
forall a. Semigroup a => a -> a -> a
(Semi.<>)
alwaysUnsafeUfmToUdfm :: UniqFM elt -> UniqDFM elt
alwaysUnsafeUfmToUdfm :: UniqFM elt -> UniqDFM elt
alwaysUnsafeUfmToUdfm = [(Unique, elt)] -> UniqDFM elt
forall elt. [(Unique, elt)] -> UniqDFM elt
listToUDFM_Directly ([(Unique, elt)] -> UniqDFM elt)
-> (UniqFM elt -> [(Unique, elt)]) -> UniqFM elt -> UniqDFM elt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UniqFM elt -> [(Unique, elt)]
forall elt. UniqFM elt -> [(Unique, elt)]
nonDetUFMToList
instance Outputable a => Outputable (UniqDFM a) where
ppr :: UniqDFM a -> SDoc
ppr UniqDFM a
ufm = (a -> SDoc) -> UniqDFM a -> SDoc
forall a. (a -> SDoc) -> UniqDFM a -> SDoc
pprUniqDFM a -> SDoc
forall a. Outputable a => a -> SDoc
ppr UniqDFM a
ufm
pprUniqDFM :: (a -> SDoc) -> UniqDFM a -> SDoc
pprUniqDFM :: (a -> SDoc) -> UniqDFM a -> SDoc
pprUniqDFM a -> SDoc
ppr_elt UniqDFM a
ufm
= SDoc -> SDoc
brackets (SDoc -> SDoc) -> SDoc -> SDoc
forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
fsep ([SDoc] -> SDoc) -> [SDoc] -> SDoc
forall a b. (a -> b) -> a -> b
$ SDoc -> [SDoc] -> [SDoc]
punctuate SDoc
comma ([SDoc] -> [SDoc]) -> [SDoc] -> [SDoc]
forall a b. (a -> b) -> a -> b
$
[ Unique -> SDoc
forall a. Outputable a => a -> SDoc
ppr Unique
uq SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
":->" SDoc -> SDoc -> SDoc
<+> a -> SDoc
ppr_elt a
elt
| (Unique
uq, a
elt) <- UniqDFM a -> [(Unique, a)]
forall elt. UniqDFM elt -> [(Unique, elt)]
udfmToList UniqDFM a
ufm ]
pprUDFM :: UniqDFM a
-> ([a] -> SDoc)
-> SDoc
pprUDFM :: UniqDFM a -> ([a] -> SDoc) -> SDoc
pprUDFM UniqDFM a
ufm [a] -> SDoc
pp = [a] -> SDoc
pp (UniqDFM a -> [a]
forall a. UniqDFM a -> [a]
eltsUDFM UniqDFM a
ufm)