Skip to content

simplify CPP by dropping GHC 7 #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
compilerVersion: 8.6.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.2
compilerKind: ghc
compilerVersion: 8.6.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.1
compilerKind: ghc
compilerVersion: 8.6.1
Expand Down Expand Up @@ -93,26 +98,6 @@ jobs:
compilerVersion: 8.0.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.10.3
compilerKind: ghc
compilerVersion: 7.10.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.8.4
compilerKind: ghc
compilerVersion: 7.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.6.3
compilerKind: ghc
compilerVersion: 7.6.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.4.2
compilerKind: ghc
compilerVersion: 7.4.2
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
Expand Down
93 changes: 1 addition & 92 deletions Control/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE TypeOperators #-}

#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif

#if __GLASGOW_HASKELL__ >= 708
{-# LANGUAGE EmptyCase #-}
#endif

#if __GLASGOW_HASKELL__ >= 811 && __GLASGOW_HASKELL__ < 901
-- For the Option instance (https://gitlab.haskell.org/ghc/ghc/issues/15028)
Expand Down Expand Up @@ -113,48 +107,27 @@ import Foreign.Ptr
import Foreign.C.Types
import System.Exit ( ExitCode(..) )
import System.Mem.StableName ( StableName )

#if MIN_VERSION_base(4,6,0)
import Data.Ord ( Down(Down) )
#else
import Control.DeepSeq.BackDoor ( Down(Down) )
#endif

#if MIN_VERSION_base(4,7,0)
import Data.Proxy ( Proxy(Proxy) )
#endif

#if MIN_VERSION_base(4,10,0)
import Data.Type.Equality ( (:~:), (:~~:) )
#elif MIN_VERSION_base(4,9,0)
#else
import Data.Type.Equality ( (:~:) )
#elif MIN_VERSION_base(4,7,0)
import Control.DeepSeq.BackDoor ( (:~:) )
#endif

#if MIN_VERSION_base(4,8,0)
import Data.Functor.Identity ( Identity(..) )
import Data.Typeable ( rnfTypeRep, rnfTyCon )
import Data.Void ( Void, absurd )
import Numeric.Natural ( Natural )
#else
import Data.Typeable ( typeRepTyCon, typeRepArgs, tyConPackage, tyConModule, tyConName )
#endif

#if MIN_VERSION_base(4,9,0)
import Data.List.NonEmpty ( NonEmpty (..) )
import Data.Semigroup as Semi
#endif

#if MIN_VERSION_base(4,9,0)
import GHC.Stack.Types ( CallStack(..), SrcLoc(..) )
import Data.Functor.Compose
import qualified Data.Functor.Sum as Functor
import qualified Data.Functor.Product as Functor
#elif MIN_VERSION_base(4,8,1)
import GHC.Stack ( CallStack(..) )
import GHC.SrcLoc ( SrcLoc(..) )
#endif

import GHC.Fingerprint.Type ( Fingerprint(..) )
import GHC.Generics
Expand All @@ -174,11 +147,7 @@ class GNFData arity f where
grnf :: RnfArgs arity a -> f a -> ()

instance GNFData arity V1 where
#if __GLASGOW_HASKELL__ >= 708
grnf _ x = case x of {}
#else
grnf _ !_ = error "Control.DeepSeq.rnf: uninhabited type"
#endif

data Zero
data One
Expand All @@ -198,17 +167,11 @@ instance GNFData arity a => GNFData arity (M1 i c a) where
grnf args = grnf args . unM1
{-# INLINEABLE grnf #-}

#if MIN_VERSION_base(4,9,0)
-- | Because 'URec' did not exist prior to @base-4.9@, this instance is only
-- defined on @base-4.9@ or later.
--
-- @since 1.4.5.0
instance GNFData arity (URec a) where
grnf _ = rwhnf -- Every URec data instance consists of a single data
-- constructor containing a single strict field, so reducing
-- any URec instance to WHNF suffices to reduce it to NF.
{-# INLINEABLE grnf #-}
#endif

instance (GNFData arity a, GNFData arity b) => GNFData arity (a :*: b) where
grnf args (x :*: y) = grnf args x `seq` grnf args y
Expand Down Expand Up @@ -467,7 +430,6 @@ instance NFData Word64 where rnf = rwhnf
-- | @since 1.4.4.0
instance NFData MaskingState where rnf = rwhnf

#if MIN_VERSION_base(4,7,0)
-- |@since 1.4.0.0
instance NFData (Proxy a) where rnf Proxy = ()
-- |@since 1.4.3.0
Expand All @@ -479,7 +441,6 @@ instance NFData (a :~: b) where rnf = rwhnf
instance NFData1 ((:~:) a) where liftRnf _ = rwhnf
-- | @since 1.4.3.0
instance NFData2 (:~:) where liftRnf2 _ _ = rwhnf
#endif

#if MIN_VERSION_base(4,10,0)
-- | @since 1.4.3.0
Expand All @@ -490,7 +451,6 @@ instance NFData1 ((:~~:) a) where liftRnf _ = rwhnf
instance NFData2 (:~~:) where liftRnf2 _ _ = rwhnf
#endif

#if MIN_VERSION_base(4,8,0)
-- |@since 1.4.0.0
instance NFData a => NFData (Identity a) where
rnf = rnf1
Expand All @@ -507,7 +467,6 @@ instance NFData Void where

-- |@since 1.4.0.0
instance NFData Natural where rnf = rwhnf
#endif

-- |@since 1.3.0.0
instance NFData (Fixed a) where rnf = rwhnf
Expand All @@ -522,7 +481,6 @@ instance NFData (a -> b) where rnf = rwhnf

--Rational and complex numbers.

#if MIN_VERSION_base(4,9,0)
-- | Available on @base >=4.9@
--
-- @since 1.4.3.0
Expand Down Expand Up @@ -555,9 +513,6 @@ instance (NFData1 f, NFData1 g, NFData a) => NFData (Functor.Product f g a) wher
rnf = rnf1

instance NFData a => NFData (Ratio a) where
#else
instance (Integral a, NFData a) => NFData (Ratio a) where
#endif
rnf x = rnf (numerator x, denominator x)

instance (NFData a) => NFData (Complex a) where
Expand Down Expand Up @@ -609,27 +564,16 @@ instance NFData2 Const where

-- We should use MIN_VERSION array(0,5,1,1) but that's not possible.
-- There isn't an underscore to not break C preprocessor
#if __GLASGOW_HASKELL__ >= 711
instance (NFData a, NFData b) => NFData (Array a b) where
#else
instance (Ix a, NFData a, NFData b) => NFData (Array a b) where
#endif
rnf x = rnf (bounds x, Data.Array.elems x)

#if __GLASGOW_HASKELL__ >= 711
-- |@since 1.4.3.0
instance (NFData a) => NFData1 (Array a) where
#else
-- |@since 1.4.3.0
instance (Ix a, NFData a) => NFData1 (Array a) where
#endif
liftRnf r x = rnf (bounds x) `seq` liftRnf r (Data.Array.elems x)

#if __GLASGOW_HASKELL__ >= 711
-- |@since 1.4.3.0
instance NFData2 Array where
liftRnf2 r r' x = liftRnf2 r r (bounds x) `seq` liftRnf r' (Data.Array.elems x)
#endif

-- |@since 1.4.0.0
instance NFData a => NFData (Down a) where rnf = rnf1
Expand Down Expand Up @@ -688,7 +632,6 @@ instance NFData ThreadId where
instance NFData Unique where
rnf = rwhnf -- assumes `newtype Unique = Unique Integer`

#if MIN_VERSION_base(4,8,0)
-- | __NOTE__: Prior to @deepseq-1.4.4.0@ this instance was only defined for @base-4.8.0.0@ and later.
--
-- @since 1.4.0.0
Expand All @@ -700,21 +643,7 @@ instance NFData TypeRep where
-- @since 1.4.0.0
instance NFData TyCon where
rnf tycon = rnfTyCon tycon
#else
-- | __NOTE__: Prior to @deepseq-1.4.4.0@ this instance was only defined for @base-4.8.0.0@ and later.
--
-- @since 1.4.0.0
instance NFData TypeRep where
rnf tr = rnf (typeRepTyCon tr) `seq` rnf (typeRepArgs tr)

-- | __NOTE__: Prior to @deepseq-1.4.4.0@ this instance was only defined for @base-4.8.0.0@ and later.
--
-- @since 1.4.0.0
instance NFData TyCon where
rnf tc = rnf (tyConPackage tc) `seq`
rnf (tyConModule tc) `seq`
rnf (tyConName tc)
#endif

-- | __NOTE__: Only strict in the reference and not the referenced value.
--
Expand Down Expand Up @@ -877,7 +806,6 @@ instance NFData ExitCode where
----------------------------------------------------------------------------
-- instances previously provided by semigroups package

#if MIN_VERSION_base(4,9,0)
-- |@since 1.4.2.0
instance NFData a => NFData (NonEmpty a) where rnf = rnf1
-- |@since 1.4.3.0
Expand Down Expand Up @@ -929,12 +857,10 @@ instance NFData a => NFData (Option a) where rnf = rnf1
instance NFData1 Option where
liftRnf r (Option a) = liftRnf r a
#endif
#endif

----------------------------------------------------------------------------
-- GHC.Stack

#if MIN_VERSION_base(4,9,0)
-- |@since 1.4.2.0
instance NFData SrcLoc where
rnf (SrcLoc a b c d e f g) = rnf a `seq` rnf b `seq` rnf c `seq`
Expand All @@ -946,23 +872,6 @@ instance NFData CallStack where
rnf (PushCallStack a b c) = rnf a `seq` rnf b `seq` rnf c
rnf (FreezeCallStack a) = rnf a

#elif MIN_VERSION_base(4,8,1)
-- |@since 1.4.2.0
instance NFData SrcLoc where
-- base-4.8 didn't expose the 'SrcLoc' constructor
rnf sl = rnf (srcLocPackage sl) `seq`
rnf (srcLocModule sl) `seq`
rnf (srcLocFile sl) `seq`
rnf (srcLocStartLine sl) `seq`
rnf (srcLocStartCol sl) `seq`
rnf (srcLocEndLine sl) `seq`
rnf (srcLocEndCol sl)

-- |@since 1.4.2.0
instance NFData CallStack where
rnf = rnf . getCallStack
#endif

----------------------------------------------------------------------------
-- Tuples

Expand Down
30 changes: 9 additions & 21 deletions deepseq.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ description:

build-type: Simple
tested-with:
GHC==9.2.1, GHC==9.0.1,
GHC==8.10.7,
GHC==8.6.5, GHC==8.6.4,GHC==8.6.3,GHC==8.6.3,GHC==8.6.1,
GHC==8.4.4, GHC==8.4.3, GHC==8.4.2, GHC==8.4.1,
GHC==8.2.2,
GHC==8.0.2,
GHC==7.10.3,
GHC==7.8.4,
GHC==7.6.3,
GHC==7.4.2
GHC==9.2.1,
GHC==9.0.1,
GHC==8.10.7,
GHC==8.6.5, GHC==8.6.4, GHC==8.6.3, GHC==8.6.2, GHC==8.6.1,
GHC==8.4.4, GHC==8.4.3, GHC==8.4.2, GHC==8.4.1,
GHC==8.2.2,
GHC==8.0.2

extra-source-files: changelog.md

Expand All @@ -49,28 +46,19 @@ library
BangPatterns
CPP
DefaultSignatures
EmptyCase
FlexibleContexts
FlexibleInstances
GADTs
MultiParamTypeClasses
PolyKinds
Safe
TypeOperators

-- GHC.Generics lived in `ghc-prim` for GHC 7.2 & GHC 7.4
if impl(ghc == 7.4.*)
build-depends: ghc-prim == 0.2.*

-- Solo lives in ghc-prim in GHC-9.0 (and maybe still in GHC-9.2)
if impl(ghc >=9.0)
build-depends: ghc-prim

if impl(ghc>=7.6)
other-extensions: PolyKinds

if impl(ghc>=7.8)
other-extensions: EmptyCase


build-depends: base >= 4.5 && < 4.17,
array >= 0.4 && < 0.6
ghc-options: -Wall
Expand Down