HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Unique-keyed deterministic mappings

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, …
  • Functor (UniqDFM key)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Unique.DFM
  • Foldable (UniqDFM key)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Unique.DFM

    Deterministic, in O(n log n).

  • Traversable (UniqDFM key)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Unique.DFM

    Deterministic, in O(n log n).

  • Uniquable key => TrieMap (UniqDFM key)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Data.TrieMap
  • (Typeable key, Typeable k, Data ele) => Data (UniqDFM key ele)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Unique.DFM
  • Outputable a => Outputable (UniqDFM key a)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.Unique.DFM
  • type Key (UniqDFM key) = keyDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Data.TrieMap

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.

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

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