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

Modulelinear-base-0.4.0Haskell2010

Data.HashMap.Mutable.Linear

This module provides mutable hashmaps with a linear interface.

It is implemented with Robin Hood hashing which has amortized constant time lookups and updates.

  • 2 types
  • 20 values

A mutable hashmap

2 declarations
datadata HashMap k v where
#

A mutable hashmap with a linear interface.

Instances5Functor, Consumable, Dupable, Semigroup
  • Functor (HashMap k)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Semigroup (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Consumable (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Dupable (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
  • Keyed k => Semigroup (HashMap k v)Defined in linear-base-0.4.0 · Data.HashMap.Mutable.Linear.Internal
typetype Keyed k = (Eq k, Hashable k)
#

At minimum, we need to store hashable and identifiable keys

Constructors

2 declarations

Modifiers

10 declarations
valuealter
  1. :: Keyed k
  2. => Maybe v -> Maybe v
  3. -> k
  4. -> HashMap k v
  5. -> HashMap k v
#

A general modification function; which can insert, update or delete a value of the key. See alterF, for an even more general function.

valuealterF
  1. :: (Keyed k, Functor f)
  2. => Maybe v -> f (Ur (Maybe v))
  3. -> k
  4. -> HashMap k v
  5. -> f (HashMap k v)
#

The most general modification function; which can insert, update or delete a value of the key, while collecting an effect in the form of an arbitrary Functor.

Accessors

5 declarations
valuecapacity :: HashMap k v %1 -> (Ur Int, HashMap k v)
#

Maximum number of elements the HashMap can store without resizing. However, for performance reasons, the HashMap might be before full.

Use shrinkToFit to reduce the wasted space.

valuetoList :: HashMap k v %1 -> Ur [(k, v)]
#

Converts a HashMap to a lazy list.

Combining maps

3 declarations
valueunionWith
  1. :: Keyed k
  2. => v -> v -> v
  3. -> HashMap k v
  4. -> HashMap k v
  5. -> HashMap k v
#

Union of two maps using the provided function on conflicts.

Complexity: O(min(capacity hm1, capacity hm2)