packages feed

transformers-compat 0.6.5 → 0.6.6

raw patch · 10 files changed

+275/−153 lines, 10 filesdep ~base

Dependency ranges changed: base

Files

+ .hlint.yaml view
@@ -0,0 +1,3 @@+- arguments: [--cpp-define=HLINT, --cpp-ansi]++- ignore: {name: Avoid lambda}
.travis.yml view
@@ -2,11 +2,17 @@ # #   haskell-ci '--output=.travis.yml' '--config=cabal.haskell-ci' 'cabal.project' #+# To regenerate the script (for example after adjusting tested-with) run+#+#   haskell-ci regenerate+# # For more information, see https://github.com/haskell-CI/haskell-ci #-# version: 0.3.20190425+# version: 0.10 #+version: ~> 1.0 language: c+os: linux dist: xenial git:   # whether to recursively clone submodules@@ -17,11 +23,12 @@       - irc.freenode.org#haskell-lens     skip_join: true     template:-      - "\"\\x0313transformers-compat\\x03/\\x0306%{branch}\\x03 \\x0314%{commit}\\x03 %{build_url} %{message}\""+      - "\x0313transformers-compat\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}" cache:   directories:     - $HOME/.cabal/packages     - $HOME/.cabal/store+    - $HOME/.hlint before_cache:   - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log   # remove files that are regenerated by 'cabal update'@@ -31,77 +38,66 @@   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx   - rm -rfv $CABALHOME/packages/head.hackage-matrix:+jobs:   include:-    - compiler: ghc-8.8.1-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}-      env: GHCHEAD=true+    - compiler: ghc-8.10.1+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.1","cabal-install-3.2"]}}+      os: linux+    - compiler: ghc-8.8.3+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.3","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-8.6.5-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-8.4.4-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-8.2.2-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-8.0.2-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.10.3-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.10.3","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.8.4-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.8.4","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.6.3-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.6.3","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.4.2-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.4.2","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.2.2-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.2.2","cabal-install-2.4"]}}+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.2.2","cabal-install-3.2"]}}+      os: linux     - compiler: ghc-7.0.4-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.4","cabal-install-2.4"]}}-    - compiler: ghc-head-      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}-      env: GHCHEAD=true-  allow_failures:-    - compiler: ghc-head-    - compiler: ghc-8.8.1+      addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.0.4","cabal-install-3.2"]}}+      os: linux before_install:   - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')+  - WITHCOMPILER="-w $HC"+  - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')   - HCPKG="$HC-pkg"   - unset CC   - CABAL=/opt/ghc/bin/cabal   - CABALHOME=$HOME/.cabal   - export PATH="$CABALHOME/bin:$PATH"   - TOP=$(pwd)-  - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))+  - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"   - echo $HCNUMVER-  - CABAL="$CABAL -vnormal+nowrap+markoutput"+  - CABAL="$CABAL -vnormal+nowrap"   - set -o pipefail-  - |-    echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }'           >> .colorful.awk-    echo 'BEGIN { state = "output"; }'                                     >> .colorful.awk-    echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }'            >> .colorful.awk-    echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }'             >> .colorful.awk-    echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk-    echo '  if (state == "cabal") {'                                       >> .colorful.awk-    echo '    print blue($0)'                                              >> .colorful.awk-    echo '  } else {'                                                      >> .colorful.awk-    echo '    print $0'                                                    >> .colorful.awk-    echo '  }'                                                             >> .colorful.awk-    echo '}'                                                               >> .colorful.awk-  - cat .colorful.awk-  - |-    color_cabal_output () {-      awk -f $TOP/.colorful.awk-    }-  - echo text | color_cabal_output-install:-  - ${CABAL} --version-  - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"   - TEST=--enable-tests   - BENCH=--enable-benchmarks-  - GHCHEAD=${GHCHEAD-false}+  - HEADHACKAGE=false   - rm -f $CABALHOME/config   - |     echo "verbose: normal +nowrap +markoutput"          >> $CABALHOME/config     echo "remote-build-reporting: anonymous"            >> $CABALHOME/config+    echo "write-ghc-environment-files: always"          >> $CABALHOME/config     echo "remote-repo-cache: $CABALHOME/packages"       >> $CABALHOME/config     echo "logs-dir:          $CABALHOME/logs"           >> $CABALHOME/config     echo "world-file:        $CABALHOME/world"          >> $CABALHOME/config@@ -114,19 +110,13 @@     echo "  prefix: $CABALHOME"                         >> $CABALHOME/config     echo "repository hackage.haskell.org"               >> $CABALHOME/config     echo "  url: http://hackage.haskell.org/"           >> $CABALHOME/config-  - |-    if $GHCHEAD; then-    echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config-    -    echo "repository head.hackage"                                                        >> $CABALHOME/config-    echo "   url: http://head.hackage.haskell.org/"                                       >> $CABALHOME/config-    echo "   secure: True"                                                                >> $CABALHOME/config-    echo "   root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config-    echo "              2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config-    echo "              8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config-    echo "   key-threshold: 3"                                                            >> $CABALHOME/config-    fi+install:+  - ${CABAL} --version+  - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"   - "echo 'jobs: 2' >> $CABALHOME/config"+  - |+    echo "program-default-options"                >> $CABALHOME/config+    echo "  ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config   - cat $CABALHOME/config   - rm -fv cabal.project cabal.project.local cabal.project.freeze   - travis_retry ${CABAL} v2-update -v@@ -134,70 +124,79 @@   - rm -rf cabal.project cabal.project.local cabal.project.freeze   - touch cabal.project   - |-    echo 'packages: "."' >> cabal.project-    echo 'packages: "./tests"' >> cabal.project+    echo "packages: ." >> cabal.project+    echo "packages: ./tests" >> cabal.project+  - if [ $HCNUMVER -ge 80200 ] ; then echo 'package transformers-compat' >> cabal.project ; fi+  - "if [ $HCNUMVER -ge 80200 ] ; then echo '  ghc-options: -Werror=missing-methods' >> cabal.project ; fi"+  - if [ $HCNUMVER -ge 80200 ] ; then echo 'package transformers-compat-tests' >> cabal.project ; fi+  - "if [ $HCNUMVER -ge 80200 ] ; then echo '  ghc-options: -Werror=missing-methods' >> cabal.project ; fi"   - |-    echo "write-ghc-environment-files: always" >> cabal.project-  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(transformers-compat|transformers-compat-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(transformers-compat|transformers-compat-tests)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"   - cat cabal.project || true   - cat cabal.project.local || true   - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi   - if [ -f "./tests/configure.ac" ]; then (cd "./tests" && autoreconf -i); fi-  - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output+  - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}   - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"   - rm  cabal.project.freeze script:   - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)   # Packaging...-  - ${CABAL} v2-sdist all | color_cabal_output+  - ${CABAL} v2-sdist all   # Unpacking...   - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/   - cd ${DISTDIR} || false-  - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;+  - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;+  - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm       '{}' \;+  - PKGDIR_transformers_compat="$(find . -maxdepth 1 -type d -regex '.*/transformers-compat-[0-9.]*')"+  - PKGDIR_transformers_compat_tests="$(find . -maxdepth 1 -type d -regex '.*/transformers-compat-tests-[0-9.]*')"   # Generate cabal.project   - rm -rf cabal.project cabal.project.local cabal.project.freeze   - touch cabal.project   - |-    echo 'packages: "transformers-compat-*/*.cabal"' >> cabal.project-    echo 'packages: "transformers-compat-tests-*/*.cabal"' >> cabal.project+    echo "packages: ${PKGDIR_transformers_compat}" >> cabal.project+    echo "packages: ${PKGDIR_transformers_compat_tests}" >> cabal.project+  - if [ $HCNUMVER -ge 80200 ] ; then echo 'package transformers-compat' >> cabal.project ; fi+  - "if [ $HCNUMVER -ge 80200 ] ; then echo '  ghc-options: -Werror=missing-methods' >> cabal.project ; fi"+  - if [ $HCNUMVER -ge 80200 ] ; then echo 'package transformers-compat-tests' >> cabal.project ; fi+  - "if [ $HCNUMVER -ge 80200 ] ; then echo '  ghc-options: -Werror=missing-methods' >> cabal.project ; fi"   - |-    echo "write-ghc-environment-files: always" >> cabal.project-  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(transformers-compat|transformers-compat-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(transformers-compat|transformers-compat-tests)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"   - cat cabal.project || true   - cat cabal.project.local || true   # Building with tests and benchmarks...   # build & run tests, build benchmarks-  - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+  - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all   # Testing...-  - ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+  - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all   # cabal check...-  - (cd transformers-compat-* && ${CABAL} -vnormal check)-  - (cd transformers-compat-tests-* && ${CABAL} -vnormal check)+  - (cd ${PKGDIR_transformers_compat} && ${CABAL} -vnormal check)+  - (cd ${PKGDIR_transformers_compat_tests} && ${CABAL} -vnormal check)   # haddock...-  - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output+  - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all   # Building without installed constraints for packages in global-db...   - rm -f cabal.project.local-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all   # Constraint sets   - rm -rf cabal.project.local   # Constraint set no-mtl-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat -mtl' all | color_cabal_output+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -mtl' all   # Constraint set no-generic-deriving-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' all | color_cabal_output+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' all   # Constraint set no-mtl-no-generic-deriving-  - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' --constraint='tranformers-compat -mtl' all | color_cabal_output+  - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' --constraint='tranformers-compat -mtl' all   # Constraint set two-  - if [ $HCNUMVER -lt 70900 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat +two' all | color_cabal_output ; fi+  - if [ $HCNUMVER -lt 71000 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat +two' all ; fi   # Constraint set three-  - if [ $HCNUMVER -lt 70900 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat +three' all | color_cabal_output ; fi+  - if [ $HCNUMVER -lt 71000 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat +three' all ; fi   # Constraint set four-  - if [ $HCNUMVER -lt 71100 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat +four' all | color_cabal_output ; fi+  - if [ $HCNUMVER -lt 80000 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat +four' all ; fi   # Constraint set five-  - if [ $HCNUMVER -lt 80300 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers-compat +five' all | color_cabal_output ; fi+  - if [ $HCNUMVER -lt 80400 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat +five' all ; fi   # Constraint set transformers-installed-  - if [ $HCNUMVER -ge 70800 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers installed' all | color_cabal_output ; fi+  - if [ $HCNUMVER -ge 70800 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers installed' all ; fi   # Constraint set transformers-newer-  - if [ $HCNUMVER -lt 80500 ] ; then ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks --constraint='transformers >=0.5.5.0' all | color_cabal_output ; fi+  - if [ $HCNUMVER -lt 80600 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers >=0.5.5.0' all ; fi -# REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]+# REGENDATA ("0.10",["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]) # EOF
CHANGELOG.markdown view
@@ -1,3 +1,10 @@+0.6.6 [2020.09.30]+------------------+* Add `FunctorClassesDefault`, an adapter newtype suitable for `DerivingVia`,+  to `Data.Functor.Classes.Generic`.+* Fix a bug in which `readsPrec1Default`/`liftReadsPrecDefault` would parse+  empty data types too strictly.+ 0.6.5 [2019.05.11] ------------------ * Ensure that the backported `MonadFail` instance for `ExceptT` is available
− HLint.hs
@@ -1,1 +0,0 @@-ignore "Warning: Avoid lambda"
generics/Data/Functor/Classes/Generic.hs view
@@ -43,6 +43,8 @@   , liftShowsPrecDefault   , liftShowsPrecOptions #endif+    -- * 'GenericFunctorClasses'+  , FunctorClassesDefault(..)     -- * Example     -- $example   ) where@@ -52,12 +54,29 @@  #undef MIN_VERSION_transformers {- $example-Note that this module exports different functions depending on which version of-@transformers@ this library is built against. Here is an example of how to-use this module correctly:+The most straightforward way to use the defaults in this module is to use+@DerivingVia@ on GHC 8.6 or later. For example:  @-{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveGeneric, DerivingVia #-}++import Data.Functor.Classes+import Data.Functor.Classes.Generic+import GHC.Generics++data Pair a = Pair a a+  deriving stock Generic1+  deriving (Eq1, Ord1, Read1, Show1)+           via FunctorClassesDefault Pair+@++If using an older version of GHC, then one can also define instances manually.+This is slightly trickier to accomplish since this module exports different+functions depending on which version of @transformers@ this library is built+against. Here is an example of how to define instances manually:++@+{-# LANGUAGE CPP, DeriveGeneric #-}  import Data.Functor.Classes import Data.Functor.Classes.Generic
generics/Data/Functor/Classes/Generic/Internal.hs view
@@ -10,6 +10,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}  #if __GLASGOW_HASKELL__ >= 708@@ -76,11 +77,14 @@   , GShow1(..)   , GShow1Con(..)   , Show1Args(..)+    -- * 'FunctorClassesDefault'+  , FunctorClassesDefault(..)   -- * Miscellaneous types   , V4   , NonV4   , ConType(..)-  , IsNullary(..)+  , IsNullaryDataType(..)+  , IsNullaryCon(..)   ) where  import Data.Char (isSymbol, ord)@@ -390,7 +394,7 @@ readsPrec1Options :: (GRead1 V4 (Rep1 f), Generic1 f, Read a)                   => Options -> Int -> ReadS (f a) readsPrec1Options _ p =-  readPrec_to_S (fmap to1 $ parens $ gliftReadPrec V4Read1Args) p+  readPrec_to_S (fmap to1 $ gliftReadPrec V4Read1Args) p #else -- | A sensible default 'liftReadsPrec' implementation for 'Generic1' instances. liftReadsPrecDefault :: (GRead1 NonV4 (Rep1 f), Generic1 f)@@ -402,7 +406,7 @@ liftReadsPrecOptions :: (GRead1 NonV4 (Rep1 f), Generic1 f)                      => Options -> (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a) liftReadsPrecOptions _ rp rl p =-  readPrec_to_S (fmap to1 $ parens $ gliftReadPrec+  readPrec_to_S (fmap to1 $ gliftReadPrec                       (NonV4Read1Args (readS_to_Prec rp)                                       (readS_to_Prec (const rl)))) p #endif@@ -457,9 +461,17 @@ class GRead1 v f where   gliftReadPrec :: Read1Args v a -> ReadPrec (f a) -instance GRead1 v f => GRead1 v (D1 d f) where-  gliftReadPrec = coerceM1 . gliftReadPrec+instance (GRead1 v f, IsNullaryDataType f) => GRead1 v (D1 d f) where+  gliftReadPrec = coerceM1 . parensIfNonNullary . gliftReadPrec+    where+      x :: f p+      x = undefined +      parensIfNonNullary :: ReadPrec a -> ReadPrec a+      parensIfNonNullary = if isNullaryDataType x+                              then id+                              else parens+ instance GRead1 v V1 where   gliftReadPrec _ = pfail @@ -467,7 +479,7 @@   gliftReadPrec ras =     fmap L1 (gliftReadPrec ras) +++ fmap R1 (gliftReadPrec ras) -instance (Constructor c, GRead1Con v f, IsNullary f) => GRead1 v (C1 c f) where+instance (Constructor c, GRead1Con v f, IsNullaryCon f) => GRead1 v (C1 c f) where   gliftReadPrec ras = coerceM1 $ case fixity of       Prefix -> precIfNonNullary $ do                   if conIsTuple c@@ -489,7 +501,7 @@       fixity = conFixity c        precIfNonNullary :: ReadPrec a -> ReadPrec a-      precIfNonNullary = if isNullary x+      precIfNonNullary = if isNullaryCon x                             then id                             else prec (if conIsRecord c                                           then appPrec1@@ -648,16 +660,16 @@   gliftShowsPrec opts sas p (L1 x) = gliftShowsPrec opts sas p x   gliftShowsPrec opts sas p (R1 x) = gliftShowsPrec opts sas p x -instance (Constructor c, GShow1Con v f, IsNullary f) => GShow1 v (C1 c f) where+instance (Constructor c, GShow1Con v f, IsNullaryCon f) => GShow1 v (C1 c f) where   gliftShowsPrec opts sas p c@(M1 x) = case fixity of       Prefix -> showParen ( p > appPrec-                             && not (isNullary x || conIsTuple c)+                             && not (isNullaryCon x || conIsTuple c)                            ) $              (if conIsTuple c                  then id                  else let cn = conName c                       in showParen (isInfixDataCon cn) (showString cn))-           . (if isNullary x || conIsTuple c+           . (if isNullaryCon x || conIsTuple c                  then id                  else showChar ' ')            . showBraces t (gliftShowsPrecCon opts t sas appPrec1 x)@@ -786,6 +798,38 @@ #endif  -------------------------------------------------------------------------------+-- * GenericFunctorClasses+-------------------------------------------------------------------------------++-- | An adapter newtype, suitable for @DerivingVia@. Its 'Eq1', 'Ord1',+-- 'Read1', and 'Show1' instances leverage 'Generic1'-based defaults.+newtype FunctorClassesDefault f a =+  FunctorClassesDefault { getFunctorClassesDefault :: f a }++#if defined(TRANSFORMERS_FOUR)+instance (GEq1 V4 (Rep1 f), Generic1 f) => Eq1 (FunctorClassesDefault f) where+   eq1 (FunctorClassesDefault x) (FunctorClassesDefault y) = eq1Default x y+instance (GOrd1 V4 (Rep1 f), Generic1 f) => Ord1 (FunctorClassesDefault f) where+   compare1 (FunctorClassesDefault x) (FunctorClassesDefault y) = compare1Default x y+instance (GRead1 V4 (Rep1 f), Generic1 f) => Read1 (FunctorClassesDefault f) where+   readsPrec1 p = coerceFCD (readsPrec1Default p)+instance (GShow1 V4 (Rep1 f), Generic1 f) => Show1 (FunctorClassesDefault f) where+   showsPrec1 p (FunctorClassesDefault x) = showsPrec1Default p x+#else+instance (GEq1 NonV4 (Rep1 f), Generic1 f) => Eq1 (FunctorClassesDefault f) where+   liftEq f (FunctorClassesDefault x) (FunctorClassesDefault y) = liftEqDefault f x y+instance (GOrd1 NonV4 (Rep1 f), Generic1 f) => Ord1 (FunctorClassesDefault f) where+   liftCompare f (FunctorClassesDefault x) (FunctorClassesDefault y) = liftCompareDefault f x y+instance (GRead1 NonV4 (Rep1 f), Generic1 f) => Read1 (FunctorClassesDefault f) where+   liftReadsPrec rp rl p = coerceFCD (liftReadsPrecDefault rp rl p)+instance (GShow1 NonV4 (Rep1 f), Generic1 f) => Show1 (FunctorClassesDefault f) where+   liftShowsPrec sp sl p (FunctorClassesDefault x) = liftShowsPrecDefault sp sl p x+#endif++coerceFCD :: ReadS (f a) -> ReadS (FunctorClassesDefault f a)+coerceFCD = coerce++------------------------------------------------------------------------------- -- * Shared code ------------------------------------------------------------------------------- @@ -825,48 +869,63 @@ isInfixDataCon (':':_) = True isInfixDataCon _       = False +-- | Class of generic representation types that represent a data type with+-- zero or more constructors.+class IsNullaryDataType f where+    -- | Returns 'True' if the data type has no constructors.+    isNullaryDataType :: f a -> Bool++instance IsNullaryDataType (f :+: g) where+    isNullaryDataType _ = False++instance IsNullaryDataType (C1 c f) where+    isNullaryDataType _ = False+ -- | Class of generic representation types that represent a constructor with -- zero or more fields.-class IsNullary f where-    -- Returns 'True' if the constructor has no fields.-    isNullary :: f a -> Bool+class IsNullaryCon f where+    -- | Returns 'True' if the constructor has no fields.+    isNullaryCon :: f a -> Bool -instance IsNullary U1 where-    isNullary _ = True+instance IsNullaryDataType V1 where+    isNullaryDataType _ = True -instance IsNullary Par1 where-    isNullary _ = False+instance IsNullaryCon U1 where+    isNullaryCon _ = True -instance IsNullary (K1 i c) where-    isNullary _ = False+instance IsNullaryCon Par1 where+    isNullaryCon _ = False -instance IsNullary f => IsNullary (S1 s f) where-    isNullary (M1 x) = isNullary x+instance IsNullaryCon (K1 i c) where+    isNullaryCon _ = False -instance IsNullary (Rec1 f) where-    isNullary _ = False+instance IsNullaryCon f => IsNullaryCon (S1 s f) where+    isNullaryCon (M1 x) = isNullaryCon x -instance IsNullary (f :*: g) where-    isNullary _ = False+instance IsNullaryCon (Rec1 f) where+    isNullaryCon _ = False -instance IsNullary (f :.: g) where-    isNullary _ = False+instance IsNullaryCon (f :*: g) where+    isNullaryCon _ = False +instance IsNullaryCon (f :.: g) where+    isNullaryCon _ = False+ #if MIN_VERSION_base(4,9,0) || defined(GENERIC_DERIVING)-instance IsNullary UChar where-    isNullary _ = False+instance IsNullaryCon UChar where+    isNullaryCon _ = False -instance IsNullary UDouble where-    isNullary _ = False+instance IsNullaryCon UDouble where+    isNullaryCon _ = False -instance IsNullary UFloat where-    isNullary _ = False+instance IsNullaryCon UFloat where+    isNullaryCon _ = False -instance IsNullary UInt where-    isNullary _ = False+instance IsNullaryCon UInt where+    isNullaryCon _ = False -instance IsNullary UWord where-    isNullary _ = False+instance IsNullaryCon UWord where+    isNullaryCon _ = False  # if __GLASGOW_HASKELL__ < 708 isTrue# :: Bool -> Bool
tests/GenericsSpec.hs view
@@ -1,12 +1,7 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE ScopedTypeVariables #-} module GenericsSpec (main, spec) where -#if !(MIN_VERSION_base(4,8,0))-import Control.Applicative-#endif- import Data.Functor.Classes import Data.Proxy (Proxy(..)) @@ -42,8 +37,8 @@ readEither' s rs =   case [ x | (x,"") <- rs minPrec s ] of     [x] -> Right x-    []  -> Left "Prelude.read: no parse"-    _   -> Left "Prelude.read: ambiguous parse"+    []  -> Left "read': no parse"+    _   -> Left "read': ambiguous parse"  read' :: String -> (Int -> ReadS a) -> a read' s = either error id . readEither' s@@ -74,10 +69,10 @@                              Show a, Show (f a), Show1 f)              => String -> Proxy (f a) -> Spec classes1Spec str proxy =-    describe str $ eqSpec proxy-                *> ordSpec proxy-                *> readSpec proxy-                *> showSpec proxy+    describe str $ do eqSpec proxy+                      ordSpec proxy+                      readSpec proxy+                      showSpec proxy  spec :: Spec spec = parallel $ do@@ -86,9 +81,19 @@     classes1Spec "Infix"     (Proxy :: Proxy (Infix Int))     classes1Spec "GADT"      (Proxy :: Proxy (GADT Int))     classes1Spec "Record"    (Proxy :: Proxy (Record Int))-    describe "Prim" $+    describe "Prim" $ do         let proxy :: Proxy (Prim Int)             proxy = Proxy-        in eqSpec proxy-        *> ordSpec proxy-        *> showSpec proxy+        eqSpec proxy+        ordSpec proxy+        showSpec proxy+    describe "Empty" $ do+        let proxy :: Proxy (Empty Int)+            proxy = Proxy+        eqSpec proxy+        ordSpec proxy+        it "should fail to parse eagerly" $ do+          let readEmpty :: String -> (Int -> ReadS (Empty Int)) -> Either String (Empty Int)+              readEmpty = readEither'+          readEmpty ""             readsPrec `shouldBe` readEmpty ""             readsPrec1+          readEmpty (error "boom") readsPrec `shouldBe` readEmpty (error "boom") readsPrec1
tests/GenericsTypes.hs view
@@ -19,9 +19,6 @@ import Data.Functor.Classes import Data.Functor.Classes.Generic -#if __GLASGOW_HASKELL__ < 800-import Generics.Deriving.TH (deriveAll1)-#endif #if __GLASGOW_HASKELL__ >= 706 import GHC.Generics (Generic1) #endif@@ -29,10 +26,18 @@  import Test.QuickCheck (Arbitrary(..), oneof) -#if __GLASGOW_HASKELL__ == 700 || __GLASGOW_HASKELL__ == 804+#if __GLASGOW_HASKELL__ < 804+import Data.Eq.Deriving (deriveEq)+import Data.Ord.Deriving (deriveOrd)+import Generics.Deriving.TH (deriveAll1)+import Text.Show.Deriving (deriveShow)+#endif++#if __GLASGOW_HASKELL__ < 806 import Text.Read.Deriving (deriveRead) #endif + data TestParam a = TestParam a (Maybe a) (Maybe (Maybe a))   deriving (Eq, Ord, Read, Show) @@ -105,6 +110,11 @@                     , (:%:)  <$> arbitrary <*> arbitrary                     ] +data Empty a++instance Arbitrary (Empty a) where+  arbitrary = return $ error "Arbitrary Empty"+ #if __GLASGOW_HASKELL__ == 700 -- Workaround for GHC Trac #5041 $(deriveRead ''T#)@@ -115,6 +125,20 @@ deriving instance Read a => Read (T# a) #endif +#if __GLASGOW_HASKELL__ >= 804+deriving instance Eq   (Empty a)+deriving instance Ord  (Empty a)+deriving instance Read (Empty a)+deriving instance Show (Empty a)+deriving instance Generic1 Empty+#else+$(deriveEq   ''Empty)+$(deriveOrd  ''Empty)+$(deriveRead ''Empty)+$(deriveShow ''Empty)+$(deriveAll1 ''Empty)+#endif+ #if __GLASGOW_HASKELL__ >= 706 deriving instance Generic1 TestParam deriving instance Generic1 T#@@ -165,6 +189,7 @@ CLASS1_INSTANCES(Infix) CLASS1_INSTANCES(GADT) CLASS1_INSTANCES(Record)+CLASS1_INSTANCES(Empty)  EQ1_INSTANCE(Prim) ORD1_INSTANCE(Prim)
tests/transformers-compat-tests.cabal view
@@ -2,7 +2,7 @@ category:      Compatibility version:       0.1 license:       BSD3-cabal-version: >= 1.8+cabal-version: >= 1.10 license-file:  LICENSE author:        Edward A. Kmett maintainer:    Edward A. Kmett <ekmett@gmail.com>@@ -23,7 +23,8 @@              , GHC == 8.2.2              , GHC == 8.4.4              , GHC == 8.6.5-             , GHC == 8.8.1+             , GHC == 8.8.3+             , GHC == 8.10.1  source-repository head   type: git@@ -42,7 +43,7 @@   other-modules:        GenericsSpec                         GenericsTypes   build-depends:        base             >= 4.3   && < 5-                      , deriving-compat  >= 0.3.4 && < 1+                      , deriving-compat  >= 0.4   && < 1                       , generic-deriving >= 1.10  && < 2                       , hspec            >= 2     && < 3                       , QuickCheck       >= 2     && < 3@@ -52,3 +53,4 @@   build-tool-depends:   hspec-discover:hspec-discover >= 2 && < 3   hs-source-dirs:       .   ghc-options:          -Wall -threaded -rtsopts+  default-language:     Haskell2010
transformers-compat.cabal view
@@ -1,8 +1,8 @@ name:          transformers-compat category:      Compatibility-version:       0.6.5+version:       0.6.6 license:       BSD3-cabal-version: >= 1.8+cabal-version: >= 1.10 license-file:  LICENSE author:        Edward A. Kmett maintainer:    Edward A. Kmett <ekmett@gmail.com>@@ -33,17 +33,18 @@              , GHC == 8.2.2              , GHC == 8.4.4              , GHC == 8.6.5-             , GHC == 8.8.1+             , GHC == 8.8.3+             , GHC == 8.10.1 extra-source-files:   .travis.yml   .ghci   .gitignore+  .hlint.yaml   .vim.custom   config   tests/*.hs   tests/LICENSE   tests/transformers-compat-tests.cabal-  HLint.hs   README.markdown   CHANGELOG.markdown @@ -108,6 +109,9 @@    other-modules:     Paths_transformers_compat++  default-language:+    Haskell2010    -- automatic flags   if flag(five-three)