Skip to content

Commit 48d19a8

Browse files
committed
Fix the build post-Semigroup–Monoid Proposal
1 parent 1b48d0c commit 48d19a8

File tree

5 files changed

+137
-64
lines changed

5 files changed

+137
-64
lines changed

Diff for: .gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@
88
/dist/*
99
.cabal-sandbox
1010
cabal.sandbox.config
11+
dist-*
12+
cabal-dev
13+
*.chi
14+
*.chs.h
15+
*.dyn_o
16+
*.dyn_hi
17+
.hsenv
18+
*.prof
19+
*.aux
20+
*.hp
21+
*.eventlog
22+
.stack-work/
23+
cabal.project.local
24+
cabal.project.local~
25+
.HTF/
26+
.ghc.environment.*

Diff for: .travis.yml

+109-58
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,132 @@
1-
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
1+
# This Travis job script has been generated by a script via
2+
#
3+
# make_travis_yml_2.hs '-o' 'travis.yml' 'unordered-containers.cabal'
4+
#
5+
# For more information, see https://github.com/hvr/multi-ghc-travis
6+
#
27
language: c
38
sudo: false
49

10+
git:
11+
submodules: false # whether to recursively clone submodules
12+
513
cache:
614
directories:
7-
- $HOME/.cabsnap
815
- $HOME/.cabal/packages
16+
- $HOME/.cabal/store
917

1018
before_cache:
1119
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12-
- 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 -fv $HOME/.cabal/packages/head.hackage
1328

1429
matrix:
1530
include:
16-
- env: CABALVER=1.24 GHCVER=7.8.4
17-
compiler: ": #GHC 7.8.4"
18-
addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4], sources: [hvr-ghc]}}
19-
- env: CABALVER=1.24 GHCVER=7.10.3
20-
compiler: ": #GHC 7.10.3"
21-
addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3], sources: [hvr-ghc]}}
22-
- env: CABALVER=1.24 GHCVER=8.0.1
23-
compiler: ": #GHC 8.0.1"
24-
addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
31+
- compiler: "ghc-7.8.4"
32+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
33+
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.0,ghc-7.8.4], sources: [hvr-ghc]}}
34+
- compiler: "ghc-7.10.3"
35+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
36+
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.0,ghc-7.10.3], 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-2.0,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-2.0,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+
- compiler: "ghc-head"
47+
env: GHCHEAD=true
48+
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}
49+
50+
allow_failures:
51+
- compiler: "ghc-8.4.1"
52+
- compiler: "ghc-head"
2553

2654
before_install:
27-
- unset CC
28-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
55+
- HC=${CC}
56+
- HCPKG=${HC/ghc/ghc-pkg}
57+
- unset CC
58+
- "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH"
2959

3060
install:
31-
- cabal --version
32-
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
33-
- if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
34-
then
35-
zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
36-
$HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
37-
fi
38-
- travis_retry cabal update -v
39-
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
40-
- cabal install --only-dependencies --enable-tests --disable-benchmarks --dry -v > installplan.txt
41-
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
42-
43-
# check whether current requested install-plan matches cached package-db snapshot
44-
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
45-
then
46-
echo "cabal build-cache HIT";
47-
rm -rfv .ghc;
48-
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
49-
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
50-
else
51-
echo "cabal build-cache MISS";
52-
rm -rf $HOME/.cabsnap;
53-
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
54-
cabal install --only-dependencies --enable-tests --disable-benchmarks;
55-
fi
56-
57-
# snapshot package-db on cache miss
58-
- if [ ! -d $HOME/.cabsnap ];
59-
then
60-
echo "snapshotting package-db to build-cache";
61-
mkdir $HOME/.cabsnap;
62-
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
63-
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
64-
fi
61+
- cabal --version
62+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
63+
- BENCH=${BENCH---disable-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.local
71+
- "printf 'packages: \".\"\\n' > cabal.project"
72+
# Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
73+
- |
74+
if $GHCHEAD; then
75+
echo 'allow-newer: *:base, *:template-haskell' >> cabal.project
76+
echo 'repository head.hackage' >> cabal.project
77+
echo ' url: http://head.hackage.haskell.org/' >> cabal.project
78+
echo ' secure: True' >> cabal.project
79+
echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> cabal.project
80+
echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> cabal.project
81+
echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> cabal.project
82+
echo ' key-threshold: 3' >> cabal.project
83+
fi
84+
- cat cabal.project
85+
- if $GHCHEAD; then cabal new-update head.hackage -v; fi
86+
- if [ -f "./configure.ac" ]; then
87+
(cd "."; autoreconf -i);
88+
fi
89+
- rm -f cabal.project.freeze
90+
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
91+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
92+
- rm -rf "."/.ghc.environment.* "."/dist
93+
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
6594

6695
# Here starts the actual work to be performed for the package under test;
6796
# any command which exits with a non-zero exit code causes the build to fail.
6897
script:
69-
- if [ -f configure.ac ]; then autoreconf -i; fi
70-
- cabal configure --enable-tests --disable-benchmarks -v2 # -v2 provides useful information for debugging
71-
- cabal build # this builds all libraries and executables (including tests)
72-
- cabal test
73-
- cabal sdist # tests that a source-distribution can be generated
98+
# test that source-distributions can be generated
99+
- (cd "." && cabal sdist)
100+
- mv "."/dist/unordered-containers-*.tar.gz ${DISTDIR}/
101+
- cd ${DISTDIR} || false
102+
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
103+
- "printf 'packages: unordered-containers-*/*.cabal\\n' > cabal.project"
104+
# Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
105+
- |
106+
if $GHCHEAD; then
107+
echo 'allow-newer: *:base, *:template-haskell' >> cabal.project
108+
echo 'repository head.hackage' >> cabal.project
109+
echo ' url: http://head.hackage.haskell.org/' >> cabal.project
110+
echo ' secure: True' >> cabal.project
111+
echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> cabal.project
112+
echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> cabal.project
113+
echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> cabal.project
114+
echo ' key-threshold: 3' >> cabal.project
115+
fi
116+
- cat cabal.project
117+
# this builds all libraries and executables (without tests/benchmarks)
118+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
119+
120+
# Build with installed constraints for packages in global-db
121+
- 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
122+
123+
# build & run tests, build benchmarks
124+
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
125+
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
74126

