Skip to content

Commit 8594d5d

Browse files
committed
Merge pull request #114 from hvr/pr/ghc-8-cleanups
GHC 8.0 Cleanups
2 parents 0696e2d + 2fb6073 commit 8594d5d

File tree

6 files changed

+108
-38
lines changed

6 files changed

+108
-38
lines changed

.travis.yml

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,84 @@
1-
# NB: don't set `language: haskell` here
1+
# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2+
language: c
3+
sudo: false
24

3-
# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
4-
env:
5-
- GHCVER=7.4.2
6-
- GHCVER=7.6.3
7-
- GHCVER=7.8.1
8-
# - GHCVER=head # see section about GHC HEAD snapshots
5+
cache:
6+
directories:
7+
- $HOME/.cabsnap
8+
- $HOME/.cabal/packages
9+
10+
before_cache:
11+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12+
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
13+
14+
matrix:
15+
include:
16+
- env: CABALVER=1.16 GHCVER=7.4.2
17+
compiler: ": #GHC 7.4.2"
18+
addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
19+
- env: CABALVER=1.16 GHCVER=7.6.3
20+
compiler: ": #GHC 7.6.3"
21+
addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
22+
- env: CABALVER=1.18 GHCVER=7.8.4
23+
compiler: ": #GHC 7.8.4"
24+
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
25+
- env: CABALVER=1.22 GHCVER=7.10.3
26+
compiler: ": #GHC 7.10.3"
27+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
928

10-
# Note: the distinction between `before_install` and `install` is not important.
1129
before_install:
12-
- sudo add-apt-repository -y ppa:hvr/ghc
13-
- sudo apt-get update
14-
- sudo apt-get install cabal-install-1.18 ghc-$GHCVER happy
15-
- export PATH=/opt/ghc/$GHCVER/bin:$PATH
30+
- unset CC
31+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
1632

17-
# Benchmarks aren't built as installing their dependencies causes a
18-
# dependency cycle.
1933
install:
20-
- cabal-1.18 update
21-
- cabal-1.18 install --only-dependencies --enable-tests
34+
- cabal --version
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 install --only-dependencies --enable-tests --dry -v > installplan.txt
44+
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
2245

23-
# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
24-
script:
25-
- cabal-1.18 configure --enable-tests -v2 # -v2 provides useful information for debugging
26-
- cabal-1.18 build # this builds all libraries and executables (including tests/benchmarks)
27-
- cabal-1.18 test
28-
- cabal-1.18 sdist # tests that a source-distribution can be generated
29-
30-
# The following scriptlet checks that the resulting source distribution can be built & installed
31-
- export SRC_TGZ=$(cabal-1.18 info . | awk '{print $2 ".tar.gz";exit}') ;
32-
cd dist/;
33-
if [ -f "$SRC_TGZ" ]; then
34-
cabal-1.18 install "$SRC_TGZ";
46+
# check whether current requested install-plan matches cached package-db snapshot
47+
- if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
48+
then
49+
echo "cabal build-cache HIT";
50+
rm -rfv .ghc;
51+
cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
52+
cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
3553
else
36-
echo "expected '$SRC_TGZ' not found";
37-
exit 1;
54+
echo "cabal build-cache MISS";
55+
rm -rf $HOME/.cabsnap;
56+
mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
57+
cabal install --only-dependencies --enable-tests;
58+
fi
59+
60+
# snapshot package-db on cache miss
61+
- if [ ! -d $HOME/.cabsnap ];
62+
then
63+
echo "snapshotting package-db to build-cache";
64+
mkdir $HOME/.cabsnap;
65+
cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
66+
cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
3867
fi
68+
69+
# Here starts the actual work to be performed for the package under test;
70+
# any command which exits with a non-zero exit code causes the build to fail.
71+
script:
72+
- if [ -f configure.ac ]; then autoreconf -i; fi
73+
- cabal configure --enable-tests -v2 # -v2 provides useful information for debugging
74+
- cabal build # this builds all libraries and executables (including tests)
75+
- cabal test
76+
- cabal sdist # tests that a source-distribution can be generated
77+
78+
# Check that the resulting source distribution can be built & installed.
79+
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
80+
# `cabal install --force-reinstalls dist/*-*.tar.gz`
81+
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
82+
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
83+
84+
# EOF

Data/HashMap/Array.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import qualified Data.Traversable as Traversable
5353
import Control.Applicative (Applicative)
5454
#endif
5555
import Control.DeepSeq
56-
import Control.Monad.ST hiding (runST)
5756
-- GHC 7.7 exports toList/fromList from GHC.Exts
5857
-- In order to avoid warnings on previous GHC versions, we provide
5958
-- an explicit import list instead of only hiding the offending symbols

