HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.Types.Unique.DFM

  • 1 type
  • 47 values
  • Packageghc-9.10.3
  • Exports48
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceDFM.hs

Unique-keyed deterministic mappings

1 declaration
datadata 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.

Instances7Functor, Foldable, Traversable, TrieMap, Data, Outputable, …

Manipulating those mappings

valuealterUDFM
  1. :: Uniquable key
  2. => Maybe elt -> Maybe elt
  3. -> UniqDFM key elt
  4. -> key
  5. -> 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.

valuemapUDFM :: (elt1 -> elt2) -> UniqDFM key elt1 -> UniqDFM key elt2
#

Map a function over every value in a UniqDFM

valuefoldUDFM :: (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).

valuepprUDFM
  1. :: UniqDFM key a

    The things to be pretty printed

  2. -> ([a] -> SDoc)

    The pretty printing function to use on the elements

  3. -> SDoc

    SDoc where the things have been pretty printed

#
valueudfmToList :: 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).

valuenonDetStrictFoldUDFM :: (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.

valueunsafeCastUDFMKey :: 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.