Skip to content

Commit e423601

Browse files
committed
Properly handle older GHC and container combinations
Two conflicting issues: * cabal-install on Travis-CI was selecting newer versions of containers than shipped with the corresponding version of GHC (thus hiding the other issue). * foldlWithKey' was added in containers-0.4.2, and thus not available in older versions. We now fudge it with foldWithKey, which dates back to 0.1 (and thus always available).
2 parents e295037 + 494882a commit e423601

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

.travis.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ before_cache:
1111
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
1212
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
1313

14+
env:
15+
global:
16+
- CONF=""
17+
1418
matrix:
15-
fast_finish: true
1619
include:
17-
- env: CABALVER=1.16 GHCVER=7.0.4
20+
- env: CABALVER=1.16 GHCVER=7.0.4 CONF="-f -containers042"
1821
compiler: ": #GHC 7.0.4"
1922
addons: {apt: {packages: [cabal-install-1.16,ghc-7.0.4], sources: [hvr-ghc]}}
20-
- env: CABALVER=1.16 GHCVER=7.2.2
23+
- env: CABALVER=1.16 GHCVER=7.2.2 CONF="-f -containers042"
2124
compiler: ": #GHC 7.2.2"
2225
addons: {apt: {packages: [cabal-install-1.16,ghc-7.2.2], sources: [hvr-ghc]}}
2326
- env: CABALVER=1.16 GHCVER=7.4.2
@@ -56,11 +59,11 @@ install:
5659
fi
5760
- travis_retry cabal update -v
5861
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
59-
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
62+
- cabal install --only-dependencies --enable-tests --enable-benchmarks $CONF --dry -v > installplan.txt
6063
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
6164

6265
# check whether current requested install-plan matches cached package-db snapshot
63-
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
66+
- if diff -u $HOME/.cabsnap/installplan.txt installplan.txt;
6467
then
6568
echo "cabal build-cache HIT";
6669
rm -rfv .ghc;
@@ -86,7 +89,7 @@ install:
8689
# any command which exits with a non-zero exit code causes the build to fail.
8790
script:
8891
- if [ -f configure.ac ]; then autoreconf -i; fi
89-
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
92+
- cabal configure --enable-tests --enable-benchmarks -v2 $CONF # -v2 provides useful information for debugging
9093
- cabal build # this builds all libraries and executables (including tests/benchmarks)
9194
- cabal test
9295
- cabal check
@@ -96,7 +99,7 @@ script:
9699
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
97100
# `cabal install --force-reinstalls dist/*-*.tar.gz`
98101
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
99-
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
102+
(cd dist && cabal install --force-reinstalls $CONF "$SRC_TGZ")
100103

101104
# Check the fgl-arbitrary sub-package
102105
- cd fgl-arbitrary
@@ -110,5 +113,4 @@ script:
110113
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
111114
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
112115

113-
114116
# EOF

Data/Graph/Inductive/PatriciaTree.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ addLists xs ys = xs ++ ys
273273

274274
addSucc :: forall a b . GraphRep a b -> Node -> Int -> IM.IntMap [b] -> GraphRep a b
275275
addSucc g0 v numAdd xs
276-
| numAdd < bulkThreshold = IM.foldlWithKey' go g0 xs
276+
| numAdd < bulkThreshold = foldlWithKey' go g0 xs
277277
where
278278
go :: GraphRep a b -> Node -> [b] -> GraphRep a b
279279
go g p l = IMS.adjust f p g
@@ -285,9 +285,19 @@ addSucc g v _ xs = IMS.differenceWith go g xs
285285
go (ps, l', ss) l = let !ss' = IM.insertWith addLists v l ss
286286
in Just (ps, l', ss')
287287

288+
foldlWithKey' :: (a -> IM.Key -> b -> a) -> a -> IntMap b -> a
289+
foldlWithKey' =
290+
#if MIN_VERSION_containers (0,4,2)
291+
IM.foldlWithKey'
292+
#else
293+
IM.foldWithKey . adjustFunc
294+
where
295+
adjustFunc f k b a = f a k b
296+
#endif
297+
288298
addPred :: forall a b . GraphRep a b -> Node -> Int -> IM.IntMap [b] -> GraphRep a b
289299
addPred g0 v numAdd xs
290-
| numAdd < bulkThreshold = IM.foldlWithKey' go g0 xs
300+
| numAdd < bulkThreshold = foldlWithKey' go g0 xs
291301
where
292302
go :: GraphRep a b -> Node -> [b] -> GraphRep a b
293303
go g p l = IMS.adjust f p g

fgl.cabal

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ test-suite fgl-tests {
109109
}
110110

111111
benchmark fgl-benchmark {
112+
if flag(containers042)
113+
buildable: True
114+
else
115+
buildable: False
116+
112117
default-language: Haskell98
113118

114119
type: exitcode-stdio-1.0

0 commit comments

Comments
 (0)