ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Unique.DFM

Contents

- Unique-keyed deterministic mappings
  - Manipulating those mappings

Synopsis

- data UniqDFM (key :: k) ele
- emptyUDFM :: forall {k} (key :: k) elt. UniqDFM key elt
- unitUDFM :: Uniquable key => key -> elt -> UniqDFM key elt
- addToUDFM :: Uniquable key => UniqDFM key elt -> key -> elt -> UniqDFM key elt
- addToUDFM_C :: Uniquable key => (elt -> elt -> elt) -> UniqDFM key elt -> key -> elt -> UniqDFM key elt
- addToUDFM_C_Directly :: forall {k} elt (key :: k). (elt -> elt -> elt) -> UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
- addToUDFM_Directly :: forall {k} (key :: k) elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt
- addListToUDFM :: Uniquable key => UniqDFM key elt -> [(key, elt)] -> UniqDFM key elt
- delFromUDFM :: Uniquable key => UniqDFM key elt -> key -> UniqDFM key elt
- delListFromUDFM :: Uniquable key => UniqDFM key elt -> [key] -> UniqDFM key elt
- adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM key elt -> key -> UniqDFM key elt
- adjustUDFM_Directly :: forall {k} elt (key :: k). (elt -> elt) -> UniqDFM key elt -> Unique -> UniqDFM key elt
- alterUDFM :: Uniquable key => (Maybe elt -> Maybe elt) -> UniqDFM key elt -> key -> UniqDFM key elt
- mapUDFM :: forall {k} elt1 elt2 (key :: k). (elt1 -> elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
- mapMaybeUDFM :: forall {k} elt1 elt2 (key :: k). (elt1 -> Maybe elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
- mapMUDFM :: forall {k} m elt1 elt2 (key :: k). Monad m => (elt1 -> m elt2) -> UniqDFM key elt1 -> m (UniqDFM key elt2)
- plusUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
- plusUDFM_C :: forall {k} elt (key :: k). (elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
- plusUDFM_CK :: forall {k} elt (key :: k). (Unique -> elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
- lookupUDFM :: Uniquable key => UniqDFM key elt -> key -> Maybe elt
- lookupUDFM_Directly :: forall {k} (key :: k) elt. UniqDFM key elt -> Unique -> Maybe elt
- elemUDFM :: Uniquable key => key -> UniqDFM key elt -> Bool
- foldUDFM :: forall {k} elt a (key :: k). (elt -> a -> a) -> a -> UniqDFM key elt -> a
- foldWithKeyUDFM :: forall {k} elt a (key :: k). (Unique -> elt -> a -> a) -> a -> UniqDFM key elt -> a
- eltsUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> [elt]
- filterUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
- filterUDFM_Directly :: forall {k} elt (key :: k). (Unique -> elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt
- isNullUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> Bool
- sizeUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> Int
- intersectUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt
- udfmIntersectUFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
- disjointUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> Bool
- disjointUdfmUfm :: forall {k} (key :: k) elt elt2. UniqDFM key elt -> UniqFM key elt2 -> Bool
- equalKeysUDFM :: forall {k} (key :: k) a b. UniqDFM key a -> UniqDFM key b -> Bool
- minusUDFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqDFM key elt2 -> UniqDFM key elt1
- listToUDFM :: Uniquable key => [(key, elt)] -> UniqDFM key elt
- listToUDFM_Directly :: forall {k} elt (key :: k). [(Unique, elt)] -> UniqDFM key elt
- listToUDFM_C_Directly :: forall {k} elt (key :: k). (elt -> elt -> elt) -> [(Unique, elt)] -> UniqDFM key elt
- udfmMinusUFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1
- ufmMinusUDFM :: forall {k} (key :: k) elt1 elt2. UniqFM key elt1 -> UniqDFM key elt2 -> UniqFM key elt1
- partitionUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> (UniqDFM key elt, UniqDFM key elt)
- udfmRestrictKeys :: forall {k} (key :: k) elt elt2. UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt
- udfmRestrictKeysSet :: forall {k} (key :: k) elt. UniqDFM key elt -> Word64Set -> UniqDFM key elt
- anyUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> Bool
- allUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> Bool
- pprUniqDFM :: forall {k} a (key :: k). (a -> SDoc) -> UniqDFM key a -> SDoc
- pprUDFM :: forall {k} (key :: k) a. UniqDFM key a -> ([a] -> SDoc) -> SDoc
- udfmToList :: forall {k} (key :: k) elt. UniqDFM key elt -> [(Unique, elt)]
- udfmToUfm :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqFM key elt
- nonDetStrictFoldUDFM :: forall {k} elt a (key :: k). (elt -> a -> a) -> a -> UniqDFM key elt -> a
- unsafeCastUDFMKey :: forall {k1} {k2} (key1 :: k1) elt (key2 :: k2). UniqDFM key1 elt -> UniqDFM key2 elt
- alwaysUnsafeUfmToUdfm :: forall {k} (key :: k) elt. UniqFM key elt -> UniqDFM key elt

# Unique-keyed deterministic mappings

data UniqDFM (key :: k) ele #

Type of unique deterministic finite maps

The key is just here to keep us honest. It's always safe to use a single type as key. If two types don't overlap in their uniques it's also safe to index the same map at multiple key types. But this is very much discouraged.

#### Instances

Instances details

Functor (UniqDFM key) # |
Instance details Defined in GHC.Types.Unique.DFM Methods fmap :: (a -> b) -> UniqDFM key a -> UniqDFM key b # (<$) :: a -> UniqDFM key b -> UniqDFM key a #
Foldable (UniqDFM key) # | Deterministic, in O(n log n).
Instance details Defined in GHC.Types.Unique.DFM Methods fold :: Monoid m => UniqDFM key m -> m # foldMap :: Monoid m => (a -> m) -> UniqDFM key a -> m # foldMap' :: Monoid m => (a -> m) -> UniqDFM key a -> m # foldr :: (a -> b -> b) -> b -> UniqDFM key a -> b # foldr' :: (a -> b -> b) -> b -> UniqDFM key a -> b # foldl :: (b -> a -> b) -> b -> UniqDFM key a -> b # foldl' :: (b -> a -> b) -> b -> UniqDFM key a -> b # foldr1 :: (a -> a -> a) -> UniqDFM key a -> a # foldl1 :: (a -> a -> a) -> UniqDFM key a -> a # toList :: UniqDFM key a -> [a] # null :: UniqDFM key a -> Bool # length :: UniqDFM key a -> Int # elem :: Eq a => a -> UniqDFM key a -> Bool # maximum :: Ord a => UniqDFM key a -> a # minimum :: Ord a => UniqDFM key a -> a # sum :: Num a => UniqDFM key a -> a # product :: Num a => UniqDFM key a -> a #
Traversable (UniqDFM key) # | Deterministic, in O(n log n).
Instance details Defined in GHC.Types.Unique.DFM Methods traverse :: Applicative f => (a -> f b) -> UniqDFM key a -> f (UniqDFM key b) # sequenceA :: Applicative f => UniqDFM key (f a) -> f (UniqDFM key a) # mapM :: Monad m => (a -> m b) -> UniqDFM key a -> m (UniqDFM key b) # sequence :: Monad m => UniqDFM key (m a) -> m (UniqDFM key a) #
Uniquable key => TrieMap (UniqDFM key) # |
Instance details Defined in GHC.Data.TrieMap Associated Types
type Key (UniqDFM key) |
Instance details Defined in GHC.Data.TrieMap type Key (UniqDFM key) = key
Methods emptyTM :: UniqDFM key a # lookupTM :: Key (UniqDFM key) -> UniqDFM key b -> Maybe b # alterTM :: Key (UniqDFM key) -> XT b -> UniqDFM key b -> UniqDFM key b # filterTM :: (a -> Bool) -> UniqDFM key a -> UniqDFM key a # mapMaybeTM :: (a -> Maybe b) -> UniqDFM key a -> UniqDFM key b # foldTM :: (a -> b -> b) -> UniqDFM key a -> b -> b #
(Typeable key, Typeable k, Data ele) => Data (UniqDFM key ele) # |
Instance details Defined in GHC.Types.Unique.DFM Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UniqDFM key ele -> c (UniqDFM key ele) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (UniqDFM key ele) # toConstr :: UniqDFM key ele -> Constr # dataTypeOf :: UniqDFM key ele -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (UniqDFM key ele)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (UniqDFM key ele)) # gmapT :: (forall b. Data b => b -> b) -> UniqDFM key ele -> UniqDFM key ele # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UniqDFM key ele -> r # gmapQ :: (forall d. Data d => d -> u) -> UniqDFM key ele -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UniqDFM key ele -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UniqDFM key ele -> m (UniqDFM key ele) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UniqDFM key ele -> m (UniqDFM key ele) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UniqDFM key ele -> m (UniqDFM key ele) #
Outputable a => Outputable (UniqDFM key a) # |
Instance details Defined in GHC.Types.Unique.DFM Methods ppr :: UniqDFM key a -> SDoc #
type Key (UniqDFM key) # |
Instance details Defined in GHC.Data.TrieMap type Key (UniqDFM key) = key

## Manipulating those mappings

emptyUDFM :: forall {k} (key :: k) elt. UniqDFM key elt #

unitUDFM :: Uniquable key => key -> elt -> UniqDFM key elt #

addToUDFM :: Uniquable key => UniqDFM key elt -> key -> elt -> UniqDFM key elt #

addToUDFM_C :: Uniquable key => (elt -> elt -> elt) -> UniqDFM key elt -> key -> elt -> UniqDFM key elt #

addToUDFM_C_Directly :: forall {k} elt (key :: k). (elt -> elt -> elt) -> UniqDFM key elt -> Unique -> elt -> UniqDFM key elt #

addToUDFM_Directly :: forall {k} (key :: k) elt. UniqDFM key elt -> Unique -> elt -> UniqDFM key elt #

addListToUDFM :: Uniquable key => UniqDFM key elt -> [(key, elt)] -> UniqDFM key elt #

delFromUDFM :: Uniquable key => UniqDFM key elt -> key -> UniqDFM key elt #

delListFromUDFM :: Uniquable key => UniqDFM key elt -> [key] -> UniqDFM key elt #

Delete a list of elements from a UniqDFM

adjustUDFM :: Uniquable key => (elt -> elt) -> UniqDFM key elt -> key -> UniqDFM key elt #

Apply a function to a particular element

adjustUDFM_Directly :: forall {k} elt (key :: k). (elt -> elt) -> UniqDFM key elt -> Unique -> UniqDFM key elt #

Apply a function to a particular element

alterUDFM :: Uniquable key => (Maybe elt -> Maybe elt) -> UniqDFM key elt -> key -> UniqDFM key elt #

The expression (alterUDFM f k map) alters value x at k, or absence thereof. alterUDFM can be used to insert, delete, or update a value in UniqDFM. Use addToUDFM, delFromUDFM or adjustUDFM when possible, they are more efficient.

mapUDFM :: forall {k} elt1 elt2 (key :: k). (elt1 -> elt2) -> UniqDFM key elt1 -> UniqDFM key elt2 #

Map a function over every value in a UniqDFM

mapMaybeUDFM :: forall {k} elt1 elt2 (key :: k). (elt1 -> Maybe elt2) -> UniqDFM key elt1 -> UniqDFM key elt2 #

mapMUDFM :: forall {k} m elt1 elt2 (key :: k). Monad m => (elt1 -> m elt2) -> UniqDFM key elt1 -> m (UniqDFM key elt2) #

`mapM` for a `UniqDFM`.

plusUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt #

plusUDFM_C :: forall {k} elt (key :: k). (elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt #

plusUDFM_CK :: forall {k} elt (key :: k). (Unique -> elt -> elt -> elt) -> UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt #

Like `plusUDFM_C` but the combine function also receives the unique key

lookupUDFM :: Uniquable key => UniqDFM key elt -> key -> Maybe elt #

lookupUDFM_Directly :: forall {k} (key :: k) elt. UniqDFM key elt -> Unique -> Maybe elt #

elemUDFM :: Uniquable key => key -> UniqDFM key elt -> Bool #

foldUDFM :: forall {k} elt a (key :: k). (elt -> a -> a) -> a -> UniqDFM key elt -> a #

Performs a deterministic fold over the UniqDFM. It's O(n log n) while the corresponding function on `UniqFM` is O(n).

foldWithKeyUDFM :: forall {k} elt a (key :: k). (Unique -> elt -> a -> a) -> a -> UniqDFM key elt -> a #

Like `foldUDFM` but the function also receives a key

eltsUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> [elt] #

filterUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt #

filterUDFM_Directly :: forall {k} elt (key :: k). (Unique -> elt -> Bool) -> UniqDFM key elt -> UniqDFM key elt #

isNullUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> Bool #

sizeUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> Int #

intersectUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> UniqDFM key elt #

udfmIntersectUFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1 #

disjointUDFM :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqDFM key elt -> Bool #

disjointUdfmUfm :: forall {k} (key :: k) elt elt2. UniqDFM key elt -> UniqFM key elt2 -> Bool #

equalKeysUDFM :: forall {k} (key :: k) a b. UniqDFM key a -> UniqDFM key b -> Bool #

minusUDFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqDFM key elt2 -> UniqDFM key elt1 #

listToUDFM :: Uniquable key => [(key, elt)] -> UniqDFM key elt #

listToUDFM_Directly :: forall {k} elt (key :: k). [(Unique, elt)] -> UniqDFM key elt #

listToUDFM_C_Directly :: forall {k} elt (key :: k). (elt -> elt -> elt) -> [(Unique, elt)] -> UniqDFM key elt #

udfmMinusUFM :: forall {k} (key :: k) elt1 elt2. UniqDFM key elt1 -> UniqFM key elt2 -> UniqDFM key elt1 #

ufmMinusUDFM :: forall {k} (key :: k) elt1 elt2. UniqFM key elt1 -> UniqDFM key elt2 -> UniqFM key elt1 #

partitionUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> (UniqDFM key elt, UniqDFM key elt) #

Partition UniqDFM into two UniqDFMs according to the predicate

udfmRestrictKeys :: forall {k} (key :: k) elt elt2. UniqDFM key elt -> UniqDFM key elt2 -> UniqDFM key elt #

udfmRestrictKeysSet :: forall {k} (key :: k) elt. UniqDFM key elt -> Word64Set -> UniqDFM key elt #

anyUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> Bool #

allUDFM :: forall {k} elt (key :: k). (elt -> Bool) -> UniqDFM key elt -> Bool #

pprUniqDFM :: forall {k} a (key :: k). (a -> SDoc) -> UniqDFM key a -> SDoc #

pprUDFM #

Arguments

:: forall {k} (key :: k) a. UniqDFM key a | The things to be pretty printed
-> ([a] -> SDoc) | The pretty printing function to use on the elements
-> SDoc | `SDoc` where the things have been pretty printed

udfmToList :: forall {k} (key :: k) elt. UniqDFM key elt -> [(Unique, elt)] #

Converts `UniqDFM` to a list, with elements in deterministic order. It's O(n log n) while the corresponding function on `UniqFM` is O(n).

udfmToUfm :: forall {k} (key :: k) elt. UniqDFM key elt -> UniqFM key elt #

This allows for lossy conversion from UniqDFM to UniqFM

nonDetStrictFoldUDFM :: forall {k} elt a (key :: k). (elt -> a -> a) -> a -> UniqDFM key elt -> a #

Performs a nondeterministic strict fold over the UniqDFM. It's O(n), same as the corresponding function on `UniqFM`. If you use this please provide a justification why it doesn't introduce nondeterminism.

unsafeCastUDFMKey :: forall {k1} {k2} (key1 :: k1) elt (key2 :: k2). UniqDFM key1 elt -> UniqDFM key2 elt #

Cast the key domain of a UniqFM.

As long as the domains don't overlap in their uniques this is safe.

alwaysUnsafeUfmToUdfm :: forall {k} (key :: k) elt. UniqFM key elt -> UniqDFM key elt #