diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 52de92e..1629173 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.17.20231010 +# version: 0.19.20240702 # -# REGENDATA ("0.17.20231010",["github","cabal.project"]) +# REGENDATA ("0.19.20240702",["github","cabal.project"]) # name: Haskell-CI on: @@ -27,24 +27,29 @@ jobs: timeout-minutes: 60 container: - image: buildpack-deps:bionic + image: buildpack-deps:jammy continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - - compiler: ghc-9.8.1 + - compiler: ghc-9.10.1 compilerKind: ghc - compilerVersion: 9.8.1 + compilerVersion: 9.10.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.6.3 + - compiler: ghc-9.8.2 compilerKind: ghc - compilerVersion: 9.6.3 + compilerVersion: 9.8.2 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.7 + - compiler: ghc-9.6.6 compilerKind: ghc - compilerVersion: 9.4.7 + compilerVersion: 9.6.6 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.4.8 + compilerKind: ghc + compilerVersion: 9.4.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.2.8 @@ -65,47 +70,12 @@ jobs: - compiler: ghc-8.8.4 compilerKind: ghc compilerVersion: 8.8.4 - setup-method: hvr-ppa + setup-method: ghcup 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 - - compiler: ghc-8.0.2 - compilerKind: ghc - 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 + setup-method: ghcup allow-failure: false fail-fast: false steps: @@ -113,21 +83,11 @@ jobs: 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.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.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.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - fi + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -139,22 +99,13 @@ 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/ghcup" whereis ghc "$HCVER") - HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') - HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" - echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.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.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - fi - + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.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" @@ -211,16 +162,16 @@ jobs: chmod a+x $HOME/.cabal/bin/cabal-plan cabal-plan --version - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: source - name: initial cabal.project for sdist run: | touch cabal.project echo "packages: $GITHUB_WORKSPACE/source/strict" >> cabal.project - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/strict-lens" >> cabal.project ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/strict-base-types" >> cabal.project ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: $GITHUB_WORKSPACE/source/strict-optics" >> cabal.project ; fi + echo "packages: $GITHUB_WORKSPACE/source/strict-lens" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/strict-base-types" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/strict-optics" >> cabal.project cat cabal.project - name: sdist run: | @@ -244,20 +195,20 @@ jobs: touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_strict}" >> cabal.project - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: ${PKGDIR_strict_lens}" >> cabal.project ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: ${PKGDIR_strict_base_types}" >> cabal.project ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then echo "packages: ${PKGDIR_strict_optics}" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package strict" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package strict-lens" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package strict-base-types" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package strict-optics" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi + echo "packages: ${PKGDIR_strict_lens}" >> cabal.project + echo "packages: ${PKGDIR_strict_base_types}" >> cabal.project + echo "packages: ${PKGDIR_strict_optics}" >> cabal.project + echo "package strict" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + echo "package strict-lens" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + echo "package strict-base-types" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project + echo "package strict-optics" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(strict|strict-base-types|strict-lens|strict-optics)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan @@ -265,7 +216,7 @@ jobs: $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all cabal-plan - name: restore cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store @@ -280,12 +231,12 @@ jobs: run: | cd ${PKGDIR_strict} || false ${CABAL} -vnormal check - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then cd ${PKGDIR_strict_lens} || false ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then cd ${PKGDIR_strict_base_types} || false ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then cd ${PKGDIR_strict_optics} || false ; fi - if [ $((HCNUMVER >= 80000)) -ne 0 ] ; then ${CABAL} -vnormal check ; fi + cd ${PKGDIR_strict_lens} || false + ${CABAL} -vnormal check + cd ${PKGDIR_strict_base_types} || false + ${CABAL} -vnormal check + cd ${PKGDIR_strict_optics} || false + ${CABAL} -vnormal check - name: haddock run: | $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all @@ -294,7 +245,7 @@ jobs: rm -f cabal.project.local $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all - name: save cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: always() with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} diff --git a/cabal.haskell-ci b/cabal.haskell-ci index c1978a6..9b7ca12 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -3,9 +3,6 @@ branches: master -- we have inplace dependencies install-dependencies: False --- to allow different set of packages per GHC versions -jobs-selection: any - -- Don't use head.hackage head-hackage: False diff --git a/strict-base-types/strict-base-types.cabal b/strict-base-types/strict-base-types.cabal index a3a957d..621d32e 100644 --- a/strict-base-types/strict-base-types.cabal +++ b/strict-base-types/strict-base-types.cabal @@ -1,6 +1,5 @@ name: strict-base-types -version: 0.8 -x-revision: 1 +version: 0.8.1 synopsis: Strict variants of the types provided in base. category: Data description: @@ -25,17 +24,15 @@ homepage: https://github.com/haskell-strict/strict cabal-version: >=1.10 build-type: Simple tested-with: - GHC ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 + || ==9.10.1 extra-source-files: CHANGES @@ -48,11 +45,11 @@ library default-language: Haskell2010 ghc-options: -Wall build-depends: - aeson >=2.1.2.1 && <2.3 - , base >=4.9 && <5 - , quickcheck-instances >=0.3.24 && <0.4 - , strict >=0.5 && <0.5.1 - , strict-lens >=0.4 && <0.5 + aeson >=2.2.3.0 && <2.3 + , base >=4.12.0.0 && <5 + , quickcheck-instances >=0.3.31 && <0.4 + , strict >=0.5.1 && <0.5.2 + , strict-lens >=0.4.1 && <0.4.2 hs-source-dirs: src exposed-modules: diff --git a/strict-lens/strict-lens.cabal b/strict-lens/strict-lens.cabal index 77879f7..9290aea 100644 --- a/strict-lens/strict-lens.cabal +++ b/strict-lens/strict-lens.cabal @@ -1,5 +1,5 @@ name: strict-lens -version: 0.4.0.3 +version: 0.4.1 synopsis: Lenses for types in strict package category: Data, Lenses description: Lenses for types in strict package. @@ -18,17 +18,15 @@ homepage: https://github.com/haskell-strict/strict cabal-version: >=1.10 build-type: Simple tested-with: - GHC ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 + || ==9.10.1 extra-source-files: CHANGES.md @@ -47,9 +45,9 @@ library -Wnoncanonical-monadfail-instances build-depends: - base >=4.9 && <5 - , lens >=5.2.1 && <5.3 - , strict >=0.5 && <0.6 + base >=4.12.0.0 && <5 + , lens >=5.2.1 && <5.4 + , strict >=0.5.1 && <0.6 hs-source-dirs: src exposed-modules: Data.Strict.Lens diff --git a/strict-optics/strict-optics.cabal b/strict-optics/strict-optics.cabal index 7f99ef0..be24e29 100644 --- a/strict-optics/strict-optics.cabal +++ b/strict-optics/strict-optics.cabal @@ -1,6 +1,5 @@ name: strict-optics -version: 0.4.0.1 -x-revision: 2 +version: 0.4.1 synopsis: Optics for types in strict package category: Data, Optics description: Optics for types in strict package. @@ -20,17 +19,15 @@ homepage: https://github.com/haskell-strict/strict cabal-version: >=1.10 build-type: Simple tested-with: - GHC ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 + || ==9.10.1 extra-source-files: CHANGES.md @@ -46,9 +43,9 @@ library -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances build-depends: - base >=4.9 && <5 - , optics-core >=0.3 && <0.5 - , strict >=0.4 && <0.5.1 + base >=4.12.0.0 && <5 + , optics-core >=0.4.1.1 && <0.5 + , strict >=0.5.1 && <0.5.2 hs-source-dirs: src exposed-modules: Data.Strict.Optics diff --git a/strict/src/Data/Strict/Classes.hs b/strict/src/Data/Strict/Classes.hs index 8612ec7..4330916 100644 --- a/strict/src/Data/Strict/Classes.hs +++ b/strict/src/Data/Strict/Classes.hs @@ -1,10 +1,5 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE FunctionalDependencies #-} -#if MIN_VERSION_base(4,8,0) {-# LANGUAGE Safe #-} -#else -{-# LANGUAGE Trustworthy #-} -#endif module Data.Strict.Classes ( Strict (..), @@ -70,13 +65,8 @@ instance Strict (L.These a b) (These a b) where toLazy (These x y) = L.These x y instance Strict LBS.ByteString BS.ByteString where -#if MIN_VERSION_bytestring(0,10,0) toStrict = LBS.toStrict toLazy = LBS.fromStrict -#else - toStrict = BS.concat . LBS.toChunks - toLazy = LBS.fromChunks . L.return {- singleton -} -#endif instance Strict LT.Text T.Text where toStrict = LT.toStrict diff --git a/strict/src/Data/Strict/Either.hs b/strict/src/Data/Strict/Either.hs index fcdcf86..3fdf85b 100644 --- a/strict/src/Data/Strict/Either.hs +++ b/strict/src/Data/Strict/Either.hs @@ -1,20 +1,7 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE Safe #-} {-# LANGUAGE DeriveGeneric #-} -#if MIN_VERSION_base(4,9,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers(0,5,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#endif -#endif -#endif - ----------------------------------------------------------------------------- -- | -- @@ -47,44 +34,25 @@ import Data.Traversable (Traversable (..)) -- Lazy variants import qualified Prelude as L -import Control.DeepSeq (NFData (..)) -import Data.Bifoldable (Bifoldable (..)) -import Data.Bifunctor (Bifunctor (..)) -import Data.Binary (Binary (..)) -import Data.Bitraversable (Bitraversable (..)) -import Data.Hashable (Hashable(..)) -import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..)) -import GHC.Generics (Generic) -import Data.Data (Data (..), Typeable) - -#if __GLASGOW_HASKELL__ >= 706 -import GHC.Generics (Generic1) -#endif - -#if MIN_VERSION_deepseq(1,4,3) -import Control.DeepSeq (NFData1 (..), NFData2 (..)) -#endif - -#ifdef MIN_VERSION_assoc +import Control.DeepSeq (NFData (..), NFData1 (..), NFData2 (..)) +import Data.Bifoldable (Bifoldable (..)) +import Data.Bifunctor (Bifunctor (..)) import Data.Bifunctor.Assoc (Assoc (..)) import Data.Bifunctor.Swap (Swap (..)) -#endif +import Data.Binary (Binary (..)) +import Data.Bitraversable (Bitraversable (..)) +import Data.Data (Data (..), Typeable) +import Data.Hashable (Hashable(..)) +import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..)) +import GHC.Generics (Generic, Generic1) -#ifdef LIFTED_FUNCTOR_CLASSES import Data.Functor.Classes (Eq1 (..), Eq2 (..), Ord1 (..), Ord2 (..), Read1 (..), Read2 (..), Show1 (..), Show2 (..)) -#else -import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) -#endif -- | The strict choice type. data Either a b = Left !a | Right !b - deriving (Eq, Ord, Read, Show, Typeable, Data, Generic -#if __GLASGOW_HASKELL__ >= 706 - , Generic1 -#endif - ) + deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Generic1) toStrict :: L.Either a b -> Either a b toStrict (L.Left x) = Left x @@ -166,13 +134,11 @@ instance Semigroup (Either a b) where instance (NFData a, NFData b) => NFData (Either a b) where rnf = rnf . toLazy -#if MIN_VERSION_deepseq(1,4,3) instance (NFData a) => NFData1 (Either a) where liftRnf rnfA = liftRnf rnfA . toLazy instance NFData2 Either where liftRnf2 rnfA rnfB = liftRnf2 rnfA rnfB . toLazy -#endif -- binary instance (Binary a, Binary b) => Binary (Either a b) where @@ -210,7 +176,6 @@ instance Hashable2 Either where liftHashWithSalt2 hashA hashB salt = liftHashWithSalt2 hashA hashB salt . toLazy -- assoc -#ifdef MIN_VERSION_assoc instance Assoc Either where assoc (Left (Left a)) = Left a assoc (Left (Right b)) = Right (Left b) @@ -223,10 +188,8 @@ instance Assoc Either where instance Swap Either where swap (Left x) = Right x swap (Right x) = Left x -#endif -- Data.Functor.Classes -#ifdef LIFTED_FUNCTOR_CLASSES instance Eq2 Either where liftEq2 f _ (Left a) (Left a') = f a a' liftEq2 _ g (Right b) (Right b') = g b b' @@ -271,9 +234,3 @@ instance Read2 Either where instance Read a => Read1 (Either a) where liftReadsPrec = liftReadsPrec2 readsPrec readList -#else -instance Eq a => Eq1 (Either a) where eq1 = (==) -instance Ord a => Ord1 (Either a) where compare1 = compare -instance Show a => Show1 (Either a) where showsPrec1 = showsPrec -instance Read a => Read1 (Either a) where readsPrec1 = readsPrec -#endif diff --git a/strict/src/Data/Strict/Maybe.hs b/strict/src/Data/Strict/Maybe.hs index c50059f..76769ed 100644 --- a/strict/src/Data/Strict/Maybe.hs +++ b/strict/src/Data/Strict/Maybe.hs @@ -1,20 +1,7 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE Safe #-} {-# LANGUAGE DeriveGeneric #-} -#if MIN_VERSION_base(4,9,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers(0,5,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#endif -#endif -#endif - ----------------------------------------------------------------------------- -- | -- @@ -58,35 +45,18 @@ import Data.Traversable (Traversable (..)) -- Lazy variants import qualified Prelude as L -import Control.DeepSeq (NFData (..)) -import Data.Binary (Binary (..)) -import Data.Hashable (Hashable(..)) +import Control.DeepSeq (NFData (..), NFData1 (..)) +import Data.Binary (Binary (..)) +import Data.Data (Data (..), Typeable) +import Data.Hashable (Hashable(..)) import Data.Hashable.Lifted (Hashable1 (..)) -import GHC.Generics (Generic) -import Data.Data (Data (..), Typeable) - - -#if __GLASGOW_HASKELL__ >= 706 -import GHC.Generics (Generic1) -#endif +import GHC.Generics (Generic, Generic1) -#if MIN_VERSION_deepseq(1,4,3) -import Control.DeepSeq (NFData1 (..)) -#endif - -#ifdef LIFTED_FUNCTOR_CLASSES -import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) -#else import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) -#endif -- | The type of strict optional values. data Maybe a = Nothing | Just !a - deriving (Eq, Ord, Read, Show, Typeable, Data, Generic -#if __GLASGOW_HASKELL__ >= 706 - , Generic1 -#endif - ) + deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Generic1) toStrict :: L.Maybe a -> Maybe a toStrict L.Nothing = Nothing @@ -157,17 +127,8 @@ instance Semigroup a => Semigroup (Maybe a) where m <> Nothing = m Just x1 <> Just x2 = Just (x1 <> x2) -#if MIN_VERSION_base(4,11,0) instance Semigroup a => Monoid (Maybe a) where mempty = Nothing -#else -instance Monoid a => Monoid (Maybe a) where - mempty = Nothing - - Nothing `mappend` m = m - m `mappend` Nothing = m - Just x1 `mappend` Just x2 = Just (x1 `mappend` x2) -#endif instance Functor Maybe where fmap _ Nothing = Nothing @@ -185,10 +146,8 @@ instance Traversable Maybe where instance NFData a => NFData (Maybe a) where rnf = rnf . toLazy -#if MIN_VERSION_deepseq(1,4,3) instance NFData1 Maybe where liftRnf rnfA = liftRnf rnfA . toLazy -#endif -- binary instance Binary a => Binary (Maybe a) where @@ -203,8 +162,6 @@ instance Hashable1 Maybe where liftHashWithSalt hashA salt = liftHashWithSalt hashA salt . toLazy -- Data.Functor.Classes -#ifdef LIFTED_FUNCTOR_CLASSES - instance Eq1 Maybe where liftEq f (Just a) (Just a') = f a a' liftEq _ Nothing Nothing = True @@ -232,10 +189,3 @@ instance Read1 Maybe where (a, s2) <- ra 11 s1 return (Just a, s2) _ -> [] - -#else -instance Eq1 Maybe where eq1 = (==) -instance Ord1 Maybe where compare1 = compare -instance Show1 Maybe where showsPrec1 = showsPrec -instance Read1 Maybe where readsPrec1 = readsPrec -#endif diff --git a/strict/src/Data/Strict/These.hs b/strict/src/Data/Strict/These.hs index 7be6d4c..5bdeab0 100644 --- a/strict/src/Data/Strict/These.hs +++ b/strict/src/Data/Strict/These.hs @@ -1,21 +1,8 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE Safe #-} -#if MIN_VERSION_base(4,9,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers(0,5,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#endif -#endif -#endif - module Data.Strict.These ( These(..) @@ -62,37 +49,21 @@ import Prelude import qualified Data.These as L -#if MIN_VERSION_deepseq(1,4,3) import Control.DeepSeq (NFData1 (..), NFData2 (..)) -#endif - -#if __GLASGOW_HASKELL__ >= 706 import GHC.Generics (Generic1) -#endif - -#ifdef MIN_VERSION_assoc import Data.Bifunctor.Assoc (Assoc (..)) import Data.Bifunctor.Swap (Swap (..)) -#endif -#ifdef LIFTED_FUNCTOR_CLASSES import Data.Functor.Classes (Eq1 (..), Eq2 (..), Ord1 (..), Ord2 (..), Read1 (..), Read2 (..), Show1 (..), Show2 (..)) -#else -import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) -#endif -- $setup -- >>> import Prelude (map) -- | The strict these type. data These a b = This !a | That !b | These !a !b - deriving (Eq, Ord, Read, Show, Typeable, Data, Generic -#if __GLASGOW_HASKELL__ >= 706 - , Generic1 -#endif - ) + deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Generic1) toStrict :: L.These a b -> These a b toStrict (L.This x) = This x @@ -282,7 +253,6 @@ instance (Semigroup a) => Monad (These a) where -- Data.Functor.Classes ------------------------------------------------------------------------------- -#ifdef LIFTED_FUNCTOR_CLASSES instance Eq2 These where liftEq2 f _ (This a) (This a') = f a a' liftEq2 _ g (That b) (That b') = g b b' @@ -341,18 +311,10 @@ instance Read2 These where instance Read a => Read1 (These a) where liftReadsPrec = liftReadsPrec2 readsPrec readList -#else -instance Eq a => Eq1 (These a) where eq1 = (==) -instance Ord a => Ord1 (These a) where compare1 = compare -instance Show a => Show1 (These a) where showsPrec1 = showsPrec -instance Read a => Read1 (These a) where readsPrec1 = readsPrec -#endif - ------------------------------------------------------------------------------- -- assoc ------------------------------------------------------------------------------- -#ifdef MIN_VERSION_assoc instance Swap These where swap (This a) = That a swap (That b) = This b @@ -374,7 +336,6 @@ instance Assoc These where unassoc (These a (This b)) = This (These a b) unassoc (These a (That c)) = These (This a) c unassoc (These a (These b c)) = These (These a b) c -#endif ------------------------------------------------------------------------------- -- deepseq @@ -385,7 +346,6 @@ instance (NFData a, NFData b) => NFData (These a b) where rnf (That b) = rnf b rnf (These a b) = rnf a `seq` rnf b -#if MIN_VERSION_deepseq(1,4,3) instance NFData a => NFData1 (These a) where liftRnf _rnfB (This a) = rnf a liftRnf rnfB (That b) = rnfB b @@ -395,7 +355,6 @@ instance NFData2 These where liftRnf2 rnfA _rnfB (This a) = rnfA a liftRnf2 _rnfA rnfB (That b) = rnfB b liftRnf2 rnfA rnfB (These a b) = rnfA a `seq` rnfB b -#endif ------------------------------------------------------------------------------- -- binary diff --git a/strict/src/Data/Strict/Tuple.hs b/strict/src/Data/Strict/Tuple.hs index 49a69ea..5c06090 100644 --- a/strict/src/Data/Strict/Tuple.hs +++ b/strict/src/Data/Strict/Tuple.hs @@ -1,24 +1,8 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE Safe #-} {-# LANGUAGE DeriveGeneric #-} -#ifndef __HADDOCK__ -#ifdef __GLASGOW_HASKELL__ {-# LANGUAGE TypeOperators #-} -#endif -#endif - -#if MIN_VERSION_base(4,9,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers(0,5,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#else -#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0) -#define LIFTED_FUNCTOR_CLASSES 1 -#endif -#endif -#endif + ----------------------------------------------------------------------------- -- | @@ -32,11 +16,7 @@ module Data.Strict.Tuple ( Pair(..) -#ifndef __HADDOCK__ -#ifdef __GLASGOW_HASKELL__ - , (:!:) -#endif -#endif + , type (:!:) , fst , snd , curry @@ -58,41 +38,22 @@ import Data.Traversable (Traversable (..)) -- Lazy variants import qualified Prelude as L -import Control.DeepSeq (NFData (..)) -import Data.Bifoldable (Bifoldable (..)) -import Data.Bifunctor (Bifunctor (..)) -import Data.Binary (Binary (..)) -import Data.Bitraversable (Bitraversable (..)) -import Data.Hashable (Hashable(..)) -import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..)) -import Data.Ix (Ix (..)) -import GHC.Generics (Generic) -import Data.Data (Data (..), Typeable) - -#if __GLASGOW_HASKELL__ >= 706 -import GHC.Generics (Generic1) -#endif - -#if MIN_VERSION_deepseq(1,4,3) -import Control.DeepSeq (NFData1 (..), NFData2 (..)) -#endif - -#ifdef MIN_VERSION_assoc +import Control.DeepSeq (NFData (..), NFData1 (..), NFData2 (..)) +import Data.Bifoldable (Bifoldable (..)) +import Data.Bifunctor (Bifunctor (..)) import Data.Bifunctor.Assoc (Assoc (..)) import Data.Bifunctor.Swap (Swap (..)) -#endif +import Data.Binary (Binary (..)) +import Data.Bitraversable (Bitraversable (..)) +import Data.Data (Data (..), Typeable) +import Data.Hashable (Hashable(..)) +import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..)) +import Data.Ix (Ix (..)) +import GHC.Generics (Generic, Generic1) -#ifdef LIFTED_FUNCTOR_CLASSES import Data.Functor.Classes (Eq1 (..), Eq2 (..), Ord1 (..), Ord2 (..), Read1 (..), Read2 (..), Show1 (..), Show2 (..)) -#else -import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) -#endif - -#if __HADDOCK__ -import Data.Tuple () -#endif -- $setup -- >>> import Prelude (Char, String) @@ -102,18 +63,10 @@ infix 2 :!: -- | The type of strict pairs. data Pair a b = !a :!: !b - deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Bounded, Ix -#if __GLASGOW_HASKELL__ >= 706 - , Generic1 -#endif - ) - -#ifndef __HADDOCK__ -#ifdef __GLASGOW_HASKELL__ + deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Bounded, Ix, Generic1) + -- This gives a nicer syntax for the type but only works in GHC for now. type (:!:) = Pair -#endif -#endif toStrict :: (a, b) -> Pair a b toStrict (a, b) = a :!: b @@ -174,13 +127,11 @@ instance (Monoid a, Monoid b) => Monoid (Pair a b) where instance (NFData a, NFData b) => NFData (Pair a b) where rnf = rnf . toLazy -#if MIN_VERSION_deepseq(1,4,3) instance (NFData a) => NFData1 (Pair a) where liftRnf rnfA = liftRnf rnfA . toLazy instance NFData2 Pair where liftRnf2 rnfA rnfB = liftRnf2 rnfA rnfB . toLazy -#endif -- binary instance (Binary a, Binary b) => Binary (Pair a b) where @@ -213,17 +164,14 @@ instance Hashable2 Pair where liftHashWithSalt2 hashA hashB salt = liftHashWithSalt2 hashA hashB salt . toLazy -- assoc -#ifdef MIN_VERSION_assoc instance Assoc Pair where assoc ((a :!: b) :!: c) = (a :!: (b :!: c)) unassoc (a :!: (b :!: c)) = ((a :!: b) :!: c) instance Swap Pair where swap = Data.Strict.Tuple.swap -#endif -- Data.Functor.Classes -#ifdef LIFTED_FUNCTOR_CLASSES instance Eq2 Pair where liftEq2 f g (a :!: b) (a' :!: b') = f a a' && g b b' @@ -265,9 +213,3 @@ instance Read2 Pair where instance Read a => Read1 (Pair a) where liftReadsPrec = liftReadsPrec2 readsPrec readList -#else -instance Eq a => Eq1 (Pair a) where eq1 = (==) -instance Ord a => Ord1 (Pair a) where compare1 = compare -instance Show a => Show1 (Pair a) where showsPrec1 = showsPrec -instance Read a => Read1 (Pair a) where readsPrec1 = readsPrec -#endif diff --git a/strict/strict.cabal b/strict/strict.cabal index 2ae4e10..d3973e5 100644 --- a/strict/strict.cabal +++ b/strict/strict.cabal @@ -1,112 +1,98 @@ -Name: strict -Version: 0.5 -x-revision: 1 -Synopsis: Strict data types and String IO. -Category: Data, System -Description: - This package provides strict versions of some standard Haskell data - types (pairs, Maybe and Either). It also contains strict IO operations. - . - It is common knowledge that lazy datastructures can lead to space-leaks. - This problem is particularly prominent, when using lazy datastructures to - store the state of a long-running application in memory. One common - solution to this problem is to use @seq@ and its variants in every piece of - code that updates your state. However a much easier solution is to use - fully strict types to store such state values. By \"fully strict types\" we - mean types for whose values it holds that, if they are in weak-head normal - form, then they are also in normal form. Intuitively, this means that - values of fully strict types cannot contain unevaluated thunks. - . - To define a fully strict datatype, one typically uses the following recipe. - . - 1. Make all fields of every constructor strict; i.e., add a bang to - all fields. - . - 2. Use only strict types for the fields of the constructors. - . - The second requirement is problematic as it rules out the use of - the standard Haskell 'Maybe', 'Either', and pair types. This library - solves this problem by providing strict variants of these types and their - corresponding standard support functions and type-class instances. - . - Note that this library does currently not provide fully strict lists. - They can be added if they are really required. However, in many cases one - probably wants to use unboxed or strict boxed vectors from the 'vector' - library () instead of strict - lists. Moreover, instead of @String@s one probably wants to use strict - @Text@ values from the @text@ library - (). - . - This library comes with batteries included; i.e., mirror functions and - instances of the lazy versions in @base@. It also includes instances for - type-classes from the @deepseq@, @binary@, and @hashable@ packages. -License: BSD3 -License-File: LICENSE -Author: Roman Leshchinskiy - Simon Meier -Maintainer: Don Stewart , - Bas van Dijk , - Oleg Grenrus , - Simon Meier , - Ximin Luo -Copyright: (c) 2006-2008 by Roman Leshchinskiy - (c) 2013-2014 by Simon Meier -Homepage: https://github.com/haskell-strict/strict -Cabal-Version: >= 1.10 -Build-type: Simple +name: strict +version: 0.5.1 +synopsis: Strict data types and String IO. +category: Data, System +description: + This package provides strict versions of some standard Haskell data + types (pairs, Maybe and Either). It also contains strict IO operations. + . + It is common knowledge that lazy datastructures can lead to space-leaks. + This problem is particularly prominent, when using lazy datastructures to + store the state of a long-running application in memory. One common + solution to this problem is to use @seq@ and its variants in every piece of + code that updates your state. However a much easier solution is to use + fully strict types to store such state values. By \"fully strict types\" we + mean types for whose values it holds that, if they are in weak-head normal + form, then they are also in normal form. Intuitively, this means that + values of fully strict types cannot contain unevaluated thunks. + . + To define a fully strict datatype, one typically uses the following recipe. + . + 1. Make all fields of every constructor strict; i.e., add a bang to + all fields. + . + 2. Use only strict types for the fields of the constructors. + . + The second requirement is problematic as it rules out the use of + the standard Haskell 'Maybe', 'Either', and pair types. This library + solves this problem by providing strict variants of these types and their + corresponding standard support functions and type-class instances. + . + Note that this library does currently not provide fully strict lists. + They can be added if they are really required. However, in many cases one + probably wants to use unboxed or strict boxed vectors from the 'vector' + library () instead of strict + lists. Moreover, instead of @String@s one probably wants to use strict + @Text@ values from the @text@ library + (). + . + This library comes with batteries included; i.e., mirror functions and + instances of the lazy versions in @base@. It also includes instances for + type-classes from the @deepseq@, @binary@, and @hashable@ packages. + +license: BSD3 +license-file: LICENSE +author: + Roman Leshchinskiy + Simon Meier + +maintainer: + Don Stewart , + Bas van Dijk , + Oleg Grenrus , + Simon Meier , + Ximin Luo + +copyright: + (c) 2006-2008 by Roman Leshchinskiy + (c) 2013-2014 by Simon Meier + +homepage: https://github.com/haskell-strict/strict +cabal-version: >=1.10 +build-type: Simple extra-source-files: CHANGELOG.md tested-with: - GHC ==7.4.2 - || ==7.6.3 - || ==7.8.4 - || ==7.10.3 - || ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.6 + || ==9.8.2 + || ==9.10.1 library default-language: Haskell2010 hs-source-dirs: src ghc-options: -Wall - build-depends: - base >= 4.5.0.0 && < 5 - , assoc >= 1.1 && < 1.2 - , binary >= 0.5.1.0 && < 0.9 - , bytestring >= 0.9.2.1 && < 0.13 - , deepseq >= 1.3.0.0 && < 1.6 - , hashable >= 1.2.7.0 && < 1.5 - , text >= 1.2.3.0 && < 1.3 || >=2.0 && <2.2 - , these >= 1.2 && < 1.3 - , transformers >= 0.3.0.0 && < 0.7 + assoc >=1.1.1 && <1.2 + , base >=4.12.0.0 && <5 + , binary >=0.8.6.0 && <0.9 + , bytestring >=0.10.8.2 && <0.13 + , deepseq >=1.4.4.0 && <1.6 , ghc-prim - - if !impl(ghc >= 8.0) - build-depends: - semigroups >= 0.18.5 && < 0.21 - , transformers-compat >= 0.6.5 && < 0.8 - - -- Ensure Data.Functor.Classes is always available - if impl(ghc >= 7.10) - build-depends: transformers >= 0.4.2.0 - - if !impl(ghc >= 8.2) - build-depends: - bifunctor-classes-compat >= 0.1 && < 0.2 + , hashable >=1.4.7.0 && <1.5 + , text >=1.2.3.1 && <1.3 || >=2.0 && <2.2 + , these >=1.2.1 && <1.3 + , transformers >=0.5.6.2 && <0.7 exposed-modules: Data.Strict Data.Strict.Classes + Data.Strict.Either + Data.Strict.Maybe Data.Strict.These Data.Strict.Tuple - Data.Strict.Maybe - Data.Strict.Either System.IO.Strict