appendmap-0.1.5: Map with a Semigroup and Monoid instances delegating to Semigroup of the elements

Safe HaskellSafe
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.