appendmap

Map with a Semigroup and Monoid instances delegating to Semigroup of the elements

https://github.com/koterpillar/appendmap#readme

LTS Haskell 22.36:0.1.5
Stackage Nightly 2024-10-05:0.1.5
Latest on Hackage:0.1.5

See all snapshots appendmap appears in

BSD-3-Clause licensed by Alexey Kotlyarov
Maintained by [email protected]
This version can be pinned in stack with:appendmap-0.1.5@sha256:1c150f734016276c580de7064d620d86f4793603c0d5c7f2724c6b5f0fcaf316,1548

Module documentation for 0.1.5

Depends on 2 packages(full list with versions):

appendmap

Build status Hackage Stackage LTS Hackage dependencies

A Data.Map wrapper with a Semigroup and Monoid instances that delegate to the individual keys.

import qualified Data.Map as Map
import Data.Map.Append

> one = AppendMap $ Map.fromList [(1, "hello"), (2, "goodbye")]
> two = AppendMap $ Map.fromList [(1, "world"), (3, "again")]

> unAppendMap (one <> two)
fromList [(1, "helloworld"), (2, "goodbye"), (3, "again")]

Motivation

Data.Map has a Semigroup instance that keeps the values from the first argument in case of a key conflict:

import qualified Data.Map as Map
import Data.Map.Append

> Map.fromList [(1, "hello")] <> Map.fromList [(1, "goodbye")]
fromList [(1, "hello")]

A different instance has been suggested for a long time (1, 2), but this is a breaking change and hasn’t happened yet (as of 2018-08).

Development

Source code is formatted with hindent then stylish-haskell.

Releasing

  • Run ./bumpversion patch|minor|major. This will create a new version and push it to the repository to be released.

Changes

Changelog for appendmap

Unreleased changes

0.1.5

0.1.4

0.1.3

  • Fix tests on older LTS

0.1.2

  • Wrappers for lazy and strict versions of Data.Map.

0.1.1

  • Initial release on Hackage.