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

[ bsd3, data-structures, library ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), containers [details]
License BSD-3-Clause
Copyright 2018 Alexey Kotlyarov
Author Alexey Kotlyarov
Maintainer a@koterpillar.com
Category Data Structures
Home page https://github.com/koterpillar/appendmap#readme
Bug tracker https://github.com/koterpillar/appendmap/issues
Source repo head: git clone https://github.com/koterpillar/appendmap
Uploaded by AlexeyKotlyarov at 2018-09-02T07:30:02Z
Distributions LTSHaskell:0.1.5, NixOS:0.1.5, Stackage:0.1.5
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 3488 total (31 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-09-02 [all 1 reports]

Readme for appendmap-0.1.5

[back to package description]

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.