Skip to content

Commit

Permalink
Drop support of GHC < 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Jan 19, 2023
1 parent ae26e18 commit c72a101
Show file tree
Hide file tree
Showing 33 changed files with 15 additions and 179 deletions.
66 changes: 11 additions & 55 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,53 +48,18 @@ jobs:
compilerVersion: 9.0.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.10.7
compilerKind: ghc
compilerVersion: 8.10.7
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-8.2.2
compilerKind: ghc
compilerVersion: 8.2.2
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
run: |
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml;
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -106,20 +71,11 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down
8 changes: 0 additions & 8 deletions Math/NumberTheory/ArithmeticFunctions/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
-- factorisation domains.
--

{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}

module Math.NumberTheory.ArithmeticFunctions.Class
Expand All @@ -18,9 +17,6 @@ module Math.NumberTheory.ArithmeticFunctions.Class
) where

import Control.Applicative
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Prelude hiding (Applicative(..))

import Math.NumberTheory.Primes
Expand Down Expand Up @@ -66,11 +62,7 @@ instance Semigroup a => Semigroup (ArithmeticFunction n a) where

instance Monoid a => Monoid (ArithmeticFunction n a) where
mempty = pure mempty
#if __GLASGOW_HASKELL__ < 803
mappend = liftA2 mappend
#else
mappend = (<>)
#endif

-- | Factorisation is expensive, so it is better to avoid doing it twice.
-- Write 'runFunction (f + g) n' instead of 'runFunction f n + runFunction g n'.
Expand Down
4 changes: 0 additions & 4 deletions Math/NumberTheory/ArithmeticFunctions/Inverse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
-- <https://www.emis.de/journals/JIS/VOL19/Alekseyev/alek5.pdf Computing the Inverses, their Power Sums, and Extrema for Euler’s Totient and Other Multiplicative Functions>
-- by M. A. Alekseyev.

{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -37,9 +36,6 @@ import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
import Data.Ord (Down(..))
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Data.Semiring (Semiring(..), Mul(..))
import Data.Set (Set)
import qualified Data.Set as S
Expand Down
4 changes: 0 additions & 4 deletions Math/NumberTheory/ArithmeticFunctions/Moebius.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
--

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
Expand All @@ -24,9 +23,6 @@ import Control.Monad.ST (runST)
import Data.Bits
import Data.Int
import Data.Word
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Primitive as P
Expand Down
19 changes: 0 additions & 19 deletions Math/NumberTheory/DirichletCharacters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
-- Implementation and enumeration of Dirichlet characters.
--

{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
Expand Down Expand Up @@ -59,9 +57,6 @@ module Math.NumberTheory.DirichletCharacters
, validChar
) where

#if !MIN_VERSION_base(4,12,0)
import Control.Applicative (liftA2)
#endif
import Data.Bits (Bits(..))
import Data.Constraint
import Data.Foldable
Expand All @@ -70,9 +65,7 @@ import Data.Kind
import Data.List (sort, unfoldr)
import Data.Maybe (mapMaybe, fromJust, fromMaybe)
import Data.Mod
#if MIN_VERSION_base(4,12,0)
import Data.Monoid (Ap(..))
#endif
import Data.Proxy (Proxy(..))
import Data.Ratio ((%), numerator, denominator)
import Data.Semigroup (Semigroup(..),Product(..))
Expand Down Expand Up @@ -466,18 +459,6 @@ makePrimitive (Generated xs) =
where options = [(i, bit (i-2) :: Natural) | i <- [2..k]]
worksb (_,phi) = phi `stimes` b == mempty

#if !MIN_VERSION_base(4,12,0)
newtype Ap f a = Ap { getAp :: f a }
deriving (Eq, Functor, Applicative, Monad)

instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
(<>) = liftA2 (<>)

instance (Applicative f, Semigroup a, Monoid a) => Monoid (Ap f a) where
mempty = pure mempty
mappend = (<>)
#endif

-- | Similar to Maybe, but with different Semigroup and Monoid instances.
type OrZero a = Ap Maybe a

Expand Down
4 changes: 0 additions & 4 deletions Math/NumberTheory/Euclidean/Coprimes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
--
-- Container for pairwise coprime numbers.

{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

Expand All @@ -23,9 +22,6 @@ import Data.Coerce
import Data.Euclidean
import Data.List (tails)
import Data.Maybe
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Data.Semiring (Semiring(..), isZero)
import Data.Traversable

Expand Down
4 changes: 0 additions & 4 deletions Math/NumberTheory/Moduli/JacobiSymbol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
--

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}

module Math.NumberTheory.Moduli.JacobiSymbol
Expand All @@ -21,9 +20,6 @@ module Math.NumberTheory.Moduli.JacobiSymbol
) where

import Data.Bits
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Numeric.Natural

import Math.NumberTheory.Utils
Expand Down
6 changes: 0 additions & 6 deletions Math/NumberTheory/Moduli/Singleton.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- Singleton data types.
--

