Skip to content

Commit

Permalink
rm-old-base: remove ifdefs for pre-4.13 bases (#10092)
Browse files Browse the repository at this point in the history
* rm-old-base: remove ifdefs for pre-4.13 bases

4.13 and older have fallen out of the support window. Hence this commit
removes code only conditionally included for base 4.13 and older. Some
occasional transitive removals were implied and done in this same commit.

* Remove 8.6.5 from CI and Makefile

* Remove test for GHC <8.6.5

* Update GHC versions mentioned in the user guide

* rm-old-base: use Distribution.Compat.Prelude

The change was likely an artifact of a rebase.

* rm-old-base: restore builds not of cabal itself

The #ifdefs being generated need to be kept here so that projects other
than cabal can be built using older ghc versions and current cabal
versions.

* rm-old-base: restore older catchIO

This needs to be included so running with older bases and ghcs can be
done even while building cabal itself demands recent ghcs.

* Bump base lower bounds to >=4.13

* Update a few package version in the documentation

* rm-old-base: remove Distribution.Compat.Typeable

It's not needed with our currently supported ghcs.

* rm-old-base: restore T6906

---------

Co-authored-by: Andrea Bedini <[email protected]>
Co-authored-by: brandon s allbery kf8nh <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 26, 2024
1 parent 5e6f306 commit 356c2f4
Show file tree
Hide file tree
Showing 43 changed files with 127 additions and 488 deletions.
121 changes: 63 additions & 58 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ concurrency:
on:
push:
paths-ignore:
- 'doc/**'
- '**/README.md'
- 'CONTRIBUTING.md'
- "doc/**"
- "**/README.md"
- "CONTRIBUTING.md"
branches:
- master
pull_request:
paths-ignore:
- 'doc/**'
- '**/README.md'
- 'CONTRIBUTING.md'
- "doc/**"
- "**/README.md"
- "CONTRIBUTING.md"
release:
types:
- created
Expand All @@ -41,17 +41,16 @@ on:
env:
# We choose a stable ghc version across all os's
# which will be used to do the next release
GHC_FOR_RELEASE: '9.4.8'
GHC_FOR_RELEASE: "9.4.8"
# Ideally we should use the version about to be released for hackage tests and benchmarks
GHC_FOR_SOLVER_BENCHMARKS: '9.4.8'
GHC_FOR_COMPLETE_HACKAGE_TESTS: '9.4.8'
COMMON_FLAGS: '-j 2 -v'
GHC_FOR_SOLVER_BENCHMARKS: "9.4.8"
GHC_FOR_COMPLETE_HACKAGE_TESTS: "9.4.8"
COMMON_FLAGS: "-j 2 -v"

# See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#hackage-revisions
ALLOWNEWER: ${{ github.event.inputs.allow-newer }}
CONSTRAINTS: ${{ github.event.inputs.constraints }}


jobs:
validate:
name: Validate ${{ matrix.sys.os }} ghc-${{ matrix.ghc }}
Expand All @@ -61,28 +60,36 @@ jobs:
strategy:
matrix:
sys:
- { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
- { os: ubuntu-latest, shell: bash }
- { os: macos-13, shell: bash}
- { os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
- { os: ubuntu-latest, shell: bash }
- { os: macos-13, shell: bash }
# If you remove something from here, then add it to the old-ghcs job.
# Also a removed GHC from here means that we are actually dropping
# support, so the PR *must* have a changelog entry.
ghc: ['9.10.1', '9.8.2', '9.6.4', '9.4.8', '9.2.8', '9.0.2', '8.10.7', '8.8.4', '8.6.5']
ghc:
[
"9.10.1",
"9.8.2",
"9.6.4",
"9.4.8",
"9.2.8",
"9.0.2",
"8.10.7",
"8.8.4",
]
exclude:
# corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
- sys: { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
ghc: '8.10.7'
- sys:
{ os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
ghc: "8.10.7"
# lot of segfaults caused by ghc bugs
- sys: { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
ghc: '8.8.4'
# it often randomly does "C:\Users\RUNNER~1\AppData\Local\Temp\ghcFEDE.c: DeleteFile "\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\ghcFEDE.c": permission denied (Access is denied.)"
- sys: { os: windows-latest, shell: 'C:/msys64/usr/bin/bash.exe -e {0}' }
ghc: '8.6.5'
- sys:
{ os: windows-latest, shell: "C:/msys64/usr/bin/bash.exe -e {0}" }
ghc: "8.8.4"
defaults:
run:
shell: ${{ matrix.sys.shell }}
run:
shell: ${{ matrix.sys.shell }}
steps:

- name: Work around XDG directories existence (haskell-actions/setup#62)
if: runner.os == 'macOS'
run: |
Expand Down Expand Up @@ -213,21 +220,20 @@ jobs:
if: matrix.ghc == env.GHC_FOR_SOLVER_BENCHMARKS
run: sh validate.sh $FLAGS -s solver-benchmarks-run


validate-old-ghcs:
name: Validate old ghcs ${{ matrix.extra-ghc }}
runs-on: ubuntu-latest
needs: validate

strategy:
matrix:
extra-ghc: ['8.4.4', '8.2.2', '8.0.2']
extra-ghc:
["8.4.4", "8.2.2", "8.0.2"]
## GHC 7.10.3 does not install on ubuntu-22.04 with ghcup.
## Older GHCs are not supported by ghcup in the first place.
fail-fast: false

steps:

- uses: actions/checkout@v4

- name: Install prerequisites for old GHCs
Expand Down Expand Up @@ -276,7 +282,7 @@ jobs:
build-alpine:
name: Build statically linked using alpine
runs-on: ubuntu-latest
container: 'alpine:3.19'
container: "alpine:3.19"
steps:
- name: Install extra dependencies
shell: sh
Expand Down Expand Up @@ -336,7 +342,6 @@ jobs:
name: cabal-${{ runner.os }}-static-x86_64
path: ${{ env.CABAL_EXEC_TAR }}


# The previous jobs use a released version of cabal to build cabal HEAD itself
# This one uses the cabal HEAD generated executable in the previous step
# to build itself again, as sanity check
Expand Down Expand Up @@ -393,34 +398,34 @@ jobs:
needs: [validate, validate-old-ghcs, build-alpine, dogfooding]

steps:
- uses: actions/download-artifact@v3
with:
name: cabal-Windows-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-Linux-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-Linux-static-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-macOS-x86_64

- name: Create GitHub prerelease
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: cabal-head
prerelease: true
title: cabal-head
files: |
cabal-head-Windows-x86_64.tar.gz
cabal-head-Linux-x86_64.tar.gz
cabal-head-Linux-static-x86_64.tar.gz
cabal-head-macOS-x86_64.tar.gz
- uses: actions/download-artifact@v3
with:
name: cabal-Windows-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-Linux-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-Linux-static-x86_64

- uses: actions/download-artifact@v3
with:
name: cabal-macOS-x86_64

- name: Create GitHub prerelease
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: cabal-head
prerelease: true
title: cabal-head
files: |
cabal-head-Windows-x86_64.tar.gz
cabal-head-Linux-x86_64.tar.gz
cabal-head-Linux-static-x86_64.tar.gz
cabal-head-macOS-x86_64.tar.gz
# We use this job as a summary of the workflow
# It will fail if any of the previous jobs does it
Expand Down
4 changes: 0 additions & 4 deletions Cabal-QuickCheck/src/Test/QuickCheck/GenericArbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ module Test.QuickCheck.GenericArbitrary (
import GHC.Generics
import Test.QuickCheck

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative (pure, (<$>), (<*>))
#endif

-- Generic arbitrary for non-recursive types
genericArbitrary :: (Generic a, GArbitrary (Rep a)) => Gen a
genericArbitrary = fmap to garbitrary
Expand Down
16 changes: 1 addition & 15 deletions Cabal-QuickCheck/src/Test/QuickCheck/Instances/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ module Test.QuickCheck.Instances.Cabal () where
#if !MIN_VERSION_base(4,18,0)
import Control.Applicative (liftA2)
#endif
import Data.Bits (shiftR)
import Data.Bits (countLeadingZeros, finiteBitSize, shiftL, shiftR)
import Data.Char (isAlphaNum, isDigit, toLower)
import Data.List (intercalate, (\\))
import Data.List.NonEmpty (NonEmpty (..))
import Distribution.Utils.Generic (lowercase)
import Test.QuickCheck

#if MIN_VERSION_base(4,8,0)
import Data.Bits (countLeadingZeros, finiteBitSize, shiftL)
#else
import Data.Bits (popCount)
#endif

import Distribution.CabalSpecVersion
import Distribution.Compat.NonEmptySet (NonEmptySet)
import Distribution.Compiler
Expand Down Expand Up @@ -54,10 +48,6 @@ import Test.QuickCheck.GenericArbitrary
import qualified Data.ByteString.Char8 as BS8
import qualified Distribution.Compat.NonEmptySet as NES

#if !MIN_VERSION_base(4,8,0)
import Control.Applicative (pure, (<$>), (<*>))
#endif

-------------------------------------------------------------------------------
-- CabalSpecVersion
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -541,8 +531,4 @@ intSqrt n = case compare n 0 of
iter x = shiftR (x + n `div` x) 1

guess :: Int
#if MIN_VERSION_base(4,8,0)
guess = shiftR n (shiftL (finiteBitSize n - countLeadingZeros n) 1)
#else
guess = shiftR n (shiftR (popCount n) 1)
#endif
2 changes: 1 addition & 1 deletion Cabal-hooks/Cabal-hooks.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library
build-depends:
Cabal-syntax >= 3.13 && < 3.15,
Cabal >= 3.13 && < 3.15,
base >= 4.11 && < 5,
base >= 4.13 && < 5,
containers >= 0.5.0.0 && < 0.8,
transformers >= 0.5.6.0 && < 0.7

Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/Cabal-syntax.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library

build-depends:
array >= 0.4.0.1 && < 0.6,
base >= 4.11 && < 5,
base >= 4.13 && < 5,
binary >= 0.7 && < 0.9,
bytestring >= 0.10.0.0 && < 0.13,
containers >= 0.5.0.0 && < 0.8,
Expand Down Expand Up @@ -76,7 +76,6 @@ library
Distribution.Compat.Parsing
Distribution.Compat.Prelude
Distribution.Compat.Semigroup
Distribution.Compat.Typeable
Distribution.Compiler
Distribution.FieldGrammar
Distribution.FieldGrammar.Class
Expand Down
16 changes: 6 additions & 10 deletions Cabal-syntax/src/Distribution/Compat/Graph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,20 @@ instance (Eq (Key a), Eq a) => Eq (Graph a) where
g1 == g2 = graphMap g1 == graphMap g2

instance Foldable.Foldable Graph where
elem x = Foldable.elem x . graphMap
fold = Foldable.fold . graphMap
foldr f z = Foldable.foldr f z . graphMap
foldl f z = Foldable.foldl f z . graphMap
foldMap f = Foldable.foldMap f . graphMap
foldl' f z = Foldable.foldl' f z . graphMap
foldr f z = Foldable.foldr f z . graphMap
foldr' f z = Foldable.foldr' f z . graphMap
#ifdef MIN_VERSION_base
#if MIN_VERSION_base(4,8,0)
foldMap f = Foldable.foldMap f . graphMap
length = Foldable.length . graphMap
null = Foldable.null . graphMap
toList = Foldable.toList . graphMap
elem x = Foldable.elem x . graphMap
maximum = Foldable.maximum . graphMap
minimum = Foldable.minimum . graphMap
sum = Foldable.sum . graphMap
null = Foldable.null . graphMap
product = Foldable.product . graphMap
#endif
#endif
sum = Foldable.sum . graphMap
toList = Foldable.toList . graphMap

instance (NFData a, NFData (Key a)) => NFData (Graph a) where
rnf
Expand Down
17 changes: 1 addition & 16 deletions Cabal-syntax/src/Distribution/Compat/Newtype.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ module Distribution.Compat.Newtype
, unpack'
) where

import Data.Coerce (Coercible, coerce)
import Data.Functor.Identity (Identity (..))
import Data.Monoid (Endo (..), Product (..), Sum (..))

#if MIN_VERSION_base(4,7,0)
import Data.Coerce (coerce, Coercible)
#else
import Unsafe.Coerce (unsafeCoerce)
#endif

-- | The @FunctionalDependencies@ version of 'Newtype' type-class.
--
-- Since Cabal-3.0 class arguments are in a different order than in @newtype@ package.
Expand All @@ -40,22 +35,12 @@ import Unsafe.Coerce (unsafeCoerce)
{- FOURMOLU_DISABLE -}
class Newtype o n | n -> o where
pack :: o -> n
#if MIN_VERSION_base(4,7,0)
default pack :: Coercible o n => o -> n
pack = coerce
#else
default pack :: o -> n
pack = unsafeCoerce
#endif

unpack :: n -> o
#if MIN_VERSION_base(4,7,0)
default unpack :: Coercible n o => n -> o
unpack = coerce
#else
default unpack :: n -> o
unpack = unsafeCoerce
#endif
{- FOURMOLU_ENABLE -}

instance Newtype a (Identity a)
Expand Down
7 changes: 2 additions & 5 deletions Cabal-syntax/src/Distribution/Compat/NonEmptySet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@ instance Ord a => Semigroup (NonEmptySet a) where
instance F.Foldable NonEmptySet where
foldMap f (NES s) = F.foldMap f s
foldr f z (NES s) = F.foldr f z s

#if MIN_VERSION_base(4,8,0)
toList = toList
null _ = False
toList = toList
null _ = False
length (NES s) = F.length s
#endif

-------------------------------------------------------------------------------
-- Constructors
Expand Down
Loading

0 comments on commit 356c2f4

Please sign in to comment.