75-
# Check that the resulting source distribution can be built & installed.
76-
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
77-
# `cabal install --force-reinstalls dist/*-*.tar.gz`
78-
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
79-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
127+
# haddock
128+
- rm -rf ./dist-newstyle
129+
- if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi
80130

131+
# REGENDATA ["-o","travis.yml","unordered-containers.cabal"]
81132
# EOF

Diff for: Data/HashSet.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import Data.Data hiding (Typeable)
7777
import Data.HashMap.Base (HashMap, foldrWithKey, equalKeys)
7878
import Data.Hashable (Hashable(hashWithSalt))
7979
#if __GLASGOW_HASKELL__ >= 711
80-
import Data.Semigroup (Semigroup(..), Monoid(..))
80+
import Data.Semigroup (Semigroup(..))
8181
#elif __GLASGOW_HASKELL__ < 709
8282
import Data.Monoid (Monoid(..))
8383
#endif

Diff for: unordered-containers.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ category: Data
2020
build-type: Simple
2121
cabal-version: >=1.8
2222
extra-source-files: CHANGES.md
23-
tested-with: GHC==8.0.1, GHC==7.10.3, GHC==7.8.4
23+
tested-with: GHC==8.4.1, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4
2424

2525
flag debug
2626
description: Enable debug support

Diff for: utils/Stats.hs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE RecordWildCards #-}
23
{-# OPTIONS_GHC -funbox-strict-fields #-}
34
module Stats where
45

56
import qualified Data.HashMap.Array as A
67
import Data.HashMap.Base (HashMap(..))
78
import qualified Data.HashMap.Base as HM
8-
import Data.Monoid
9+
import Data.Semigroup
910

1011
data Histogram = H {
1112
empty :: !Int
@@ -15,16 +16,21 @@ data Histogram = H {
1516
, collision :: !Int
1617
} deriving Show
1718

18-
instance Monoid Histogram where
19-
mempty = H 0 0 0 0 0
20-
mappend h1 h2 = H {
19+
instance Semigroup Histogram where
20+
h1 <> h2 = H {
2121
empty = empty h1 + empty h2
2222
, leaf = leaf h1 + leaf h2
2323
, bitmapIndexed = bitmapIndexed h1 + bitmapIndexed h2
2424
, full = full h1 + full h2
2525
, collision = collision h1 + collision h2
2626
}
2727

28+
instance Monoid Histogram where
29+
mempty = H 0 0 0 0 0
30+
#if __GLASGOW_HASKELL__ < 803
31+
mappend = (<>)
32+
#endif
33+
2834
-- | Count the number of node types at each level
2935
nodeHistogram :: HM.HashMap k v -> [Histogram]
3036
nodeHistogram Empty = [mempty { empty = 1 }]

0 commit comments

Comments
 (0)