appendmap
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Map.Counter

Description

A Semigroup-based counter type.

Synopsis

Documentation

type Counter key = AppendMap key (Sum Int) Source #

A Semigroup-based counter type.

let counts = mkCounter 1 <> mkCounter 2 <> mkCounter 1 :: Counter Int
getCounts counts === Map.fromList [(1, 2), (2, 1)]

mkCounter :: Ord key => key -> Counter key Source #

Counter that has a single occurrence for a single item.

getCounts :: Counter key -> Map key Int Source #

Get counts as a map.