Data/HashMap/Base.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ import Data.Monoid (Monoid(mempty, mappend))
9595
import Data.Traversable (Traversable(..))
9696
import Data.Word (Word)
9797
#endif
98+
#if __GLASGOW_HASKELL__ >= 711
99+
import Data.Semigroup (Semigroup((<>)))
100+
#endif
98101
import Control.DeepSeq (NFData(rnf))
99102
import Control.Monad.ST (ST)
100103
import Data.Bits ((.&.), (.|.), complement)
@@ -163,10 +166,20 @@ instance Functor (HashMap k) where
163166
instance Foldable.Foldable (HashMap k) where
164167
foldr f = foldrWithKey (const f)
165168

169+
#if __GLASGOW_HASKELL__ >= 711
170+
instance (Eq k, Hashable k) => Semigroup (HashMap k v) where
171+
(<>) = union
172+
{-# INLINE (<>) #-}
173+
#endif
174+
166175
instance (Eq k, Hashable k) => Monoid (HashMap k v) where
167176
mempty = empty
168177
{-# INLINE mempty #-}
178+
#if __GLASGOW_HASKELL__ >= 711
179+
mappend = (<>)
180+
#else
169181
mappend = union
182+
#endif
170183
{-# INLINE mappend #-}
171184

172185
instance (Data k, Data v, Eq k, Hashable k) => Data (HashMap k v) where
@@ -498,8 +511,7 @@ unsafeInsertWith :: forall k v. (Eq k, Hashable k)
498511
unsafeInsertWith f k0 v0 m0 = runST (go h0 k0 v0 0 m0)
499512
where
500513
h0 = hash k0
501-
go :: (Eq k, Hashable k) => Hash -> k -> v -> Shift -> HashMap k v
502-
-> ST s (HashMap k v)
514+
go :: Hash -> k -> v -> Shift -> HashMap k v -> ST s (HashMap k v)
503515
go !h !k x !_ Empty = return $! Leaf h (L k x)
504516
go h k x s (Leaf hy l@(L ky y))
505517
| hy == h = if ky == k

Data/HashMap/Unsafe.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ module Data.HashMap.Unsafe
1313
) where
1414

1515
import GHC.Base (realWorld#)
16-
import GHC.ST hiding (runST, runSTRep)
16+
import qualified GHC.ST as ST
1717

1818
-- | Return the value computed by a state transformer computation.
1919
-- The @forall@ ensures that the internal state used by the 'ST'
2020
-- computation is inaccessible to the rest of the program.
21-
runST :: (forall s. ST s a) -> a
22-
runST st = runSTRep (case st of { ST st_rep -> st_rep })
21+
runST :: (forall s. ST.ST s a) -> a
22+
runST st = runSTRep (case st of { ST.ST st_rep -> st_rep })
2323
{-# INLINE runST #-}
2424

25-
runSTRep :: (forall s. STRep s a) -> a
25+
runSTRep :: (forall s. ST.STRep s a) -> a
2626
runSTRep st_rep = case st_rep realWorld# of
2727
(# _, r #) -> r
2828
{-# INLINE [0] runSTRep #-}

Data/HashSet.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ import Control.DeepSeq (NFData(..))
7676
import Data.Data hiding (Typeable)
7777
import Data.HashMap.Base (HashMap, foldrWithKey)
7878
import Data.Hashable (Hashable(hashWithSalt))
79-
#if __GLASGOW_HASKELL__ < 709
79+
#if __GLASGOW_HASKELL__ >= 711
80+
import Data.Semigroup (Semigroup(..), Monoid(..))
81+
#elif __GLASGOW_HASKELL__ < 709
8082
import Data.Monoid (Monoid(..))
8183
#endif
8284
import GHC.Exts (build)
@@ -114,10 +116,20 @@ instance Foldable.Foldable HashSet where
114116
foldr = Data.HashSet.foldr
115117
{-# INLINE foldr #-}
116118

119+
#if __GLASGOW_HASKELL__ >= 711
120+
instance (Hashable a, Eq a) => Semigroup (HashSet a) where
121+
(<>) = union
122+
{-# INLINE (<>) #-}
123+
#endif
124+
117125
instance (Hashable a, Eq a) => Monoid (HashSet a) where
118126
mempty = empty
119127
{-# INLINE mempty #-}
128+
#if __GLASGOW_HASKELL__ >= 711
129+
mappend = (<>)
130+
#else
120131
mappend = union
132+
#endif
121133
{-# INLINE mappend #-}
122134

123135
instance (Eq a, Hashable a, Read a) => Read (HashSet a) where

unordered-containers.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ category: Data
2020
build-type: Simple
2121
cabal-version: >=1.8
2222
extra-source-files: CHANGES.md
23+
tested-with: GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2
2324

2425
flag debug
2526
description: Enable debug support

0 commit comments

Comments
 (0)