Skip to content

Commit d90ed09

Browse files
authored
Drop support for GHC < 8 (#323)
This prepares u-c for supporting hashable-1.4, as discussed in #318.
1 parent 3d9efe3 commit d90ed09

File tree

13 files changed

+83
-216
lines changed

13 files changed

+83
-216
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.13.20210525
11+
# version: 0.13.20211030
1212
#
13-
# REGENDATA ("0.13.20210525",["github","--benchmarks-jobs= >=7.10","--installed=-containers","--installed=-binary","unordered-containers.cabal","--branches=master"])
13+
# REGENDATA ("0.13.20211030",["github","--benchmarks-jobs= >=7.10","--installed=-containers","--installed=-binary","unordered-containers.cabal","--branches=master"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -31,56 +31,97 @@ jobs:
3131
matrix:
3232
include:
3333
- compiler: ghc-9.0.1
34+
compilerKind: ghc
35+
compilerVersion: 9.0.1
36+
setup-method: hvr-ppa
3437
allow-failure: false
35-
- compiler: ghc-8.10.4
38+
- compiler: ghc-8.10.7
39+
compilerKind: ghc
40+
compilerVersion: 8.10.7
41+
setup-method: ghcup
3642
allow-failure: false
3743
- compiler: ghc-8.8.4
44+
compilerKind: ghc
45+
compilerVersion: 8.8.4
46+
setup-method: hvr-ppa
3847
allow-failure: false
3948
- compiler: ghc-8.6.5
49+
compilerKind: ghc
50+
compilerVersion: 8.6.5
51+
setup-method: hvr-ppa
4052
allow-failure: false
4153
- compiler: ghc-8.4.4
54+
compilerKind: ghc
55+
compilerVersion: 8.4.4
56+
setup-method: hvr-ppa
4257
allow-failure: false
4358
- compiler: ghc-8.2.2
59+
compilerKind: ghc
60+
compilerVersion: 8.2.2
61+
setup-method: hvr-ppa
4462
allow-failure: false
4563
- compiler: ghc-8.0.2
46-
allow-failure: false
47-
- compiler: ghc-7.10.3
48-
allow-failure: false
49-
- compiler: ghc-7.8.4
64+
compilerKind: ghc
65+
compilerVersion: 8.0.2
66+
setup-method: hvr-ppa
5067
allow-failure: false
5168
fail-fast: false
5269
steps:
5370
- name: apt
5471
run: |
5572
apt-get update
56-
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
57-
apt-add-repository -y 'ppa:hvr/ghc'
58-
apt-get update
59-
apt-get install -y $CC cabal-install-3.4
73+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
74+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
75+
mkdir -p "$HOME/.ghcup/bin"
76+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
77+
chmod a+x "$HOME/.ghcup/bin/ghcup"
78+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
79+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
80+
else
81+
apt-add-repository -y 'ppa:hvr/ghc'
82+
apt-get update
83+
apt-get install -y "$HCNAME"
84+
mkdir -p "$HOME/.ghcup/bin"
85+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
86+
chmod a+x "$HOME/.ghcup/bin/ghcup"
87+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
88+
fi
6089
env:
61-
CC: ${{ matrix.compiler }}
90+
HCKIND: ${{ matrix.compilerKind }}
91+
HCNAME: ${{ matrix.compiler }}
92+
HCVER: ${{ matrix.compilerVersion }}
6293
- name: Set PATH and environment variables
6394
run: |
6495
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
65-
echo "LANG=C.UTF-8" >> $GITHUB_ENV
66-
echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
67-
echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
68-
HCDIR=$(echo "/opt/$CC" | sed 's/-/\//')
69-
HCNAME=ghc
70-
HC=$HCDIR/bin/$HCNAME
71-
echo "HC=$HC" >> $GITHUB_ENV
72-
echo "HCPKG=$HCDIR/bin/$HCNAME-pkg" >> $GITHUB_ENV
73-
echo "HADDOCK=$HCDIR/bin/haddock" >> $GITHUB_ENV
74-
echo "CABAL=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
96+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
97+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
98+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
99+
HCDIR=/opt/$HCKIND/$HCVER
100+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
101+
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
102+
echo "HC=$HC" >> "$GITHUB_ENV"
103+
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
104+
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
105+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
106+
else
107+
HC=$HCDIR/bin/$HCKIND
108+
echo "HC=$HC" >> "$GITHUB_ENV"
109+
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
110+
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
111+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
112+
fi
113+
75114
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
76-
echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
77-
echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
78-
if [ $((HCNUMVER >= 71000)) -ne 0 ] ; then echo "ARG_BENCH=--enable-benchmarks" >> $GITHUB_ENV ; else echo "ARG_BENCH=--disable-benchmarks" >> $GITHUB_ENV ; fi
79-
echo "HEADHACKAGE=false" >> $GITHUB_ENV
80-
echo "ARG_COMPILER=--$HCNAME --with-compiler=$HC" >> $GITHUB_ENV
81-
echo "GHCJSARITH=0" >> $GITHUB_ENV
115+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
116+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
117+
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
118+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
119+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
120+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
82121
env:
83-
CC: ${{ matrix.compiler }}
122+
HCKIND: ${{ matrix.compilerKind }}
123+
HCNAME: ${{ matrix.compiler }}
124+
HCVER: ${{ matrix.compilerVersion }}
84125
- name: env
85126
run: |
86127
env
@@ -141,7 +182,8 @@ jobs:
141182
- name: generate cabal.project
142183
run: |
143184
PKGDIR_unordered_containers="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/unordered-containers-[0-9.]*')"
144-
echo "PKGDIR_unordered_containers=${PKGDIR_unordered_containers}" >> $GITHUB_ENV
185+
echo "PKGDIR_unordered_containers=${PKGDIR_unordered_containers}" >> "$GITHUB_ENV"
186+
rm -f cabal.project cabal.project.local
145187
touch cabal.project
146188
touch cabal.project.local
147189
echo "packages: ${PKGDIR_unordered_containers}" >> cabal.project

Data/HashMap/Internal.hs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,11 @@ module Data.HashMap.Internal
137137
, adjust#
138138
) where
139139