{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
Expand Down Expand Up @@ -51,9 +50,6 @@ import Data.Kind
import Data.List (sort)
import qualified Data.Map as M
import Data.Proxy
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import GHC.Generics
import GHC.TypeNats (KnownNat, Nat, natVal)
import Numeric.Natural
Expand Down Expand Up @@ -315,6 +311,4 @@ pattern CGOddPrimePower p k <- CGOddPrimePower' p k
pattern CGDoubleOddPrimePower :: Prime a -> Word -> CyclicGroup a m
pattern CGDoubleOddPrimePower p k <- CGDoubleOddPrimePower' p k

#if __GLASGOW_HASKELL__ > 801
{-# COMPLETE CG2, CG4, CGOddPrimePower, CGDoubleOddPrimePower #-}
#endif
4 changes: 0 additions & 4 deletions Math/NumberTheory/Moduli/SomeMod.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- Safe modular arithmetic with modulo on type level.
--

{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
Expand All @@ -23,9 +22,6 @@ module Math.NumberTheory.Moduli.SomeMod
import Data.Euclidean (GcdDomain(..), Euclidean(..), Field)
import Data.Mod
import Data.Proxy
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Data.Semiring (Semiring(..), Ring(..))
import Data.Type.Equality
import GHC.TypeNats (KnownNat, SomeNat(..), sameNat, natVal, someNatVal)
Expand Down
4 changes: 0 additions & 4 deletions Math/NumberTheory/Primes/Factorisation/LinearAlgebra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- <http://www.enseignement.polytechnique.fr/profs/informatique/Francois.Morain/Master1/Crypto/projects/Wiedemann86.pdf Weidemann algorithm>
-- to find a non-zero element in the kernel of a singular sparse binary matrix.

{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
Expand All @@ -24,9 +23,6 @@ module Math.NumberTheory.Primes.Factorisation.LinearAlgebra
, linearSolve
) where

#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import qualified Data.List as L
import qualified Data.Vector as V
import qualified Data.Vector.Sized as SV
Expand Down
3 changes: 0 additions & 3 deletions Math/NumberTheory/Primes/Factorisation/Montgomery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ import Data.List (foldl')
import Data.Maybe
import Data.Mod
import Data.Proxy
#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import Data.Traversable
import GHC.Exts
import GHC.Num.BigNat
Expand Down
10 changes: 0 additions & 10 deletions Math/NumberTheory/Primes/Factorisation/QuadraticSieve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- <https://en.wikipedia.org/wiki/Quadratic_sieve Quadratic Sieve> algorithm
-- employing multiple polynomials and large prime variation.

{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TupleSections #-}
Expand All @@ -21,9 +20,6 @@ module Math.NumberTheory.Primes.Factorisation.QuadraticSieve
, findRoots
) where

#if __GLASGOW_HASKELL__ < 803
import Data.Semigroup
#endif
import qualified Data.Map as M
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
Expand Down Expand Up @@ -344,14 +340,8 @@ appearsOnlyOnce = fst . M.foldl' go (mempty, mempty)
go (onlyOnce, atLeastOnce) x =
((onlyOnce IS.\\ x) <> (x IS.\\ atLeastOnce), atLeastOnce <> x)

#if MIN_VERSION_containers(0,5,11)
disjoint :: IS.IntSet -> IS.IntSet -> Bool
disjoint = IS.disjoint
#else

disjoint :: IS.IntSet -> IS.IntSet -> Bool
disjoint x y = IS.null (IS.intersection x y)
#endif

setOddPowers :: IM.IntMap Int -> IS.IntSet
setOddPowers = IM.keysSet . IM.filter odd
Expand Down
7 changes: 0 additions & 7 deletions Math/NumberTheory/Primes/IntSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
--

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -179,15 +178,9 @@ isSubsetOf = coerce IS.isSubsetOf
isProperSubsetOf :: PrimeIntSet -> PrimeIntSet -> Bool
isProperSubsetOf = coerce IS.isProperSubsetOf

#if MIN_VERSION_containers(0,5,11)
-- | Check whether two sets are disjoint.
disjoint :: PrimeIntSet -> PrimeIntSet -> Bool
disjoint = coerce IS.disjoint
#else
-- | Check whether two sets are disjoint.
disjoint :: PrimeIntSet -> PrimeIntSet -> Bool
disjoint (PrimeIntSet x) (PrimeIntSet y) = IS.null (IS.intersection x y)
#endif

-- | Difference between a set of primes and a set of integers.
difference :: PrimeIntSet -> IntSet -> PrimeIntSet
Expand Down
6 changes: 3 additions & 3 deletions arithmoi.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description:
powers (integer roots and tests, modular exponentiation).
category: Math, Algorithms, Number Theory
author: Andrew Lelechenko, Daniel Fischer
tested-with: GHC ==8.2.2 GHC ==8.4.4 GHC ==8.6.5 GHC ==8.8.4 GHC ==8.10.7 GHC ==9.0.2 GHC ==9.2.5 GHC ==9.4.4 GHC ==9.6.1
tested-with: GHC ==9.0.2 GHC ==9.2.5 GHC ==9.4.4 GHC ==9.6.1
extra-source-files:
changelog.md

Expand All @@ -27,9 +27,9 @@ source-repository head

library
build-depends:
base >=4.10 && <5,
base >=4.15 && <5,
array >=0.5 && <0.6,
containers >=0.5.8 && <0.7,
containers >=0.5.11 && <0.7,
chimera >=0.3,
constraints,
deepseq,
Expand Down
Loading

0 comments on commit c72a101

Please sign in to comment.