Skip to content

Commit 4f927a1

Browse files
authored
Merge pull request #11967 from haskell/require-deepseq-1.4
Remove compatibility layer for deepseq<1.4
2 parents cdac621 + daac4eb commit 4f927a1

55 files changed

Lines changed: 73 additions & 108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cabal-syntax/Cabal-syntax.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ library
3333
, binary >= 0.8.1 && < 0.9
3434
, bytestring >= 0.10.4.0 && < 0.13
3535
, containers >= 0.5.2 && < 0.9
36-
, deepseq >= 1.3.0.1 && < 1.7
36+
, deepseq >= 1.4 && < 1.7
3737
, directory >= 1.2 && < 1.4
3838
, filepath >= 1.3.0.1 && < 1.6
3939
, mtl >= 2.1 && < 2.4

Cabal-syntax/src/Distribution/CabalSpecVersion.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ data CabalSpecVersion
4242

4343
instance Binary CabalSpecVersion
4444
instance Structured CabalSpecVersion
45-
instance NFData CabalSpecVersion where rnf = genericRnf
45+
instance NFData CabalSpecVersion
4646

4747
-- | Show cabal spec version, but not the way in the .cabal files
4848
--

Cabal-syntax/src/Distribution/Compat/Prelude.hs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE FlexibleContexts #-}
22
{-# LANGUAGE RankNTypes #-}
33
{-# LANGUAGE Trustworthy #-}
4-
{-# LANGUAGE TypeOperators #-}
54

65
-- | This module does two things:
76
--
@@ -25,7 +24,6 @@ module Distribution.Compat.Prelude
2524
, Data
2625
, Generic
2726
, NFData (..)
28-
, genericRnf
2927
, Binary (..)
3028
, Structured
3129
, Alternative (..)
@@ -235,7 +233,7 @@ import Data.Void (Void, absurd, vacuous)
235233
import Data.Word (Word, Word16, Word32, Word64, Word8)
236234
import Distribution.Compat.Binary (Binary (..))
237235
import Distribution.Compat.Semigroup (gmappend, gmempty)
238-
import GHC.Generics (Generic (..), K1 (unK1), M1 (unM1), U1 (U1), V1, (:*:) ((:*:)), (:+:) (L1, R1))
236+
import GHC.Generics (Generic)
239237
import System.Exit (ExitCode (..), exitFailure, exitSuccess, exitWith)
240238
import Text.Read (readMaybe)
241239

@@ -251,47 +249,6 @@ import qualified Debug.Trace
251249
(<<>>) :: Disp.Doc -> Disp.Doc -> Disp.Doc
252250
(<<>>) = (Disp.<>)
253251

254-
-- | "GHC.Generics"-based 'rnf' implementation
255-
--
256-
-- This is needed in order to support @deepseq < 1.4@ which didn't
257-
-- have a 'Generic'-based default 'rnf' implementation yet.
258-
--
259-
-- In order to define instances, use e.g.
260-
--
261-
-- > instance NFData MyType where rnf = genericRnf
262-
--
263-
-- The implementation has been taken from @deepseq-1.4.2@'s default
264-
-- 'rnf' implementation.
265-
genericRnf :: (Generic a, GNFData (Rep a)) => a -> ()
266-
genericRnf = grnf . from
267-
268-
-- | Hidden internal type-class
269-
class GNFData f where
270-
grnf :: f a -> ()
271-
272-
instance GNFData V1 where
273-
grnf = error "Control.DeepSeq.rnf: uninhabited type"
274-
275-
instance GNFData U1 where
276-
grnf U1 = ()
277-
278-
instance NFData a => GNFData (K1 i a) where
279-
grnf = rnf . unK1
280-
{-# INLINEABLE grnf #-}
281-
282-
instance GNFData a => GNFData (M1 i c a) where
283-
grnf = grnf . unM1
284-
{-# INLINEABLE grnf #-}
285-
286-
instance (GNFData a, GNFData b) => GNFData (a :*: b) where
287-
grnf (x :*: y) = grnf x `seq` grnf y
288-
{-# INLINEABLE grnf #-}
289-
290-
instance (GNFData a, GNFData b) => GNFData (a :+: b) where
291-
grnf (L1 x) = grnf x
292-
grnf (R1 x) = grnf x
293-
{-# INLINEABLE grnf #-}
294-
295252
-- TODO: if we want foldr1/foldl1 to work on more than NonEmpty, we
296253
-- can define a local typeclass 'Foldable1', e.g.
297254
--

Cabal-syntax/src/Distribution/Compiler.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ data CompilerFlavor
8383

8484
instance Binary CompilerFlavor
8585
instance Structured CompilerFlavor
86-
instance NFData CompilerFlavor where rnf = genericRnf
86+
instance NFData CompilerFlavor
8787

8888
knownCompilerFlavors :: [CompilerFlavor]
8989
knownCompilerFlavors =
@@ -177,7 +177,7 @@ data CompilerId = CompilerId CompilerFlavor Version
177177

178178
instance Binary CompilerId
179179
instance Structured CompilerId
180-
instance NFData CompilerId where rnf = genericRnf
180+
instance NFData CompilerId
181181

182182
instance Pretty CompilerId where
183183
pretty (CompilerId f v)

Cabal-syntax/src/Distribution/License.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ data License
115115

116116
instance Binary License
117117
instance Structured License
118-
instance NFData License where rnf = genericRnf
118+
instance NFData License
119119

120120
-- | The list of all currently recognised licenses.
121121
knownLicenses :: [License]

Cabal-syntax/src/Distribution/Parsec/Error.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data PErrorWithSource src = PErrorWithSource {perrorSource :: !(PSource src), pe
2323
deriving (Show, Generic, Functor)
2424

2525
instance Binary PError
26-
instance NFData PError where rnf = genericRnf
26+
instance NFData PError
2727

2828
showPError :: FilePath -> PError -> String
2929
showPError fpath (PError pos msg) =

Cabal-syntax/src/Distribution/Parsec/Position.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ data Position
2121
deriving (Eq, Ord, Show, Generic)
2222

2323
instance Binary Position
24-
instance NFData Position where rnf = genericRnf
24+
instance NFData Position
2525

2626
-- | Shift position by n columns to the right.
2727
incPos :: Int -> Position -> Position

Cabal-syntax/src/Distribution/Parsec/Source.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ instance Eq src => Eq (PSource src) where
4242
_ == _ = False
4343

4444
instance Binary src => Binary (PSource src)
45-
instance NFData src => NFData (PSource src) where rnf = genericRnf
45+
instance NFData src => NFData (PSource src)

Cabal-syntax/src/Distribution/Parsec/Warning.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ data PWarnType
7070
deriving (Eq, Ord, Show, Enum, Bounded, Generic)
7171

7272
instance Binary PWarnType
73-
instance NFData PWarnType where rnf = genericRnf
73+
instance NFData PWarnType
7474

7575
-- | Parser warning.
7676
data PWarning = PWarning {pwarningType :: !PWarnType, pwarningPosition :: !Position, pwarningMessage :: !String}
@@ -80,7 +80,7 @@ data PWarningWithSource src = PWarningWithSource {pwarningSource :: !(PSource sr
8080
deriving (Eq, Ord, Show, Generic, Functor)
8181

8282
instance Binary PWarning
83-
instance NFData PWarning where rnf = genericRnf
83+
instance NFData PWarning
8484

8585
showPWarning :: FilePath -> PWarning -> String
8686
showPWarning fpath (PWarning _ pos msg) =

Cabal-syntax/src/Distribution/System.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ data OS
111111

112112
instance Binary OS
113113
instance Structured OS
114-
instance NFData OS where rnf = genericRnf
114+
instance NFData OS
115115

116116
knownOSs :: [OS]
117117
knownOSs =
@@ -214,7 +214,7 @@ data Arch
214214

215215
instance Binary Arch
216216
instance Structured Arch
217-
instance NFData Arch where rnf = genericRnf
217+
instance NFData Arch
218218

219219
knownArches :: [Arch]
220220
knownArches =
@@ -285,7 +285,7 @@ data Platform = Platform Arch OS
285285

286286
instance Binary Platform
287287
instance Structured Platform
288-
instance NFData Platform where rnf = genericRnf
288+
instance NFData Platform
289289

290290
instance Pretty Platform where
291291
pretty (Platform arch os) = pretty arch <<>> Disp.char '-' <<>> pretty os

0 commit comments

Comments
 (0)