140-
#if __GLASGOW_HASKELL__ < 710
141-
import Control.Applicative ((<$>), Applicative(pure))
142-
import Data.Monoid (Monoid(mempty, mappend))
143-
import Data.Traversable (Traversable(..))
144-
import Data.Word (Word)
145-
#endif
146-
#if __GLASGOW_HASKELL__ >= 711
140+
#if !MIN_VERSION_base(4,11,0)
147141
import Data.Semigroup (Semigroup((<>)))
148142
#endif
149143
import Control.DeepSeq (NFData(rnf))
150-
import Control.Monad.ST (ST)
144+
import Control.Monad.ST (ST, runST)
151145
import Data.Bits ((.&.), (.|.), complement, popCount, unsafeShiftL, unsafeShiftR)
152146
import Data.Data hiding (Typeable)
153147
import qualified Data.Foldable as Foldable
@@ -162,17 +156,14 @@ import Text.Read hiding (step)
162156
import qualified Data.HashMap.Internal.Array as A
163157
import qualified Data.Hashable as H
164158
import Data.Hashable (Hashable)
165-
import Data.HashMap.Internal.Unsafe (runST)
166159
import Data.HashMap.Internal.List (isPermutationBy, unorderedCompare)
167160
import Data.Typeable (Typeable)
168161

