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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulemonoidal-containers-0.6.8.0Haskell2010

Data.HashMap.Monoidal

This module provides a Data.HashMap variant which uses the value's Monoid instance to accumulate conflicting entries when merging Maps.

While some functions mirroring those of Data.HashMap are provided here for convenience, more specialized needs will likely want to use either the Newtype or Wrapped instances to manipulate the underlying Map.

Contents
  1. Often-needed functions
Synopsis
newtypenewtype MonoidalHashMap k a

A HashMap with monoidal accumulation

Instances35FoldableWithIndex, FunctorWithIndex, TraversableWithIndex, Functor, Foldable, Traversable, …

Often-needed functions

valuetoList :: MonoidalHashMap k a -> [(k, a)]

O(n*log n). Return a list of this map's elements. The list is produced lazily. The order of its elements is unspecified.

valuefromList :: (Eq k, Hashable k) => [(k, a)] -> MonoidalHashMap k a

O(n*log n). Construct a map with the supplied mappings. If the list contains duplicate mappings, values will be replaced.

valuefromListWith
  1. :: (Eq k, Hashable k)
  2. => a -> a -> a
  3. -> [(k, a)]
  4. -> MonoidalHashMap k a

O(n*log n). Construct a map with the supplied mappings. If the list contains duplicate mappings, values will be merged using the provided combining function.