git.iko.soy/monoidal-containers
on master help sign in
Compatibility with GHC 8.4.1
commite0302a475a4a22b74cbcbd9bfc5371cc3cd5a8f2 authorBen Gamari <ben@smart-cactus.org> dateSat 10 Mar 2018, 12:50 (9 years ago) parentfe93b52
5 files changed+131−55
.travis.yml+102−45 monoidal-containers.cabal+4−3 src/Data/HashMap/Monoidal.hs+8−2 src/Data/Map/Monoidal.hs+8−2 src/Data/Map/Monoidal/Strict.hs+9−3
.travis.yml+102−45
@@ -1,8 +1,15 @@
1−# This file has been generated by `make_travis_yml_2.hs`
2−# see https://github.com/hvr/multi-ghc-travis for more information
1+# This Travis job script has been generated by a script via
2+#
3+# runghc make_travis_yml_2.hs 'monoidal-containers.cabal'
4+#
5+# For more information, see https://github.com/hvr/multi-ghc-travis
6+#
37language: c
48sudo: false
59
10+git:
11+ submodules: false # whether to recursively clone submodules
12+
613cache:
714 directories:
815 - $HOME/.cabal/packages
@@ -10,59 +17,109 @@ cache:
1017
1118before_cache:
1219 - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
13− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
20+ # remove files that are regenerated by 'cabal update'
21+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
22+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
23+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
24+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
25+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
26+
27+ - rm -rfv $HOME/.cabal/packages/head.hackage
1428
1529matrix:
1630 include:
17− - env: CABALVER=1.24 GHCVER=7.6.3
18− compiler: ": #GHC 7.6.3"
19− addons: {apt: {packages: [cabal-install-1.24,ghc-7.6.3], sources: [hvr-ghc]}}
20− - env: CABALVER=1.24 GHCVER=7.8.4
21− compiler: ": #GHC 7.8.4"
22− addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4], sources: [hvr-ghc]}}
23− - env: CABALVER=1.24 GHCVER=8.0.1
24− compiler: ": #GHC 8.0.1"
25− addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
31+ - compiler: "ghc-7.6.3"
32+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
33+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.6.3], sources: [hvr-ghc]}}
34+ - compiler: "ghc-7.8.4"
35+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
36+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
37+ - compiler: "ghc-8.0.2"
38+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
39+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
40+ - compiler: "ghc-8.2.2"
41+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
42+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}
43+ - compiler: "ghc-8.4.1"
44+ env: GHCHEAD=true
45+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}}
46+
47+ allow_failures:
48+ - compiler: "ghc-8.4.1"
2649
2750before_install:
28− - unset CC
29− - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
51+ - HC=${CC}
52+ - HCPKG=${HC/ghc/ghc-pkg}
53+ - unset CC
54+ - ROOTDIR=$(pwd)
55+ - mkdir -p $HOME/.local/bin
56+ - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
57+ - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
58+ - echo $HCNUMVER
3059
3160install:
32− - cabal --version
33− - BENCH=${BENCH---enable-benchmarks}
34− - TEST=${TEST---enable-tests}
35− - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
36− - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
37− then
38− zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
39− $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
40− fi
41− - travis_retry cabal update -v
42− - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
43− - cabal new-build ${TEST} ${BENCH} --dep
61+ - cabal --version
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+ - INSTALLED=${INSTALLED-true}
67+ - GHCHEAD=${GHCHEAD-false}
68+ - travis_retry cabal update -v
69+ - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
70+ - rm -fv cabal.project cabal.project.local
71+ # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
72+ - |
73+ if $GHCHEAD; then
74+ sed -i.bak 's/-- allow-newer:.*/allow-newer: *:base, *:template-haskell, *:ghc, *:Cabal/' ${HOME}/.cabal/config
75+
76+ echo 'repository head.hackage' >> ${HOME}/.cabal/config
77+ echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config
78+ echo ' secure: True' >> ${HOME}/.cabal/config
79+ echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
80+ echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
81+ echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
82+ echo ' key-threshold: 3' >> ${HOME}/.cabal.config
83+
84+ cabal new-update head.hackage -v
85+ fi
86+ - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
87+ - "printf 'packages: \".\"\\n' > cabal.project"
88+ - cat cabal.project
89+ - if [ -f "./configure.ac" ]; then
90+ (cd "." && autoreconf -i);
91+ fi
92+ - rm -f cabal.project.freeze
93+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
94+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
95+ - rm -rf .ghc.environment.* "."/dist
96+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
4497
4598# Here starts the actual work to be performed for the package under test;
4699# any command which exits with a non-zero exit code causes the build to fail.
47100script:
48− - if [ -f configure.ac ]; then autoreconf -i; fi
49− # this builds all libraries and executables (including tests/benchmarks)
50− - cabal new-build ${TEST} ${BENCH} -v2 # -v2 provides useful information for debugging
51−
52− # there's no 'cabal new-test' yet, so let's emulate for now
53− - TESTS=( $(awk 'tolower($0) ~ /^test-suite / { print $2 }' *.cabal) );
54− RC=true; for T in ${TESTS[@]}; do echo "== $T ==";
55− if dist-newstyle/build/*/build/$T/$T; then echo "= $T OK =";
56− else echo "= $T FAILED ="; RC=false; fi; done; $RC
57− - cabal sdist # test that a source-distribution can be generated
58−
59− # Check that the resulting source distribution can be built w/o and w tests
60− - SRC_BASENAME=$(cabal info . | awk '{print $2;exit}')
61− - tar -C dist/ -xf dist/$SRC_BASENAME.tar.gz
62− - "echo 'packages: *.cabal' > dist/$SRC_BASENAME/cabal.project"
63− - cd dist/$SRC_BASENAME/
64− - cabal new-build --disable-tests --disable-benchmarks
65− - rm -rf ./dist-newstyle
66− - cabal new-build ${TEST} ${BENCH}
101+ # test that source-distributions can be generated
102+ - (cd "." && cabal sdist)
103+ - mv "."/dist/monoidal-containers-*.tar.gz ${DISTDIR}/
104+ - cd ${DISTDIR} || false
105+ - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
106+ - "printf 'packages: monoidal-containers-*/*.cabal\\n' > cabal.project"
107+ - cat cabal.project
108+ # this builds all libraries and executables (without tests/benchmarks)
109+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
110+
111+ # Build with installed constraints for packages in global-db
112+ - if $INSTALLED; then echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh; else echo "Not building with installed constraints"; fi
113+
114+ # build & run tests, build benchmarks
115+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
116+
117+ # cabal check
118+ - (cd monoidal-containers-* && cabal check)
119+
120+ # haddock
121+ - rm -rf ./dist-newstyle
122+ - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
67123
124+# REGENDATA ["monoidal-containers.cabal"]
68125# EOF
monoidal-containers.cabal+4−3
@@ -23,7 +23,7 @@ copyright: (c) 2014 Ben Gamari
2323category: Data
2424build-type: Simple
2525cabal-version: >=1.10
26−tested-with: GHC ==7.6.3, GHC ==7.8.4, GHC ==8.0.1
26+tested-with: GHC ==7.6.3, GHC ==7.8.4, GHC ==8.0.2, GHC ==8.2.2, GHC ==8.4.1
2727
2828source-repository head
2929 type: git
@@ -38,12 +38,13 @@ library
3838 GeneralizedNewtypeDeriving,
3939 DeriveTraversable,
4040 DeriveDataTypeable
41− build-depends: base >=4.5 && <4.11,
41+ build-depends: base >=4.5 && <4.12,
4242 containers >=0.5 && <0.6,
4343 deepseq >=1.3 && <1.5,
4444 unordered-containers >= 0.2 && < 0.3,
4545 hashable >= 1.2 && < 1.3,
4646 lens >=4.4 && <5,
47− newtype >=0.2 && <0.3
47+ newtype >=0.2 && <0.3,
48+ semigroups >= 0.18 && < 0.19
4849 hs-source-dirs: src
4950 default-language: Haskell2010
src/Data/HashMap/Monoidal.hs+8−2
@@ -38,7 +38,7 @@ module Data.HashMap.Monoidal
3838
3939import Prelude hiding (lookup, map)
4040import Data.Maybe (fromMaybe)
41−import Data.Monoid
41+import Data.Semigroup
4242import Data.Foldable (Foldable)
4343import Control.Applicative (pure)
4444import Data.Data (Data)
@@ -92,11 +92,17 @@ instance Wrapped (MonoidalHashMap k a) where
9292 _Wrapped' = iso unpack pack
9393 {-# INLINE _Wrapped' #-}
9494
95+instance (Eq k, Hashable k, Semigroup a) => Semigroup (MonoidalHashMap k a) where
96+ MonoidalHashMap a <> MonoidalHashMap b = MonoidalHashMap $ M.unionWith (<>) a b
97+ {-# INLINE (<>) #-}
98+
9599instance (Eq k, Hashable k, Monoid a) => Monoid (MonoidalHashMap k a) where
96100 mempty = MonoidalHashMap mempty
97101 {-# INLINE mempty #-}
98− MonoidalHashMap a `mappend` MonoidalHashMap b = MonoidalHashMap $ M.unionWith mappend a b
102+#if !(MIN_VERSION_base(4,11,0))
103+ mappend (MonoidalHashMap a) (MonoidalHashMap b) = MonoidalHashMap $ M.unionWith mappend a b
99104 {-# INLINE mappend #-}
105+#endif
100106
101107instance Newtype (MonoidalHashMap k a) (M.HashMap k a) where
102108 pack = MonoidalHashMap
src/Data/Map/Monoidal.hs+8−2
@@ -28,7 +28,7 @@ module Data.Map.Monoidal
2828 , keys
2929 ) where
3030
31−import Data.Monoid
31+import Data.Semigroup
3232import Data.Foldable (Foldable)
3333import Data.Traversable (Traversable)
3434import Control.Applicative (Applicative, pure)
@@ -89,11 +89,17 @@ instance Wrapped (MonoidalMap k a) where
8989 _Wrapped' = iso unpack pack
9090 {-# INLINE _Wrapped' #-}
9191
92+instance (Ord k, Semigroup a) => Semigroup (MonoidalMap k a) where
93+ MonoidalMap a <> MonoidalMap b = MonoidalMap $ M.unionWith (<>) a b
94+ {-# INLINE (<>) #-}
95+
9296instance (Ord k, Monoid a) => Monoid (MonoidalMap k a) where
9397 mempty = MonoidalMap mempty
9498 {-# INLINE mempty #-}
95− MonoidalMap a `mappend` MonoidalMap b = MonoidalMap $ M.unionWith mappend a b
99+#if !(MIN_VERSION_base(4,11,0))
100+ mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith mappend a b
96101 {-# INLINE mappend #-}
102+#endif
97103
98104instance Newtype (MonoidalMap k a) (M.Map k a) where
99105 pack = MonoidalMap
src/Data/Map/Monoidal/Strict.hs+9−3
@@ -28,7 +28,7 @@ module Data.Map.Monoidal.Strict
2828 , keys
2929 ) where
3030
31−import Data.Monoid
31+import Data.Semigroup
3232import Data.Foldable (Foldable)
3333import Data.Traversable (Traversable)
3434import Control.Applicative (Applicative, pure)
@@ -89,11 +89,17 @@ instance Wrapped (MonoidalMap k a) where
8989 _Wrapped' = iso unpack pack
9090 {-# INLINE _Wrapped' #-}
9191
92−instance (Ord k, Monoid a) => Monoid (MonoidalMap k a) where
92+instance (Ord k, Semigroup a) => Semigroup (MonoidalMap k a) where
93+ MonoidalMap a <> MonoidalMap b = MonoidalMap $ M.unionWith (<>) a b
94+ {-# INLINE (<>) #-}
95+
96+instance (Ord k, Semigroup a, Monoid a) => Monoid (MonoidalMap k a) where
9397 mempty = MonoidalMap mempty
9498 {-# INLINE mempty #-}
95− MonoidalMap a `mappend` MonoidalMap b = MonoidalMap $ M.unionWith mappend a b
99+#if !(MIN_VERSION_base(4,11,0))
100+ mappend (MonoidalMap a) (MonoidalMap b) = MonoidalMap $ M.unionWith mappend a b
96101 {-# INLINE mappend #-}
102+#endif
97103
98104instance Newtype (MonoidalMap k a) (M.Map k a) where
99105 pack = MonoidalMap