169162
import GHC.Exts (isTrue#)
170163
import qualified GHC.Exts as Exts
171164

172-
#if MIN_VERSION_base(4,9,0)
173165
import Data.Functor.Classes
174166
import GHC.Stack
175-
#endif
176167

177168
#if MIN_VERSION_hashable(1,2,5)
178169
import qualified Data.Hashable.Lifted as H
@@ -186,9 +177,7 @@ import qualified Control.DeepSeq as NF
186177
import GHC.Exts (TYPE, Int (..), Int#)
187178
#endif
188179

189-
#if MIN_VERSION_base(4,8,0)
190180
import Data.Functor.Identity (Identity (..))
191-
#endif
192181
import Control.Applicative (Const (..))
193182
import Data.Coerce (coerce)
194183

@@ -265,12 +254,10 @@ instance Foldable.Foldable (HashMap k) where
265254
{-# INLINE foldr' #-}
266255
foldl' = foldl'
267256
{-# INLINE foldl' #-}
268-
#if MIN_VERSION_base(4,8,0)
269257
null = null
270258
{-# INLINE null #-}
271259
length = size
272260
{-# INLINE length #-}
273-
#endif
274261

275262
#if MIN_VERSION_base(4,10,0)
276263
-- | @since 0.2.11
@@ -283,7 +270,6 @@ instance Bifoldable HashMap where
283270
{-# INLINE bifoldl #-}
284271
#endif
285272

286-
#if __GLASGOW_HASKELL__ >= 711
287273
-- | '<>' = 'union'
288274
--
289275
-- If a key occurs in both maps, the mapping from the first will be the mapping in the result.
@@ -295,7 +281,6 @@ instance Bifoldable HashMap where
295281
instance (Eq k, Hashable k) => Semigroup (HashMap k v) where
296282
(<>) = union
297283
{-# INLINE (<>) #-}
298-
#endif
299284

300285
-- | 'mempty' = 'empty'
301286
--
@@ -310,11 +295,7 @@ instance (Eq k, Hashable k) => Semigroup (HashMap k v) where
310295
instance (Eq k, Hashable k) => Monoid (HashMap k v) where
311296
mempty = empty
312297
{-# INLINE mempty #-}
313-
#if __GLASGOW_HASKELL__ >= 711
314298
mappend = (<>)
315-
#else
316-
mappend = union
317-
#endif
318299
{-# INLINE mappend #-}
319300

320301
instance (Data k, Data v, Eq k, Hashable k) => Data (HashMap k v) where
@@ -336,7 +317,6 @@ type Hash = Word
336317
type Bitmap = Word
337318
type Shift = Int
338319

339-
#if MIN_VERSION_base(4,9,0)
340320
instance Show2 HashMap where
341321
liftShowsPrec2 spk slk spv slv d m =
342322
showsUnaryWith (liftShowsPrec sp sl) "fromList" d (toList m)
@@ -353,7 +333,6 @@ instance (Eq k, Hashable k, Read k) => Read1 (HashMap k) where
353333
where
354334
rp' = liftReadsPrec rp rl
355335
rl' = liftReadList rp rl
356-
#endif
357336

358337
instance (Eq k, Hashable k, Read k, Read e) => Read (HashMap k e) where
359338
readPrec = parens $ prec 10 $ do
@@ -371,13 +350,11 @@ instance Traversable (HashMap k) where
371350
traverse f = traverseWithKey (const f)
372351
{-# INLINABLE traverse #-}
373352

374-
#if MIN_VERSION_base(4,9,0)
375353
instance Eq2 HashMap where
376354
liftEq2 = equal2
377355

378356
instance Eq k => Eq1 (HashMap k) where
379357
liftEq = equal1
380-
#endif
381358

382359
-- | Note that, in the presence of hash collisions, equal @HashMap@s may
383360
-- behave differently, i.e. substitutivity may be violated:
@@ -441,13 +418,11 @@ equal2 eqk eqv t1 t2 = go (toList' t1 []) (toList' t2 [])
441418

442419
leafEq (L k v) (L k' v') = eqk k k' && eqv v v'
443420

444-
#if MIN_VERSION_base(4,9,0)
445421
instance Ord2 HashMap where
446422
liftCompare2 = cmp
447423

448424
instance Ord k => Ord1 (HashMap k) where
449425
liftCompare = cmp compare
450-
#endif
451426

452427
-- | The ordering is total and consistent with the `Eq` instance. However,
453428
-- nothing else about the ordering is specified, and it may change from
@@ -775,11 +750,7 @@ lookupDefault def k t = findWithDefault def k t
775750

776751
-- | /O(log n)/ Return the value to which the specified key is mapped.
777752
-- Calls 'error' if this map contains no mapping for the key.
778-
#if MIN_VERSION_base(4,9,0)
779753
(!) :: (Eq k, Hashable k, HasCallStack) => HashMap k v -> k -> v
780-
#else
781-
(!) :: (Eq k, Hashable k) => HashMap k v -> k -> v
782-
#endif
783754
(!) m k = case lookup k m of
784755
Just v -> v
785756
Nothing -> error "Data.HashMap.Internal.(!): key not found"
@@ -1331,7 +1302,6 @@ alterF f = \ !k !m ->
13311302
-- rule from firing.
13321303
{-# INLINABLE [0] alterF #-}
13331304

1334-
#if MIN_VERSION_base(4,8,0)
13351305
-- This is just a bottom value. See the comment on the "alterFWeird"
13361306
-- rule.
13371307
test_bottom :: a
@@ -1448,7 +1418,6 @@ alterFEager f !k m = (<$> f mv) $ \fres ->
14481418
Absent -> Nothing
14491419
Present v _ -> Just v
14501420
{-# INLINABLE alterFEager #-}
1451-
#endif
14521421

14531422
-- | /O(n*log m)/ Inclusion of maps. A map is included in another map if the keys
14541423
-- are subsets and the corresponding values are equal:

Data/HashMap/Internal/Array.hs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,35 +71,19 @@ module Data.HashMap.Internal.Array
7171
, fromList
7272
) where
7373

74-
#if !MIN_VERSION_base(4,8,0)
75-
import Control.Applicative (Applicative (..), (<$>))
76-
#endif
7774
import Control.Applicative (liftA2)
7875
import Control.DeepSeq (NFData (..))
7976
import GHC.Exts(Int(..), Int#, reallyUnsafePtrEquality#, tagToEnum#, unsafeCoerce#, State#)
8077
import GHC.ST (ST(..))
81-
import Control.Monad.ST (stToIO)
78+
import Control.Monad.ST (runST, stToIO)
8279

83-
#if __GLASGOW_HASKELL__ >= 709
8480
import Prelude hiding (filter, foldMap, foldr, foldl, length, map, read, traverse, all)
85-
#else
86-
import Prelude hiding (filter, foldr, foldl, length, map, read, all)
87-
#endif
8881

89-
#if __GLASGOW_HASKELL__ >= 710
9082
import GHC.Exts (SmallArray#, newSmallArray#, readSmallArray#, writeSmallArray#,
9183
indexSmallArray#, unsafeFreezeSmallArray#, unsafeThawSmallArray#,
9284
SmallMutableArray#, sizeofSmallArray#, copySmallArray#, thawSmallArray#,
9385
sizeofSmallMutableArray#, copySmallMutableArray#, cloneSmallMutableArray#)
9486

95-
#else
96-
import GHC.Exts (Array#, newArray#, readArray#, writeArray#,
97-
indexArray#, unsafeFreezeArray#, unsafeThawArray#,
98-
MutableArray#, sizeofArray#, copyArray#, thawArray#,
99-
sizeofMutableArray#, copyMutableArray#, cloneMutableArray#)
100-
import Data.Monoid (Monoid (..))
101-
#endif
102-
10387
#if defined(ASSERTS)
10488
import qualified Prelude
10589
#endif
@@ -108,11 +92,9 @@ import qualified Prelude
10892
import qualified Control.DeepSeq as NF
10993
#endif
11094

111-
import Data.HashMap.Internal.Unsafe (runST)
11295
import Control.Monad ((>=>))
11396

11497

115-
#if __GLASGOW_HASKELL__ >= 710
11698
type Array# a = SmallArray# a
11799
type MutableArray# a = SmallMutableArray# a
118100

@@ -175,7 +157,6 @@ copyMutableArray# :: SmallMutableArray# d a
175157
-> State# d
176158
-> State# d
177159
copyMutableArray# = copySmallMutableArray#
178-
#endif
179160

180161
------------------------------------------------------------------------
181162

0 commit comments

Comments
 (0)