git.iko.soy/monoidal-containers
on 197dca3 help sign in
.travis.yml+106−124
since splitsnapshots
unifiedsplit
@@ -1,153 +1,135 @@
1# This Travis job script has been generated by a script via
1# This Travis job script has been generated by a script via
2#
2#
3−# haskell-ci 'monoidal-containers.cabal' '-o' '.travis.yml'
3+# runghc make_travis_yml_2.hs 'monoidal-containers.cabal'
4−#
5−# To regenerate the script (for example after adjusting tested-with) run
6−#
7−# haskell-ci regenerate
8#
4#
9# For more information, see https://github.com/haskell-CI/haskell-ci
5# For more information, see https://github.com/haskell-CI/haskell-ci
10#
6#
11−# version: 0.10.3
12−#
13−version: ~> 1.0
14language: c
7language: c
15−os: linux
8+sudo: false
16−dist: xenial
9+
17git:
10git:
18− # whether to recursively clone submodules
11+ submodules: false # whether to recursively clone submodules
19− submodules: false
12+
20cache:
13cache:
21 directories:
14 directories:
22 - $HOME/.cabal/packages
15 - $HOME/.cabal/packages
23 - $HOME/.cabal/store
16 - $HOME/.cabal/store
24− - $HOME/.hlint
17+
25before_cache:
18before_cache:
26− - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
19+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
27 # remove files that are regenerated by 'cabal update'
20 # remove files that are regenerated by 'cabal update'
28− - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
21+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
29− - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
22+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
30− - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
23+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
31− - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
24+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
32− - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
25+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
26+
33− - rm -rfv $CABALHOME/packages/head.hackage
27+ - rm -rfv $HOME/.cabal/packages/head.hackage
34−jobs:
28+
29+matrix:
35 include:
30 include:
36− - compiler: ghc-8.10.2
31+ - compiler: "ghc-8.6.1"
37− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.2","cabal-install-3.2"]}}
32+ env: GHCHEAD=true
38− os: linux
33+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.1], sources: [hvr-ghc]}}
39− - compiler: ghc-8.8.4
40− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.4","cabal-install-3.2"]}}
41− os: linux
42− - compiler: ghc-8.6.5
43− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}}
44− os: linux
45− - compiler: ghc-8.4.3
34+ - compiler: "ghc-8.4.3"
46− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.3","cabal-install-3.2"]}}
35+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
47− os: linux
36+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
48− - compiler: ghc-8.2.2
37+ - compiler: "ghc-8.2.2"
49− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.2"]}}
38+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
50− os: linux
39+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}
51− - compiler: ghc-8.0.2
40+ - compiler: "ghc-8.0.2"
52− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.2"]}}
41+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
53− os: linux
42+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}}
54− - compiler: ghc-7.8.4
43+ - compiler: "ghc-7.8.4"
55− addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.8.4","cabal-install-3.2"]}}
44+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
56− os: linux
45+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.8.4], sources: [hvr-ghc]}}
46+
47+ allow_failures:
48+ - compiler: "ghc-8.6.1"
49+
57before_install:
50before_install:
58− - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
51+ - HC=${CC}
59− - WITHCOMPILER="-w $HC"
60− - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
61− - HCPKG="$HC-pkg"
52+ - HCPKG=${HC/ghc/ghc-pkg}
62 - unset CC
53 - unset CC
63− - CABAL=/opt/ghc/bin/cabal
54+ - ROOTDIR=$(pwd)
64− - CABALHOME=$HOME/.cabal
55+ - mkdir -p $HOME/.local/bin
65− - export PATH="$CABALHOME/bin:$PATH"
56+ - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
66− - TOP=$(pwd)
67− - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
57+ - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
68 - echo $HCNUMVER
58 - echo $HCNUMVER
69− - CABAL="$CABAL -vnormal+nowrap"
59+
70− - set -o pipefail
71− - TEST=--enable-tests
72− - BENCH=--enable-benchmarks
73− - HEADHACKAGE=false
74− - rm -f $CABALHOME/config
75− - |
76− echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
77− echo "remote-build-reporting: anonymous" >> $CABALHOME/config
78− echo "write-ghc-environment-files: always" >> $CABALHOME/config
79− echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
80− echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
81− echo "world-file: $CABALHOME/world" >> $CABALHOME/config
82− echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
83− echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
84− echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
85− echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
86− echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
87− echo "install-dirs user" >> $CABALHOME/config
88− echo " prefix: $CABALHOME" >> $CABALHOME/config
89− echo "repository hackage.haskell.org" >> $CABALHOME/config
90− echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
91install:
60install:
92− - ${CABAL} --version
61+ - cabal --version
93 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
62 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
63+ - BENCH=${BENCH---enable-benchmarks}
64+ - TEST=${TEST---enable-tests}
65+ - HADDOCK=${HADDOCK-true}
66+ - UNCONSTRAINED=${UNCONSTRAINED-true}
67+ - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}
68+ - GHCHEAD=${GHCHEAD-false}
69+ - travis_retry cabal update -v
70+ - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
71+ - rm -fv cabal.project cabal.project.local
72+ # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
94 - |
73 - |
95− echo "program-default-options" >> $CABALHOME/config
74+ if $GHCHEAD; then
96− echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
75+ sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config
97− - cat $CABALHOME/config
76+ for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done
98− - rm -fv cabal.project cabal.project.local cabal.project.freeze
77+
99− - travis_retry ${CABAL} v2-update -v
78+ echo 'repository head.hackage' >> ${HOME}/.cabal/config
100− # Generate cabal.project
79+ echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config
101− - rm -rf cabal.project cabal.project.local cabal.project.freeze
80+ echo ' secure: True' >> ${HOME}/.cabal/config
102− - touch cabal.project
81+ echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
103− - |
82+ echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
83+ echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
84+ echo ' key-threshold: 3' >> ${HOME}/.cabal.config
85+
86+ grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
87+
88+ cabal new-update head.hackage -v
89+ fi
90+ - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
104− echo "packages: ." >> cabal.project
91+ - "printf 'packages: \".\"\\n' > cabal.project"
105− - if [ $HCNUMVER -ge 80200 ] ; then echo 'package monoidal-containers' >> cabal.project ; fi
92+ - touch cabal.project.local
106− - "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
107− - |
108− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(monoidal-containers)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
93+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- monoidal-containers | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
109 - cat cabal.project || true
94 - cat cabal.project || true
110 - cat cabal.project.local || true
95 - cat cabal.project.local || true
111− - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
96+ - if [ -f "./configure.ac" ]; then
112− - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
97+ (cd "." && autoreconf -i);
98+ fi
113− - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
99+ - rm -f cabal.project.freeze
114− - rm cabal.project.freeze
100+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
115− - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
116− - travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
101+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
117−script:
102+ - rm -rf .ghc.environment.* "."/dist
118 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
103 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
119− # Packaging...
104+
120− - ${CABAL} v2-sdist all
105+# Here starts the actual work to be performed for the package under test;
121− # Unpacking...
106+# any command which exits with a non-zero exit code causes the build to fail.
107+script:
108+ # test that source-distributions can be generated
109+ - (cd "." && cabal sdist)
122− - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
110+ - mv "."/dist/monoidal-containers-*.tar.gz ${DISTDIR}/
123 - cd ${DISTDIR} || false
111 - cd ${DISTDIR} || false
124− - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
112+ - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
125− - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
113+ - "printf 'packages: monoidal-containers-*/*.cabal\\n' > cabal.project"
126− - PKGDIR_monoidal_containers="$(find . -maxdepth 1 -type d -regex '.*/monoidal-containers-[0-9.]*')"
127− # Generate cabal.project
128− - rm -rf cabal.project cabal.project.local cabal.project.freeze
129− - touch cabal.project
114+ - touch cabal.project.local
130− - |
131− echo "packages: ${PKGDIR_monoidal_containers}" >> cabal.project
132− - if [ $HCNUMVER -ge 80200 ] ; then echo 'package monoidal-containers' >> cabal.project ; fi
133− - "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
134− - |
135− - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(monoidal-containers)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
115+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- monoidal-containers | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
136 - cat cabal.project || true
116 - cat cabal.project || true
137 - cat cabal.project.local || true
117 - cat cabal.project.local || true
138− # Building...
139 # this builds all libraries and executables (without tests/benchmarks)
118 # this builds all libraries and executables (without tests/benchmarks)
140− - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
119+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
141− # Building with tests and benchmarks...
120+
142 # build & run tests, build benchmarks
121 # build & run tests, build benchmarks
143− - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
122+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
123+
144− # cabal check...
124+ # cabal check
145− - (cd ${PKGDIR_monoidal_containers} && ${CABAL} -vnormal check)
125+ - (cd monoidal-containers-* && cabal check)
126+
146− # haddock...
127+ # haddock
147− - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
128+ - rm -rf ./dist-newstyle
129+ - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
130+
148− # Building without installed constraints for packages in global-db...
131+ # Build without installed constraints for packages in global-db
149− - rm -f cabal.project.local
132+ - if $UNCONSTRAINED; then rm -f cabal.project.local; echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks all; else echo "Not building without installed constraints"; fi
150− - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
133+
151−
152−# REGENDATA ("0.10.3",["monoidal-containers.cabal","-o",".travis.yml"])
134+# REGENDATA ["monoidal-containers.cabal"]
153# EOF
135# EOF
Changelog.md−16
@@ -1,21 +1,5 @@
1# Monoidal containers
1# Monoidal containers
2
2
3−# 0.6.0.1
4−
5− * Support semialign-1.1
6−
7−# 0.6
8−
9− * Deprecates 0.5.* and reverts behavior of fromList, insert, mapKeys, etc. to match behavior in Data.Map. The only difference in behavior between Data.Map.Monoidal.MonoidalMap and Data.Map.Map is now the semigroup and monoid instances (as was the case in 0.4 and earlier).
10− * Fix the argument order of Data.HashMap.Monoidal.insert
11− * Remove Data.HashMap.Monoidal.insertOrReplace as it is now identical to Data.HashMap.Monoidal.insert
12− * Added Data.HashMap.Monoidal.insertWith and Data.HashMap.Monoidal.fromListWith
13−
14−# 0.5.0.1
15−
16− * Add a flag, `split-these`, to select whether to use the new "these"/"semialign" packages or the older combined "these" package.
17− * Add default.nix to make it easier to hack on this package in nix
18−
19# 0.5.0.0
3# 0.5.0.0
20
4
21 * Added Data.IntMap.Monoidal and Data.IntMap.Monoidal.Strict, corresponding to Data.IntMap and Data.IntMap.Strict
5 * Added Data.IntMap.Monoidal and Data.IntMap.Monoidal.Strict, corresponding to Data.IntMap and Data.IntMap.Strict
README.md−4
@@ -6,7 +6,3 @@ of the values to be used when resolving conflicts between keys when merging
6structures. Sadly, these are not the semantics offered by the provided
6structures. Sadly, these are not the semantics offered by the provided
7instances. This package provides `newtypes` with an appropriate set of
7instances. This package provides `newtypes` with an appropriate set of
8instances and utility functions to make them usable.
8instances and utility functions to make them usable.
9−
10−## Important Note
11−
12−This library is designed to be a drop-in replacement for `Data.Map` and similar. Absolutely no other semantic changes are introduced in functions like `fromList` or `insert`. They are still left-biased like `Data.Map`'s. The only difference is in instances for `Semigroup`.
default.nix+6−4
@@ -1,15 +1,17 @@
1{ mkDerivation, aeson, base, containers, deepseq, hashable, lens
1{ mkDerivation, aeson, base, containers, deepseq, hashable, lens
2−, newtype, semialign, semigroups, stdenv, these
2+, newtype, semialign ? null, semigroups, stdenv, these
3, unordered-containers
3, unordered-containers
4}:
4}:
5mkDerivation {
5mkDerivation {
6 pname = "monoidal-containers";
6 pname = "monoidal-containers";
7− version = "0.6";
7+ version = "0.5.0.1";
8 src = ./.;
8 src = ./.;
9 libraryHaskellDepends = [
9 libraryHaskellDepends = [
10− aeson base containers deepseq hashable lens newtype semialign
10+ aeson base containers deepseq hashable lens newtype
11 semigroups these unordered-containers
11 semigroups these unordered-containers
12− ];
12+ ] ++ stdenv.lib.optional (semialign == null) [ semialign ];
13+ configureFlags =
14+ stdenv.lib.optional (semialign == null) [ "-f-split-these" ];
13 homepage = "http://github.com/bgamari/monoidal-containers";
15 homepage = "http://github.com/bgamari/monoidal-containers";
14 description = "Containers with monoidal accumulation";
16 description = "Containers with monoidal accumulation";
15 license = stdenv.lib.licenses.bsd3;
17 license = stdenv.lib.licenses.bsd3;
monoidal-containers.cabal+7−6
@@ -1,5 +1,5 @@
1name: monoidal-containers
1name: monoidal-containers
2−version: 0.6.0.1
2+version: 0.5.0.1
3synopsis: Containers with monoidal accumulation
3synopsis: Containers with monoidal accumulation
4description:
4description:
5 Containers with merging via monoidal accumulation. The 'Monoid' instances
5 Containers with merging via monoidal accumulation. The 'Monoid' instances
@@ -24,7 +24,7 @@ category: Data
24build-type: Simple
24build-type: Simple
25cabal-version: >=1.10
25cabal-version: >=1.10
26extra-source-files: Changelog.md
26extra-source-files: Changelog.md
27−tested-with: GHC ==7.8.4, GHC ==8.0.2, GHC ==8.2.2, GHC ==8.4.3, GHC ==8.6.5, GHC ==8.8.4, GHC ==8.10.2
27+tested-with: GHC ==7.8.4, GHC ==8.0.2, GHC ==8.2.2, GHC ==8.4.3, GHC ==8.6.1
28
28
29source-repository head
29source-repository head
30 type: git
30 type: git
@@ -46,8 +46,8 @@ library
46 GeneralizedNewtypeDeriving,
46 GeneralizedNewtypeDeriving,
47 DeriveTraversable,
47 DeriveTraversable,
48 DeriveDataTypeable
48 DeriveDataTypeable
49− build-depends: base >=4.7 && <4.16,
49+ build-depends: base >=4.5 && <4.13,
50− aeson >=1.0 && <1.6,
50+ aeson >=1.0 && <1.5,
51 containers >=0.5 && <0.7,
51 containers >=0.5 && <0.7,
52 deepseq >=1.3 && <1.5,
52 deepseq >=1.3 && <1.5,
53 unordered-containers >= 0.2 && < 0.3,
53 unordered-containers >= 0.2 && < 0.3,
@@ -57,8 +57,9 @@ library
57 semigroups >= 0.18 && < 0.20
57 semigroups >= 0.18 && < 0.20
58
58
59 if flag(split-these)
59 if flag(split-these)
60− build-depends: these >= 1 && <1.2,
60+ build-depends: these >= 1 && <1.1,
61− semialign >=1 && <1.2
61+ semialign >=1 && <1.1
62+
62 else
63 else
63 build-depends: these >= 0.7 && <0.9
64 build-depends: these >= 0.7 && <0.9
64
65
src/Data/HashMap/Monoidal.hs+24−43
@@ -20,7 +20,6 @@ module Data.HashMap.Monoidal
20 -- * Often-needed functions
20 -- * Often-needed functions
21 , toList
21 , toList
22 , fromList
22 , fromList
23− , fromListWith
24 , singleton
23 , singleton
25 , size
24 , size
26 , member
25 , member
@@ -32,7 +31,7 @@ module Data.HashMap.Monoidal
32 , delete
31 , delete
33 , mapKeys
32 , mapKeys
34 , insert
33 , insert
35− , insertWith
34+ , insertOrReplace
36 , modify
35 , modify
37 , modifyDef
36 , modifyDef
38 , map
37 , map
@@ -60,12 +59,6 @@ import Data.Hashable.Lifted (Hashable1)
60import Control.Lens
59import Control.Lens
61import Control.Newtype
60import Control.Newtype
62import Data.Align
61import Data.Align
63−#ifdef MIN_VERSION_semialign
64−import Data.Semialign (Unalign)
65−#if MIN_VERSION_semialign(1,1,0)
66−import Data.Zip (Zip)
67−#endif
68−#endif
69
62
70-- | A 'HashMap' with monoidal accumulation
63-- | A 'HashMap' with monoidal accumulation
71newtype MonoidalHashMap k a = MonoidalHashMap { getMonoidalHashMap :: M.HashMap k a }
64newtype MonoidalHashMap k a = MonoidalHashMap { getMonoidalHashMap :: M.HashMap k a }
@@ -76,12 +69,6 @@ newtype MonoidalHashMap k a = MonoidalHashMap { getMonoidalHashMap :: M.HashMap
76#endif
69#endif
77#if MIN_VERSION_these(0,8,0)
70#if MIN_VERSION_these(0,8,0)
78 , Semialign
71 , Semialign
79−#endif
80−#ifdef MIN_VERSION_semialign
81− , Unalign
82−#if MIN_VERSION_semialign(1,1,0)
83− , Zip
84−#endif
85#endif
72#endif
86 )
73 )
87
74
@@ -138,7 +125,7 @@ instance Newtype (MonoidalHashMap k a) (M.HashMap k a) where
138#if MIN_VERSION_base(4,7,0)
125#if MIN_VERSION_base(4,7,0)
139instance (Eq k, Hashable k, Semigroup a) => Exts.IsList (MonoidalHashMap k a) where
126instance (Eq k, Hashable k, Semigroup a) => Exts.IsList (MonoidalHashMap k a) where
140 type Item (MonoidalHashMap k a) = (k, a)
127 type Item (MonoidalHashMap k a) = (k, a)
141− fromList = MonoidalHashMap . M.fromList
128+ fromList = MonoidalHashMap . M.fromListWith (<>)
142 {-# INLINE fromList #-}
129 {-# INLINE fromList #-}
143 toList = M.toList . unpack
130 toList = M.toList . unpack
144 {-# INLINE toList #-}
131 {-# INLINE toList #-}
@@ -195,45 +182,39 @@ keys = M.keys . unpack
195{-# INLINE keys #-}
182{-# INLINE keys #-}
196
183
197-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
184-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
198−-- contains duplicate mappings, values will be replaced.
185+-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
199−fromList :: (Eq k, Hashable k) => [(k,a)] -> MonoidalHashMap k a
186+fromList :: (Eq k, Hashable k, Semigroup a) => [(k,a)] -> MonoidalHashMap k a
200−fromList = pack . M.fromList
187+fromList = pack . M.fromListWith (<>)
201{-# INLINE fromList #-}
188{-# INLINE fromList #-}
202
189
203−-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
204−-- contains duplicate mappings, values will be merged using the provided combining function.
205−fromListWith :: (Eq k, Hashable k) => (a -> a -> a) -> [(k,a)] -> MonoidalHashMap k a
206−fromListWith f = pack . M.fromListWith f
207−{-# INLINE fromListWith #-}
208−
209−
210-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
190-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
211-- lazily. The order of its elements is unspecified.
191-- lazily. The order of its elements is unspecified.
212toList :: MonoidalHashMap k a -> [(k,a)]
192toList :: MonoidalHashMap k a -> [(k,a)]
213toList = M.toList . unpack
193toList = M.toList . unpack
214{-# INLINE toList #-}
194{-# INLINE toList #-}
215
195
216−-- | /O(log n)/. Insert a value on some key, if it exists replace the value.
196+-- | /O(log n)/. Insert a value on some key, if it exists -- mappend
217−insert :: (Hashable k, Eq k)
197+-- to the existing one.
218− => k
219− -> a
220− -> MonoidalHashMap k a
221− -> MonoidalHashMap k a
222−insert k x = pack
223− . M.insert k x
224− . unpack
225−
226−-- | /O(log n)/. Insert a value on some key, if it exists apply the combining function.
227−insertWith :: (Hashable k, Eq k)
198+insert :: (Semigroup a, Hashable k, Eq k)
228− => (a -> a -> a)
199+ => a
229 -> k
200 -> k
230− -> a
231 -> MonoidalHashMap k a
201 -> MonoidalHashMap k a
232 -> MonoidalHashMap k a
202 -> MonoidalHashMap k a
233−insertWith f k x = pack
203+insert x k = pack
234− . M.insertWith f k x
204+ . M.insertWith (<>) k x
235 . unpack
205 . unpack
236
206
207+-- | /O(log n)/. Insert a value on some key with a function, if value
208+-- under key exists -- replace it.
209+insertOrReplace :: (Semigroup a, Hashable k, Eq k)
210+ => a
211+ -> k
212+ -> MonoidalHashMap k a
213+ -> MonoidalHashMap k a
214+insertOrReplace x k = pack
215+ . M.insert k x
216+ . unpack
217+
237-- | /O(log n)/. Modify a value on some key with a function, if value
218-- | /O(log n)/. Modify a value on some key with a function, if value
238-- under key doesn't exist -- use mempty.
219-- under key doesn't exist -- use mempty.
239modify :: (Monoid a, Hashable k, Eq k)
220modify :: (Monoid a, Hashable k, Eq k)
@@ -247,7 +228,7 @@ modify f k = pack
247
228
248-- | /O(log n)/. Modify a value on some key with a function, providing
229-- | /O(log n)/. Modify a value on some key with a function, providing
249-- a default value if that key doesn't exist.
230-- a default value if that key doesn't exist.
250−modifyDef :: (Hashable k, Eq k)
231+modifyDef :: (Semigroup a, Hashable k, Eq k)
251 => a -> (a -> a)
232 => a -> (a -> a)
252 -> k -> MonoidalHashMap k a
233 -> k -> MonoidalHashMap k a
253 -> MonoidalHashMap k a
234 -> MonoidalHashMap k a
@@ -258,7 +239,7 @@ modifyDef d f k = pack
258
239
259-- | /O(n)/. Map a function to each key of a map, if it will result
240-- | /O(n)/. Map a function to each key of a map, if it will result
260-- in duplicated mappings, their values will be merged in unspecified order
241-- in duplicated mappings, their values will be merged in unspecified order
261−mapKeys :: (Hashable k, Eq k, Hashable k', Eq k')
242+mapKeys :: (Semigroup a, Hashable k, Eq k, Hashable k', Eq k')
262 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
243 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
263mapKeys f = fromList
244mapKeys f = fromList
264 . fmap (\(k, v) -> (f k, v))
245 . fmap (\(k, v) -> (f k, v))
src/Data/IntMap/Monoidal.hs+8−20
@@ -151,12 +151,6 @@ import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
151import Data.Functor.Classes
151import Data.Functor.Classes
152#endif
152#endif
153import Data.Align
153import Data.Align
154−#ifdef MIN_VERSION_semialign
155−import Data.Semialign (Unalign)
156−#if MIN_VERSION_semialign(1,1,0)
157−import Data.Zip (Zip)
158−#endif
159−#endif
160
154
161-- | An 'IntMap' with monoidal accumulation
155-- | An 'IntMap' with monoidal accumulation
162newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
156newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
@@ -166,12 +160,6 @@ newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
166 Data, Typeable, Align
160 Data, Typeable, Align
167#if MIN_VERSION_these(0,8,0)
161#if MIN_VERSION_these(0,8,0)
168 , Semialign
162 , Semialign
169−#endif
170−#ifdef MIN_VERSION_semialign
171− , Unalign
172−#if MIN_VERSION_semialign(1,1,0)
173− , Zip
174−#endif
175#endif
163#endif
176 )
164 )
177
165
@@ -333,8 +321,8 @@ empty :: forall a. MonoidalIntMap a
333empty = coerce (M.empty :: M.IntMap a)
321empty = coerce (M.empty :: M.IntMap a)
334{-# INLINE empty #-}
322{-# INLINE empty #-}
335
323
336−insert :: forall a. Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
324+insert :: forall a. Semigroup a => Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
337−insert = coerce (M.insert :: Int -> a -> M.IntMap a -> M.IntMap a)
325+insert = coerce (M.insertWith (<>) :: Int -> a -> M.IntMap a -> M.IntMap a)
338{-# INLINE insert #-}
326{-# INLINE insert #-}
339
327
340insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
328insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
@@ -433,8 +421,8 @@ mapAccumRWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntM
433mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
421mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
434{-# INLINE mapAccumRWithKey #-}
422{-# INLINE mapAccumRWithKey #-}
435
423
436−mapKeys :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
424+mapKeys :: forall a. Semigroup a => (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
437−mapKeys = coerce (M.mapKeys :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
425+mapKeys = coerce (M.mapKeysWith (<>) :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
438{-# INLINE mapKeys #-}
426{-# INLINE mapKeys #-}
439
427
440mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
428mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
@@ -493,8 +481,8 @@ toList :: forall a. MonoidalIntMap a -> [(Int, a)]
493toList = coerce (M.toList :: M.IntMap a -> [(Int, a)])
481toList = coerce (M.toList :: M.IntMap a -> [(Int, a)])
494{-# INLINE toList #-}
482{-# INLINE toList #-}
495
483
496−fromList :: forall a. [(Int, a)] -> MonoidalIntMap a
484+fromList :: forall a. Semigroup a => [(Int, a)] -> MonoidalIntMap a
497−fromList = coerce (M.fromList :: [(Int, a)] -> M.IntMap a)
485+fromList = fromListWith (<>)
498{-# INLINE fromList #-}
486{-# INLINE fromList #-}
499
487
500fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
488fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
@@ -513,8 +501,8 @@ toDescList :: forall a. MonoidalIntMap a -> [(Int, a)]
513toDescList = coerce (M.toDescList :: M.IntMap a -> [(Int, a)])
501toDescList = coerce (M.toDescList :: M.IntMap a -> [(Int, a)])
514{-# INLINE toDescList #-}
502{-# INLINE toDescList #-}
515
503
516−fromAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
504+fromAscList :: forall a. Semigroup a => [(Int, a)] -> MonoidalIntMap a
517−fromAscList = coerce (M.fromAscList :: [(Int, a)] -> M.IntMap a)
505+fromAscList = fromAscListWith (<>)
518{-# INLINE fromAscList #-}
506{-# INLINE fromAscList #-}
519
507
520fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
508fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
src/Data/IntMap/Monoidal/Strict.hs+9−21
@@ -151,12 +151,6 @@ import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
151import Data.Functor.Classes
151import Data.Functor.Classes
152#endif
152#endif
153import Data.Align
153import Data.Align
154−#ifdef MIN_VERSION_semialign
155−import Data.Semialign (Unalign)
156−#if MIN_VERSION_semialign(1,1,0)
157−import Data.Zip (Zip)
158−#endif
159−#endif
160
154
161-- | An 'IntMap' with monoidal accumulation
155-- | An 'IntMap' with monoidal accumulation
162newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
156newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
@@ -165,13 +159,7 @@ newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
165 FromJSON, ToJSON, FromJSON1, ToJSON1,
159 FromJSON, ToJSON, FromJSON1, ToJSON1,
166 Data, Typeable, Align
160 Data, Typeable, Align
167#if MIN_VERSION_these(0,8,0)
161#if MIN_VERSION_these(0,8,0)
168− , Semialign
162+ , Semialign
169−#endif
170−#ifdef MIN_VERSION_semialign
171− , Unalign
172−#if MIN_VERSION_semialign(1,1,0)
173− , Zip
174−#endif
175#endif
163#endif
176 )
164 )
177
165
@@ -333,8 +321,8 @@ empty :: forall a. MonoidalIntMap a
333empty = coerce (M.empty :: M.IntMap a)
321empty = coerce (M.empty :: M.IntMap a)
334{-# INLINE empty #-}
322{-# INLINE empty #-}
335
323
336−insert :: forall a. Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
324+insert :: forall a. Semigroup a => Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
337−insert = coerce (M.insert :: Int -> a -> M.IntMap a -> M.IntMap a)
325+insert = coerce (M.insertWith (<>) :: Int -> a -> M.IntMap a -> M.IntMap a)
338{-# INLINE insert #-}
326{-# INLINE insert #-}
339
327
340insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
328insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
@@ -433,8 +421,8 @@ mapAccumRWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntM
433mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
421mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
434{-# INLINE mapAccumRWithKey #-}
422{-# INLINE mapAccumRWithKey #-}
435
423
436−mapKeys :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
424+mapKeys :: forall a. Semigroup a => (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
437−mapKeys = coerce (M.mapKeys :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
425+mapKeys = coerce (M.mapKeysWith (<>) :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
438{-# INLINE mapKeys #-}
426{-# INLINE mapKeys #-}
439
427
440mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
428mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
@@ -493,8 +481,8 @@ toList :: forall a. MonoidalIntMap a -> [(Int, a)]
493toList = coerce (M.toList :: M.IntMap a -> [(Int, a)])
481toList = coerce (M.toList :: M.IntMap a -> [(Int, a)])
494{-# INLINE toList #-}
482{-# INLINE toList #-}
495
483
496−fromList :: forall a. [(Int, a)] -> MonoidalIntMap a
484+fromList :: forall a. Semigroup a => [(Int, a)] -> MonoidalIntMap a
497−fromList = coerce (M.fromList :: [(Int, a)] -> M.IntMap a)
485+fromList = fromListWith (<>)
498{-# INLINE fromList #-}
486{-# INLINE fromList #-}
499
487
500fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
488fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
@@ -513,8 +501,8 @@ toDescList :: forall a. MonoidalIntMap a -> [(Int, a)]
513toDescList = coerce (M.toDescList :: M.IntMap a -> [(Int, a)])
501toDescList = coerce (M.toDescList :: M.IntMap a -> [(Int, a)])
514{-# INLINE toDescList #-}
502{-# INLINE toDescList #-}
515
503
516−fromAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
504+fromAscList :: forall a. Semigroup a => [(Int, a)] -> MonoidalIntMap a
517−fromAscList = coerce (M.fromAscList :: [(Int, a)] -> M.IntMap a)
505+fromAscList = fromAscListWith (<>)
518{-# INLINE fromAscList #-}
506{-# INLINE fromAscList #-}
519
507
520fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
508fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
src/Data/Map/Monoidal.hs+8−20
@@ -151,12 +151,6 @@ import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
151import Data.Functor.Classes
151import Data.Functor.Classes
152#endif
152#endif
153import Data.Align
153import Data.Align
154−#ifdef MIN_VERSION_semialign
155−import Data.Semialign (Unalign)
156−#if MIN_VERSION_semialign(1,1,0)
157−import Data.Zip (Zip)
158−#endif
159−#endif
160
154
161-- | A 'Map' with monoidal accumulation
155-- | A 'Map' with monoidal accumulation
162newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
156newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
@@ -166,12 +160,6 @@ newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
166 , Data, Typeable, Align
160 , Data, Typeable, Align
167#if MIN_VERSION_these(0,8,0)
161#if MIN_VERSION_these(0,8,0)
168 , Semialign
162 , Semialign
169−#endif
170−#ifdef MIN_VERSION_semialign
171− , Unalign
172−#if MIN_VERSION_semialign(1,1,0)
173− , Zip
174−#endif
175#endif
163#endif
176 )
164 )
177
165
@@ -335,8 +323,8 @@ empty :: forall k a. MonoidalMap k a
335empty = coerce (M.empty :: M.Map k a)
323empty = coerce (M.empty :: M.Map k a)
336{-# INLINE empty #-}
324{-# INLINE empty #-}
337
325
338−insert :: forall k a. Ord k => k -> a -> MonoidalMap k a -> MonoidalMap k a
326+insert :: forall k a. (Ord k, Semigroup a) => k -> a -> MonoidalMap k a -> MonoidalMap k a
339−insert = coerce (M.insert :: k -> a -> M.Map k a -> M.Map k a)
327+insert = insertWith (<>)
340{-# INLINE insert #-}
328{-# INLINE insert #-}
341
329
342insertWith :: forall k a. Ord k => (a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
330insertWith :: forall k a. Ord k => (a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
@@ -435,8 +423,8 @@ mapAccumRWithKey :: forall k a b c. (a -> k -> b -> (a, c)) -> a -> MonoidalMap
435mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> M.Map k b -> (a, M.Map k c))
423mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> M.Map k b -> (a, M.Map k c))
436{-# INLINE mapAccumRWithKey #-}
424{-# INLINE mapAccumRWithKey #-}
437
425
438−mapKeys :: forall k1 k2 a. Ord k2 => (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
426+mapKeys :: forall k1 k2 a. (Ord k2, Semigroup a) => (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
439−mapKeys = coerce (M.mapKeys :: (k1 -> k2) -> M.Map k1 a -> M.Map k2 a)
427+mapKeys = mapKeysWith (<>)
440{-# INLINE mapKeys #-}
428{-# INLINE mapKeys #-}
441
429
442mapKeysWith :: forall k1 k2 a. Ord k2 => (a -> a -> a) -> (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
430mapKeysWith :: forall k1 k2 a. Ord k2 => (a -> a -> a) -> (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
@@ -513,8 +501,8 @@ toList :: forall k a. MonoidalMap k a -> [(k, a)]
513toList = coerce (M.toList :: M.Map k a -> [(k, a)])
501toList = coerce (M.toList :: M.Map k a -> [(k, a)])
514{-# INLINE toList #-}
502{-# INLINE toList #-}
515
503
516−fromList :: forall k a. Ord k => [(k, a)] -> MonoidalMap k a
504+fromList :: forall k a. (Ord k, Semigroup a) => [(k, a)] -> MonoidalMap k a
517−fromList = coerce (M.fromList :: [(k, a)] -> M.Map k a)
505+fromList = fromListWith (<>)
518{-# INLINE fromList #-}
506{-# INLINE fromList #-}
519
507
520fromListWith :: forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
508fromListWith :: forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
@@ -533,8 +521,8 @@ toDescList :: forall k a. MonoidalMap k a -> [(k, a)]
533toDescList = coerce (M.toDescList :: M.Map k a -> [(k, a)])
521toDescList = coerce (M.toDescList :: M.Map k a -> [(k, a)])
534{-# INLINE toDescList #-}
522{-# INLINE toDescList #-}
535
523
536−fromAscList :: forall k a. Eq k => [(k, a)] -> MonoidalMap k a
524+fromAscList :: forall k a. (Eq k, Semigroup a) => [(k, a)] -> MonoidalMap k a
537−fromAscList = coerce (M.fromAscList :: [(k, a)] -> M.Map k a)
525+fromAscList = fromAscListWith (<>)
538{-# INLINE fromAscList #-}
526{-# INLINE fromAscList #-}
539
527
540fromAscListWith :: forall k a. Eq k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
528fromAscListWith :: forall k a. Eq k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
src/Data/Map/Monoidal/Strict.hs+4−14
@@ -151,12 +151,6 @@ import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
151import Data.Functor.Classes
151import Data.Functor.Classes
152#endif
152#endif
153import Data.Align
153import Data.Align
154−#ifdef MIN_VERSION_semialign
155−import Data.Semialign (Unalign)
156−#if MIN_VERSION_semialign(1,1,0)
157−import Data.Zip (Zip)
158−#endif
159−#endif
160
154
161-- | A 'Map' with monoidal accumulation
155-- | A 'Map' with monoidal accumulation
162newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
156newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
@@ -166,12 +160,6 @@ newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
166 , Data, Typeable, Align
160 , Data, Typeable, Align
167#if MIN_VERSION_these(0,8,0)
161#if MIN_VERSION_these(0,8,0)
168 , Semialign
162 , Semialign
169−#endif
170−#ifdef MIN_VERSION_semialign
171− , Unalign
172−#if MIN_VERSION_semialign(1,1,0)
173− , Zip
174−#endif
175#endif
163#endif
176 )
164 )
177
165
@@ -334,8 +322,8 @@ empty :: forall k a. MonoidalMap k a
334empty = coerce (M.empty :: M.Map k a)
322empty = coerce (M.empty :: M.Map k a)
335{-# INLINE empty #-}
323{-# INLINE empty #-}
336
324
337−insert :: forall k a. Ord k => k -> a -> MonoidalMap k a -> MonoidalMap k a
325+insert :: forall k a. (Ord k, Semigroup a) => k -> a -> MonoidalMap k a -> MonoidalMap k a
338−insert = coerce (M.insert :: k -> a -> M.Map k a -> M.Map k a)
326+insert = insertWith (<>)
339{-# INLINE insert #-}
327{-# INLINE insert #-}
340
328
341insertWith :: forall k a. Ord k => (a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
329insertWith :: forall k a. Ord k => (a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
@@ -699,3 +687,5 @@ maxViewWithKey = coerce (M.maxViewWithKey :: M.Map k a -> Maybe ((k, a), M.Map k
699valid :: forall k a. Ord k => MonoidalMap k a -> Bool
687valid :: forall k a. Ord k => MonoidalMap k a -> Bool
700valid = coerce (M.valid :: Ord k => M.Map k a -> Bool)
688valid = coerce (M.valid :: Ord k => M.Map k a -> Bool)
701{-# INLINE valid #-}
689{-# INLINE valid #-}
690+
691+