Skip to content

Commit 8628140

Browse files
authored
Drop support for GHC 8.0 (#354)
This allows us to remove a good amount of CPP and hacks.
1 parent a94f518 commit 8628140

File tree

7 files changed

+10
-79
lines changed

7 files changed

+10
-79
lines changed

.github/workflows/haskell-ci.yml

+7-12
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.20211116
11+
# version: 0.14.1
1212
#
13-
# REGENDATA ("0.13.20211116",["github","unordered-containers.cabal"])
13+
# REGENDATA ("0.14.1",["github","unordered-containers.cabal"])
1414
#
1515
name: Haskell-CI
1616
on:
@@ -37,10 +37,10 @@ jobs:
3737
compilerVersion: 9.2.1
3838
setup-method: ghcup
3939
allow-failure: false
40-
- compiler: ghc-9.0.1
40+
- compiler: ghc-9.0.2
4141
compilerKind: ghc
42-
compilerVersion: 9.0.1
43-
setup-method: hvr-ppa
42+
compilerVersion: 9.0.2
43+
setup-method: ghcup
4444
allow-failure: false
4545
- compiler: ghc-8.10.7
4646
compilerKind: ghc
@@ -67,11 +67,6 @@ jobs:
6767
compilerVersion: 8.2.2
6868
setup-method: hvr-ppa
6969
allow-failure: false
70-
- compiler: ghc-8.0.2
71-
compilerKind: ghc
72-
compilerVersion: 8.0.2
73-
setup-method: hvr-ppa
74-
allow-failure: false
7570
fail-fast: false
7671
steps:
7772
- name: apt
@@ -198,8 +193,8 @@ jobs:
198193
touch cabal.project
199194
touch cabal.project.local
200195
echo "packages: ${PKGDIR_unordered_containers}" >> cabal.project
201-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package unordered-containers" >> cabal.project ; fi
202-
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
196+
echo "package unordered-containers" >> cabal.project
197+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
203198
cat >> cabal.project <<EOF
204199
EOF
205200
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(binary|containers|unordered-containers)$/; }' >> cabal.project.local

Data/HashMap/Internal.hs

