Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koterpillar/appendmap
A Data.Map wrapper with a Monoid instance that delegates to the individual keys
https://github.com/koterpillar/appendmap
containers data-structures haskell map monoid semigroup
Last synced: 7 days ago
JSON representation
A Data.Map wrapper with a Monoid instance that delegates to the individual keys
- Host: GitHub
- URL: https://github.com/koterpillar/appendmap
- Owner: koterpillar
- License: bsd-3-clause
- Created: 2018-08-16T10:33:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-17T11:10:46.000Z (9 months ago)
- Last Synced: 2024-04-26T01:02:04.363Z (7 months ago)
- Topics: containers, data-structures, haskell, map, monoid, semigroup
- Language: Haskell
- Size: 23.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# appendmap
![Build status](https://github.com/koterpillar/appendmap/workflows/Build/badge.svg)
[![Hackage](https://img.shields.io/hackage/v/appendmap.svg)](https://hackage.haskell.org/package/appendmap)
[![Stackage LTS](https://www.stackage.org/package/appendmap/badge/lts)](https://www.stackage.org/lts/package/appendmap)
[![Hackage dependencies](https://img.shields.io/hackage-deps/v/appendmap.svg)](https://packdeps.haskellers.com/feed?needle=appendmap)A `Data.Map` wrapper with a `Semigroup` and `Monoid` instances that delegate to
the individual keys.```haskell
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:```haskell
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](https://mail.haskell.org/pipermail/libraries/2012-April/017743.html),
[2](https://ghc.haskell.org/trac/ghc/ticket/1460)), 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.