-41
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
{-# LANGUAGE TemplateHaskellQuotes #-}
1111
{-# LANGUAGE TypeFamilies #-}
1212
{-# LANGUAGE UnboxedTuples #-}
13-
#if __GLASGOW_HASKELL__ >= 802
1413
{-# LANGUAGE TypeInType #-}
1514
{-# LANGUAGE UnboxedSums #-}
16-
#endif
1715
{-# OPTIONS_GHC -fno-full-laziness -funbox-strict-fields #-}
1816
{-# OPTIONS_HADDOCK not-home #-}
1917

@@ -148,9 +146,7 @@ import Control.Monad.ST (ST, runST)
148146
import Data.Bits ((.&.), (.|.), complement, popCount, unsafeShiftL, unsafeShiftR)
149147
import Data.Data
150148
import qualified Data.Foldable as Foldable
151-
#if MIN_VERSION_base(4,10,0)
152149
import Data.Bifoldable
153-
#endif
154150
import qualified Data.List as L
155151
import GHC.Exts ((==#), build, reallyUnsafePtrEquality#, inline)
156152
import Prelude hiding (filter, foldl, foldr, lookup, map, null, pred)
@@ -171,13 +167,9 @@ import GHC.Stack
171167
import qualified Data.Hashable.Lifted as H
172168
#endif
173169

174-
#if MIN_VERSION_deepseq(1,4,3)
175170
import qualified Control.DeepSeq as NF
176-
#endif
177171

178-
#if __GLASGOW_HASKELL__ >= 802
179172
import GHC.Exts (TYPE, Int (..), Int#)
180-
#endif
181173

182174
import Data.Functor.Identity (Identity (..))
183175
import Control.Applicative (Const (..))
@@ -205,15 +197,13 @@ instance (TH.Lift k, TH.Lift v) => TH.Lift (Leaf k v) where
205197
lift (L k v) = [| L k $! v |]
206198
#endif
207199

208-
#if MIN_VERSION_deepseq(1,4,3)
209200
-- | @since 0.2.14.0
210201
instance NFData k => NF.NFData1 (Leaf k) where
211202
liftRnf rnf2 = NF.liftRnf2 rnf rnf2
212203

213204
-- | @since 0.2.14.0
214205
instance NF.NFData2 Leaf where
215206
liftRnf2 rnf1 rnf2 (L k v) = rnf1 k `seq` rnf2 v
216-
#endif
217207

218208
-- Invariant: The length of the 1st argument to 'Full' is
219209
-- 2^bitsPerSubkey
@@ -239,7 +229,6 @@ instance (NFData k, NFData v) => NFData (HashMap k v) where
239229
rnf (Full ary) = rnf ary
240230
rnf (Collision _ ary) = rnf ary
241231

242-
#if MIN_VERSION_deepseq(1,4,3)
243232
-- | @since 0.2.14.0
244233
instance NFData k => NF.NFData1 (HashMap k) where
245234
liftRnf rnf2 = NF.liftRnf2 rnf rnf2
@@ -251,7 +240,6 @@ instance NF.NFData2 HashMap where
251240
liftRnf2 rnf1 rnf2 (Leaf _ l) = NF.liftRnf2 rnf1 rnf2 l
252241
liftRnf2 rnf1 rnf2 (Full ary) = NF.liftRnf (NF.liftRnf2 rnf1 rnf2) ary
253242
liftRnf2 rnf1 rnf2 (Collision _ ary) = NF.liftRnf (NF.liftRnf2 rnf1 rnf2) ary
254-
#endif
255243

256244
instance Functor (HashMap k) where
257245
fmap = map
@@ -272,7 +260,6 @@ instance Foldable.Foldable (HashMap k) where
272260
length = size
273261
{-# INLINE length #-}
274262

275-
#if MIN_VERSION_base(4,10,0)
276263
-- | @since 0.2.11
277264
instance Bifoldable HashMap where
278265
bifoldMap f g = foldMapWithKey (\ k v -> f k `mappend` g v)
@@ -281,7 +268,6 @@ instance Bifoldable HashMap where
281268
{-# INLINE bifoldr #-}
282269
bifoldl f g = foldlWithKey (\ acc k v -> (acc `f` k) `g` v)
283270
{-# INLINE bifoldl #-}
284-
#endif
285271

286272
-- | '<>' = 'union'
287273
--
@@ -606,7 +592,6 @@ member k m = case lookup k m of
606592
-- | /O(log n)/ Return the value to which the specified key is mapped,
607593
-- or 'Nothing' if this map contains no mapping for the key.
608594
lookup :: (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
609-
#if __GLASGOW_HASKELL__ >= 802
610595
-- GHC does not yet perform a worker-wrapper transformation on
611596
-- unboxed sums automatically. That seems likely to happen at some
612597
-- point (possibly as early as GHC 8.6) but for now we do it manually.
@@ -619,16 +604,9 @@ lookup# :: (Eq k, Hashable k) => k -> HashMap k v -> (# (# #) | v #)
619604
lookup# k m = lookupCont (\_ -> (# (# #) | #)) (\v _i -> (# | v #)) (hash k) k 0 m
620605
{-# INLINABLE lookup# #-}
621606

622-
#else
623-
624-
lookup k m = lookupCont (\_ -> Nothing) (\v _i -> Just v) (hash k) k 0 m
625-
{-# INLINABLE lookup #-}
626-
#endif
627-
628607
-- | lookup' is a version of lookup that takes the hash separately.
629608
-- It is used to implement alterF.
630609
lookup' :: Eq k => Hash -> k -> HashMap k v -> Maybe v
631-
#if __GLASGOW_HASKELL__ >= 802
632610
-- GHC does not yet perform a worker-wrapper transformation on
633611
-- unboxed sums automatically. That seems likely to happen at some
634612
-- point (possibly as early as GHC 8.6) but for now we do it manually.
@@ -639,10 +617,6 @@ lookup' h k m = case lookupRecordCollision# h k m of
639617
(# (# #) | #) -> Nothing
640618
(# | (# a, _i #) #) -> Just a
641619
{-# INLINE lookup' #-}
642-
#else
643-
lookup' h k m = lookupCont (\_ -> Nothing) (\v _i -> Just v) h k 0 m
644-
{-# INLINABLE lookup' #-}
645-
#endif
646620

647621
-- The result of a lookup, keeping track of if a hash collision occured.
648622
-- If a collision did not occur then it will have the Int value (-1).
@@ -662,7 +636,6 @@ data LookupRes a = Absent | Present a !Int
662636
-- Key in map, no collision => Present v (-1)
663637
-- Key in map, collision => Present v position
664638
lookupRecordCollision :: Eq k => Hash -> k -> HashMap k v -> LookupRes v
665-
#if __GLASGOW_HASKELL__ >= 802
666639
lookupRecordCollision h k m = case lookupRecordCollision# h k m of
667640
(# (# #) | #) -> Absent
668641
(# | (# a, i #) #) -> Present a (I# i) -- GHC will eliminate the I#
@@ -679,12 +652,6 @@ lookupRecordCollision# h k m =
679652
-- INLINABLE to specialize to the Eq instance.
680653
{-# INLINABLE lookupRecordCollision# #-}
681654

682-
#else /* GHC < 8.2 so there are no unboxed sums */
683-
684-
lookupRecordCollision h k m = lookupCont (\_ -> Absent) Present h k 0 m
685-
{-# INLINABLE lookupRecordCollision #-}
686-
#endif
687-
688655
-- A two-continuation version of lookupRecordCollision. This lets us
689656
-- share source code between lookup and lookupRecordCollision without
690657
-- risking any performance degradation.
@@ -698,11 +665,7 @@ lookupRecordCollision h k m = lookupCont (\_ -> Absent) Present h k 0 m
698665
-- keys at the top-level of a hashmap, the offset should be 0. When looking up
699666
-- keys at level @n@ of a hashmap, the offset should be @n * bitsPerSubkey@.
700667
lookupCont ::
701-
#if __GLASGOW_HASKELL__ >= 802
702668
forall rep (r :: TYPE rep) k v.
703-
#else
704-
forall r k v.
705-
#endif
706669
Eq k
707670
=> ((# #) -> r) -- Absent continuation
708671
-> (v -> Int -> r) -- Present continuation
@@ -2155,11 +2118,7 @@ fromListWithKey f = L.foldl' (\ m (k, v) -> unsafeInsertWithKey f k v m) empty
21552118
-- | /O(n)/ Look up the value associated with the given key in an
21562119
-- array.
21572120
lookupInArrayCont ::
2158-
#if __GLASGOW_HASKELL__ >= 802
21592121
forall rep (r :: TYPE rep) k v.
2160-
#else
2161-
forall r k v.
2162-
#endif
21632122
Eq k => ((# #) -> r) -> (v -> Int -> r) -> k -> A.Array (Leaf k v) -> r
21642123
lookupInArrayCont absent present k0 ary0 = go k0 ary0 0 (A.length ary0)
21652124
where

Data/HashMap/Internal/Array.hs

-4
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ import qualified Language.Haskell.TH.Syntax as TH
9292
import qualified Prelude
9393
#endif
9494

95-
#if MIN_VERSION_deepseq(1,4,3)
9695
import qualified Control.DeepSeq as NF
97-
#endif
9896

9997
import Control.Monad ((>=>))
10098

@@ -173,7 +171,6 @@ rnfArray ary0 = go ary0 n0 0
173171
-- relevant rnf is strict, or in case it actually isn't.
174172
{-# INLINE rnfArray #-}
175173

176-
#if MIN_VERSION_deepseq(1,4,3)
177174
-- | @since 0.2.14.0
178175
instance NF.NFData1 Array where
179176
liftRnf = liftRnfArray
@@ -187,7 +184,6 @@ liftRnfArray rnf0 ary0 = go ary0 n0 0
187184
| (# x #) <- index# ary i
188185
= rnf0 x `seq` go ary n (i+1)
189186
{-# INLINE liftRnfArray #-}
190-
#endif
191187

192188
-- | Create a new mutable array of specified size, in the specified
193189
-- state thread, with each element containing the specified initial

Data/HashSet/Internal.hs

-4
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ import Text.Read
110110
import qualified Data.Hashable.Lifted as H
111111
#endif
112112

113-
#if MIN_VERSION_deepseq(1,4,3)
114113
import qualified Control.DeepSeq as NF
115-
#endif
116114
import qualified Language.Haskell.TH.Syntax as TH
117115

118116
-- | A set of values. A set cannot contain duplicate values.
@@ -129,11 +127,9 @@ instance (NFData a) => NFData (HashSet a) where
129127
rnf = rnf . asMap
130128
{-# INLINE rnf #-}
131129

132-
#if MIN_VERSION_deepseq(1,4,3)
133130
-- | @since 0.2.14.0
134131
instance NF.NFData1 HashSet where
135132
liftRnf rnf1 = NF.liftRnf2 rnf1 rnf . asMap
136-
#endif
137133

138134
-- | Note that, in the presence of hash collisions, equal @HashSet@s may
139135
-- behave differently, i.e. substitutivity may be violated:

tests/Properties/HashMapLazy.hs

-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ module Properties.HashMapLazy (tests) where
1212

1313
import Control.Monad ( guard )
1414
import qualified Data.Foldable as Foldable
15-
#if MIN_VERSION_base(4,10,0)
1615
import Data.Bifoldable
17-
#endif
1816
import Data.Function (on)
1917
import Data.Hashable (Hashable(hashWithSalt))
2018
import qualified Data.List as L
@@ -337,7 +335,6 @@ pFoldr = (L.sort . M.foldr (:) []) `eq` (L.sort . HM.foldr (:) [])
337335
pFoldl :: [(Int, Int)] -> Bool
338336
pFoldl = (L.sort . M.foldl (flip (:)) []) `eq` (L.sort . HM.foldl (flip (:)) [])
339337

340-
#if MIN_VERSION_base(4,10,0)
341338
pBifoldMap :: [(Int, Int)] -> Bool
342339
pBifoldMap xs = concatMap f (HM.toList m) == bifoldMap (:[]) (:[]) m
343340
where f (k, v) = [k, v]
@@ -352,7 +349,6 @@ pBifoldl :: [(Int, Int)] -> Bool
352349
pBifoldl xs = reverse (concatMap f $ HM.toList m) == bifoldl (flip (:)) (flip (:)) [] m
353350
where f (k, v) = [k, v]
354351
m = HM.fromList xs
355-
#endif
356352

357353
pFoldrWithKey :: [(Int, Int)] -> Bool
358354
pFoldrWithKey = (sortByKey . M.foldrWithKey f []) `eq`
@@ -514,11 +510,9 @@ tests =
514510
, testGroup "folds"
515511
[ testProperty "foldr" pFoldr
516512
, testProperty "foldl" pFoldl
517-
#if MIN_VERSION_base(4,10,0)
518513
, testProperty "bifoldMap" pBifoldMap
519514
, testProperty "bifoldr" pBifoldr
520515
, testProperty "bifoldl" pBifoldl
521-
#endif
522516
, testProperty "foldrWithKey" pFoldrWithKey
523517
, testProperty "foldlWithKey" pFoldlWithKey
524518
, testProperty "foldrWithKey'" pFoldrWithKey'

unordered-containers.cabal

+3-9
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ extra-source-files: CHANGES.md
3030

3131
tested-with:
3232
GHC ==9.2.1
33-
|| ==9.0.1
33+
|| ==9.0.2
3434
|| ==8.10.7
3535
|| ==8.8.4
3636
|| ==8.6.5
3737
|| ==8.4.4
3838
|| ==8.2.2
39-
|| ==8.0.2
4039

4140
flag debug
4241
description: Enable debug support
@@ -54,8 +53,8 @@ library
5453
Data.HashSet.Internal
5554

5655
build-depends:
57-
base >= 4.9 && < 5,
58-
deepseq >= 1.1,
56+
base >= 4.10 && < 5,
57+
deepseq >= 1.4.3,
5958
hashable >= 1.0.1.1 && < 1.5,
6059
template-haskell < 2.19
6160

@@ -70,11 +69,6 @@ library
7069

7170
ghc-options: -Wall -O2 -fwarn-tabs -ferror-spans
7271

73-
if impl (ghc < 8.2)
74-
-- This is absolutely necessary (but not sufficient) for correctness due to
75-
-- the referential-transparency-breaking mutability in unsafeInsertWith. See
76-
-- #147 and GHC #13615 for details. The bug was fixed in GHC 8.2.
77-
ghc-options: -feager-blackholing
7872
if flag(debug)
7973
cpp-options: -DASSERTS
8074

utils/Stats.hs

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ instance Semigroup Histogram where
2727

2828
instance Monoid Histogram where
2929
mempty = H 0 0 0 0 0
30-
#if __GLASGOW_HASKELL__ < 803
31-
mappend = (<>)
32-
#endif
3330

3431
-- | Count the number of node types at each level
3532
nodeHistogram :: HM.HashMap k v -> [Histogram]

0 commit comments

Comments
 (0)