transformers-compat 0.6.6 → 0.7
raw patch · 13 files changed
+858/−277 lines, 13 filesdep ~transformers
Dependency ranges changed: transformers
Files
- .travis.yml +0/−202
- 0.2/Control/Applicative/Backwards.hs +55/−0
- 0.2/Control/Applicative/Lift.hs +48/−6
- 0.2/Data/Functor/Reverse.hs +45/−0
- 0.3/Control/Monad/Trans/Except.hs +71/−3
- 0.5/Control/Monad/Trans/Accum.hs +41/−5
- 0.5/Control/Monad/Trans/Select.hs +39/−12
- CHANGELOG.markdown +11/−0
- README.markdown +1/−1
- src/Control/Monad/Trans/Instances.hs +526/−28
- tests/GenericsSpec.hs +12/−12
- tests/transformers-compat-tests.cabal +4/−3
- transformers-compat.cabal +5/−5
− .travis.yml
@@ -1,202 +0,0 @@-# This Travis job script has been generated by a script via-#-# 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.10-#-version: ~> 1.0-language: c-os: linux-dist: xenial-git:- # whether to recursively clone submodules- submodules: false-notifications:- irc:- channels:- - irc.freenode.org#haskell-lens- skip_join: true- template:- - "\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'- - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*- - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json- - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache- - 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-jobs:- include:- - 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":[{"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":[{"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":[{"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":[{"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":[{"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":[{"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":[{"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":[{"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":[{"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":[{"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|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"- - echo $HCNUMVER- - CABAL="$CABAL -vnormal+nowrap"- - set -o pipefail- - TEST=--enable-tests- - BENCH=--enable-benchmarks- - 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- echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config- echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config- echo "installdir: $CABALHOME/bin" >> $CABALHOME/config- echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config- echo "store-dir: $CABALHOME/store" >> $CABALHOME/config- echo "install-dirs user" >> $CABALHOME/config- echo " prefix: $CABALHOME" >> $CABALHOME/config- echo "repository hackage.haskell.org" >> $CABALHOME/config- echo " url: http://hackage.haskell.org/" >> $CABALHOME/config-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- # Generate cabal.project- - rm -rf cabal.project cabal.project.local cabal.project.freeze- - touch 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"- - |- - "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 $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- # Unpacking...- - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/- - cd ${DISTDIR} || false- - 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: ${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"- - |- - "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 $WITHCOMPILER ${TEST} ${BENCH} all- # Testing...- - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all- # cabal check...- - (cd ${PKGDIR_transformers_compat} && ${CABAL} -vnormal check)- - (cd ${PKGDIR_transformers_compat_tests} && ${CABAL} -vnormal check)- # haddock...- - ${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 $WITHCOMPILER --disable-tests --disable-benchmarks all- # Constraint sets- - rm -rf cabal.project.local- # Constraint set no-mtl- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -mtl' all- # Constraint set no-generic-deriving- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' all- # Constraint set no-mtl-no-generic-deriving- - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat -generic-deriving' --constraint='tranformers-compat -mtl' all- # Constraint set two- - 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 71000 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers-compat +three' all ; fi- # Constraint set four- - 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 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 $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers installed' all ; fi- # Constraint set transformers-newer- - if [ $HCNUMVER -lt 80600 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='transformers >=0.5.5.0' all ; fi--# REGENDATA ("0.10",["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"])-# EOF
0.2/Control/Applicative/Backwards.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} #ifndef HASKELL98+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} # if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-} # elif __GLASGOW_HASKELL__ >= 702@@ -33,10 +35,51 @@ import Data.Foldable import Data.Traversable +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- | The same functor, but with an 'Applicative' instance that performs -- actions in the reverse order. newtype Backwards f a = Backwards { forwards :: f a } +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+-- Generic(1) instances for Backwards+instance Generic (Backwards f a) where+ type Rep (Backwards f a) = D1 D1'Backwards (C1 C1_0'Backwards (S1 S1_0_0'Backwards (Rec0 (f a))))+ from (Backwards x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Backwards x++instance Generic1 (Backwards f) where+ type Rep1 (Backwards f) = D1 D1'Backwards (C1 C1_0'Backwards (S1 S1_0_0'Backwards (Rec1 f)))+ from1 (Backwards x) = M1 (M1 (M1 (Rec1 x)))+ to1 (M1 (M1 (M1 x))) = Backwards (unRec1 x)++data D1'Backwards+data C1_0'Backwards+data S1_0_0'Backwards++instance Datatype D1'Backwards where+ datatypeName _ = "Backwards"+ moduleName _ = "Control.Applicative.Backwards"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'Backwards where+ conName _ = "Backwards"+ conIsRecord _ = True++instance Selector S1_0_0'Backwards where+ selName _ = "forwards"+# endif+#endif+ instance (Eq1 f) => Eq1 (Backwards f) where liftEq eq (Backwards x) (Backwards y) = liftEq eq x y {-# INLINE liftEq #-}@@ -62,6 +105,8 @@ instance (Functor f) => Functor (Backwards f) where fmap f (Backwards a) = Backwards (fmap f a) {-# INLINE fmap #-}+ x <$ Backwards a = Backwards (x <$ a)+ {-# INLINE (<$) #-} -- | Apply @f@-actions in the reverse order. instance (Applicative f) => Applicative (Backwards f) where@@ -69,6 +114,16 @@ {-# INLINE pure #-} Backwards f <*> Backwards a = Backwards (a <**> f) {-# INLINE (<*>) #-}+#if MIN_VERSION_base(4,10,0)+ liftA2 f (Backwards m) (Backwards n) = Backwards $ liftA2 (flip f) n m+ {-# INLINE liftA2 #-}+#endif+#if MIN_VERSION_base(4,2,0)+ Backwards xs *> Backwards ys = Backwards (ys <* xs)+ {-# INLINE (*>) #-}+ Backwards ys <* Backwards xs = Backwards (xs *> ys)+ {-# INLINE (<*) #-}+#endif -- | Try alternatives in the same order as @f@. instance (Alternative f) => Alternative (Backwards f) where
0.2/Control/Applicative/Lift.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} #ifndef HASKELL98+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} # if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-} # elif __GLASGOW_HASKELL__ >= 702@@ -42,10 +44,51 @@ import Data.Monoid (Monoid(..)) import Data.Traversable (Traversable(traverse)) +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- | Applicative functor formed by adding pure computations to a given -- applicative functor. data Lift f a = Pure a | Other (f a) +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+-- Generic(1) instances for Lift+instance Generic (Lift f a) where+ type Rep (Lift f a) = D1 D1'Lift (C1 C1_0'Lift (S1 NoSelector (Rec0 a)) :+: C1 C1_1'Lift (S1 NoSelector (Rec0 (f a))))+ from (Pure x) = M1 (L1 (M1 (M1 (K1 x))))+ from (Other x) = M1 (R1 (M1 (M1 (K1 x))))+ to (M1 (L1 (M1 (M1 (K1 x))))) = Pure x+ to (M1 (R1 (M1 (M1 (K1 x))))) = Other x++instance Generic1 (Lift f) where+ type Rep1 (Lift f) = D1 D1'Lift (C1 C1_0'Lift (S1 NoSelector Par1) :+: C1 C1_1'Lift (S1 NoSelector (Rec1 f)))+ from1 (Pure x) = M1 (L1 (M1 (M1 (Par1 x))))+ from1 (Other x) = M1 (R1 (M1 (M1 (Rec1 x))))+ to1 (M1 (L1 (M1 (M1 x)))) = Pure (unPar1 x)+ to1 (M1 (R1 (M1 (M1 x)))) = Other (unRec1 x)++instance Datatype D1'Lift where+ datatypeName _ = "Lift"+ moduleName _ = "Control.Applicative.Lift"++instance Constructor C1_0'Lift where+ conName _ = "Pure"++instance Constructor C1_1'Lift where+ conName _ = "Other"++data D1'Lift+data C1_0'Lift+data C1_1'Lift+# endif+#endif+ instance (Eq1 f) => Eq1 (Lift f) where liftEq eq (Pure x1) (Pure x2) = eq x1 x2 liftEq _ (Pure _) (Other _) = False@@ -94,10 +137,8 @@ instance (Applicative f) => Applicative (Lift f) where pure = Pure {-# INLINE pure #-}- Pure f <*> Pure x = Pure (f x)- Pure f <*> Other y = Other (f <$> y)- Other f <*> Pure x = Other (($ x) <$> f)- Other f <*> Other y = Other (f <*> y)+ Pure f <*> ax = f <$> ax+ Other f <*> ax = Other (f <*> unLift ax) {-# INLINE (<*>) #-} -- | A combination is 'Pure' only either part is.@@ -134,8 +175,9 @@ -- | An applicative functor that collects a monoid (e.g. lists) of errors. -- A sequence of computations fails if any of its components do, but--- unlike monads made with 'ExceptT' from "Control.Monad.Trans.Except",--- these computations continue after an error, collecting all the errors.+-- unlike monads made with 'Control.Monad.Trans.Except.ExceptT' from+-- "Control.Monad.Trans.Except", these computations continue after an+-- error, collecting all the errors. -- -- * @'pure' f '<*>' 'pure' x = 'pure' (f x)@ --
0.2/Data/Functor/Reverse.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} #ifndef HASKELL98+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} # if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-} # elif __GLASGOW_HASKELL__ >= 702@@ -40,10 +42,51 @@ import Data.Traversable import Data.Monoid +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- | The same functor, but with 'Foldable' and 'Traversable' instances -- that process the elements in the reverse order. newtype Reverse f a = Reverse { getReverse :: f a } +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+-- Generic(1) instances for Reverse+instance Generic (Reverse f a) where+ type Rep (Reverse f a) = D1 D1'Reverse (C1 C1_0'Reverse (S1 S1_0_0'Reverse (Rec0 (f a))))+ from (Reverse x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Reverse x++instance Generic1 (Reverse f) where+ type Rep1 (Reverse f) = D1 D1'Reverse (C1 C1_0'Reverse (S1 S1_0_0'Reverse (Rec1 f)))+ from1 (Reverse x) = M1 (M1 (M1 (Rec1 x)))+ to1 (M1 (M1 (M1 x))) = Reverse (unRec1 x)++instance Datatype D1'Reverse where+ datatypeName _ = "Reverse"+ moduleName _ = "Data.Functor.Reverse"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'Reverse where+ conName _ = "Reverse"+ conIsRecord _ = True++instance Selector S1_0_0'Reverse where+ selName _ = "getReverse"++data D1'Reverse+data C1_0'Reverse+data S1_0_0'Reverse+# endif+#endif+ instance (Eq1 f) => Eq1 (Reverse f) where liftEq eq (Reverse x) (Reverse y) = liftEq eq x y {-# INLINE liftEq #-}@@ -90,8 +133,10 @@ {-# INLINE return #-} m >>= f = Reverse (getReverse m >>= getReverse . f) {-# INLINE (>>=) #-}+#if !(MIN_VERSION_base(4,13,0)) fail msg = Reverse (fail msg) {-# INLINE fail #-}+#endif -- | Derived instance. instance (MonadPlus m) => MonadPlus (Reverse m) where
0.3/Control/Monad/Trans/Except.hs view
@@ -8,14 +8,18 @@ #define MIN_VERSION_mtl(x,y,z) 1 #endif -#ifdef MTL+#ifndef HASKELL98+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+# ifdef MTL {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-}-# if __GLASGOW_HASKELL__ >= 704+# if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-# elif __GLASGOW_HASKELL__ >= 702+# elif __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}+# endif # endif #endif -----------------------------------------------------------------------------@@ -54,6 +58,9 @@ -- * Exception operations throwE, catchE,+ handleE,+ tryE,+ finallyE, -- * Lifting other operations liftCallCC, liftListen,@@ -86,6 +93,14 @@ import Data.Monoid import Data.Traversable (Traversable(traverse)) +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- | The parameterizable exception monad. -- -- Computations are either exceptions or normal values.@@ -134,6 +149,34 @@ -- first exception. newtype ExceptT e m a = ExceptT { runExceptT :: m (Either e a) } +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+-- Generic(1) instances for ExceptT+instance Generic (ExceptT e m a) where+ type Rep (ExceptT e m a) = D1 D1'ExceptT (C1 C1_0'ExceptT (S1 NoSelector (Rec0 (m (Either e a)))))+ from (ExceptT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = ExceptT x++instance Functor m => Generic1 (ExceptT e m) where+ type Rep1 (ExceptT e m) = D1 D1'ExceptT (C1 C1_0'ExceptT (S1 NoSelector (m :.: Rec1 (Either e))))+ from1 (ExceptT x) = M1 (M1 (M1 ((.) Comp1 (fmap Rec1) x)))+ to1 (M1 (M1 (M1 x))) = ExceptT ((.) (fmap unRec1) unComp1 x)++instance Datatype D1'ExceptT where+ datatypeName _ = "ExceptT"+ moduleName _ = "Control.Monad.Trans.Except"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'ExceptT where+ conName _ = "ExceptT"++data D1'ExceptT+data C1_0'ExceptT+# endif+#endif+ instance (Eq e, Eq1 m) => Eq1 (ExceptT e m) where liftEq eq (ExceptT x) (ExceptT y) = liftEq (liftEq eq) x y {-# INLINE liftEq #-}@@ -227,8 +270,10 @@ Left e -> return (Left e) Right x -> runExceptT (k x) {-# INLINE (>>=) #-}+#if !(MIN_VERSION_base(4,13,0)) fail = ExceptT . fail {-# INLINE fail #-}+#endif instance (Fail.MonadFail m) => Fail.MonadFail (ExceptT e m) where fail = ExceptT . Fail.fail@@ -288,6 +333,29 @@ Left l -> runExceptT (h l) Right r -> return (Right r) {-# INLINE catchE #-}++-- | The same as @'flip' 'catchE'@, which is useful in situations where+-- the code for the handler is shorter.+handleE :: Monad m => (e -> ExceptT e' m a) -> ExceptT e m a -> ExceptT e' m a+handleE = flip catchE+{-# INLINE handleE #-}++-- | Similar to 'catchE', but returns an 'Either' result which is+-- @('Right' a)@ if no exception was thown, or @('Left' ex)@ if an+-- exception @ex@ was thrown.+tryE :: Monad m => ExceptT e m a -> ExceptT e m (Either e a)+tryE m = catchE (liftM Right m) (return . Left)+{-# INLINE tryE #-}++-- | @'finallyE' a b@ executes computation @a@ followed by computation @b@,+-- even if @a@ exits early by throwing an exception. In the latter case,+-- the exception is re-thrown after @b@ has been executed.+finallyE :: Monad m => ExceptT e m a -> ExceptT e m () -> ExceptT e m a+finallyE m closer = do+ res <- tryE m+ closer+ either throwE return res+{-# INLINE finallyE #-} -- | Lift a @callCC@ operation to the new monad. liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b
0.5/Control/Monad/Trans/Accum.hs view
@@ -3,11 +3,7 @@ #ifndef HASKELL98 {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE StandaloneDeriving #-}-# if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-# elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-# endif+{-# LANGUAGE TypeFamilies #-} # if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-} # endif@@ -15,6 +11,12 @@ {-# LANGUAGE AutoDeriveTypeable #-} {-# LANGUAGE DataKinds #-} # endif+# if __GLASGOW_HASKELL__ >= 710+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE Safe #-}+# elif __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+# endif #endif ----------------------------------------------------------------------------- -- |@@ -84,6 +86,14 @@ import Data.Typeable #endif +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- --------------------------------------------------------------------------- -- | An accumulation monad parameterized by the type @w@ of output to accumulate. --@@ -144,6 +154,30 @@ -- * a writer monad transformer with the extra ability to read all previous output. newtype AccumT w m a = AccumT (w -> m (a, w)) +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 710+deriving instance Generic (AccumT w m a)+# elif __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+instance Generic (AccumT w m a) where+ type Rep (AccumT w m a) = D1 D1'AccumT (C1 C1_0'AccumT (S1 NoSelector (Rec0 (w -> m (a, w)))))+ from (AccumT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = AccumT x++instance Datatype D1'AccumT where+ datatypeName _ = "AccumT"+ moduleName _ = "Control.Monad.Trans.Accum"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'AccumT where+ conName _ = "AccumT"++data D1'AccumT+data C1_0'AccumT+# endif+#endif+ -- | Unwrap an accumulation computation. runAccumT :: AccumT w m a -> w -> m (a, w) runAccumT (AccumT f) = f@@ -205,8 +239,10 @@ ~(b, w'') <- runAccumT (k a) (w `mappend` w') return (b, w' `mappend` w'') {-# INLINE (>>=) #-}+#if !(MIN_VERSION_base(4,13,0)) fail msg = AccumT $ const (fail msg) {-# INLINE fail #-}+#endif instance (Monoid w, Functor m, Fail.MonadFail m) => Fail.MonadFail (AccumT w m) where fail msg = AccumT $ const (Fail.fail msg)
0.5/Control/Monad/Trans/Select.hs view
@@ -3,11 +3,7 @@ # ifndef HASKELL98 {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE StandaloneDeriving #-}-# if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-# elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-# endif+{-# LANGUAGE TypeFamilies #-} # if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-} # endif@@ -15,6 +11,12 @@ {-# LANGUAGE AutoDeriveTypeable #-} {-# LANGUAGE DataKinds #-} # endif+# if __GLASGOW_HASKELL__ >= 710+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE Safe #-}+# elif __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+# endif #endif ----------------------------------------------------------------------------- -- |@@ -49,7 +51,6 @@ mapSelectT, -- * Monad transformation selectToContT,- selectToCont, ) where import Control.Monad.IO.Class@@ -65,6 +66,14 @@ import Data.Typeable #endif +#ifndef HASKELL98+# ifdef GENERIC_DERIVING+import Generics.Deriving.Base+# elif __GLASGOW_HASKELL__ >= 702+import GHC.Generics+# endif+#endif+ -- | Selection monad. type Select r = SelectT r Identity @@ -85,6 +94,30 @@ -- cannot be lifted through it. newtype SelectT r m a = SelectT ((a -> m r) -> m a) +#ifndef HASKELL98+# if __GLASGOW_HASKELL__ >= 710+deriving instance Generic (SelectT r m a)+# elif __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)+instance Generic (SelectT r m a) where+ type Rep (SelectT r m a) = D1 D1'SelectT (C1 C1_0'SelectT (S1 NoSelector (Rec0 ((a -> m r) -> m a))))+ from (SelectT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = SelectT x++instance Datatype D1'SelectT where+ datatypeName _ = "SelectT"+ moduleName _ = "Control.Monad.Trans.Select"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'SelectT where+ conName _ = "SelectT"++data D1'SelectT+data C1_0'SelectT+# endif+#endif+ -- | Runs a @SelectT@ computation with a function for evaluating answers -- to select a particular answer. (The inverse of 'select'.) runSelectT :: SelectT r m a -> (a -> m r) -> m a@@ -165,9 +198,3 @@ -- | Convert a selection computation to a continuation-passing computation. selectToContT :: (Monad m) => SelectT r m a -> ContT r m a selectToContT (SelectT g) = ContT $ \ k -> g k >>= k-{-# INLINE selectToCont #-}---- | Deprecated name for 'selectToContT'.-{-# DEPRECATED selectToCont "Use selectToContT instead" #-}-selectToCont :: (Monad m) => SelectT r m a -> ContT r m a-selectToCont = selectToContT
CHANGELOG.markdown view
@@ -1,3 +1,14 @@+0.7 [2021.07.25]+----------------+* Backport changes from `transformers-0.6.*`:+ * Remove the long-deprecated `selectToCont` function from+ `Control.Monad.Trans.Select`.+ * Backport various `Generic`, `Generic1`, and `Data` instances.+ * Backport `handleE`, `tryE`, and `finallyE` to `Control.Monad.Trans.Except`.+ * Backport explicit implementations of `(<$)`, `liftA2`, `(*>)`, and `(<*)`+ for `Control.Applicative.Backwards`.+ * Backport a lazier implementation of `(<*>)` for `Control.Applicative.Lift`.+ 0.6.6 [2020.09.30] ------------------ * Add `FunctorClassesDefault`, an adapter newtype suitable for `DerivingVia`,
README.markdown view
@@ -1,7 +1,7 @@ transformers-compat =================== -[](https://hackage.haskell.org/package/transformers-compat) [](http://travis-ci.org/ekmett/transformers-compat)+[](https://hackage.haskell.org/package/transformers-compat) [](https://github.com/ekmett/transformers-compat/actions?query=workflow%3AHaskell-CI) This provides a thin compatibility shim on top of transformers-0.2 to add the types that were added in transformers-0.3.
src/Control/Monad/Trans/Instances.hs view
@@ -20,6 +20,10 @@ # if __GLASGOW_HASKELL__ >= 708 {-# LANGUAGE DataKinds #-} # endif++# if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE DeriveGeneric #-}+# endif #endif {-# OPTIONS_GHC -fno-warn-deprecations #-}@@ -52,10 +56,8 @@ import Control.Monad.Trans.Accum (AccumT(..)) import Control.Monad.Trans.Class (MonadTrans(..)) import Control.Monad.Trans.Cont (ContT(..))-import Control.Monad.Trans.Error (Error(..), ErrorT(..)) import Control.Monad.Trans.Except (ExceptT(..)) import Control.Monad.Trans.Identity (IdentityT(..))-import Control.Monad.Trans.List (ListT(..), mapListT) import Control.Monad.Trans.Maybe (MaybeT(..)) import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST(..)) import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST(..))@@ -86,6 +88,11 @@ import Data.Traversable (Traversable(..)) import Foreign (Storable(..), castPtr) +#if !(MIN_VERSION_transformers(0,6,0))+import Control.Monad.Trans.Error (Error(..), ErrorT(..))+import Control.Monad.Trans.List (ListT(..), mapListT)+#endif+ #if MIN_VERSION_base(4,4,0) import Control.Monad.Zip (MonadZip(..)) #endif@@ -120,25 +127,12 @@ #if !(MIN_VERSION_transformers(0,3,0)) -- Foldable/Traversable instances-instance (Foldable f) => Foldable (ErrorT e f) where- foldMap f (ErrorT a) = foldMap (either (const mempty) f) a--instance (Traversable f) => Traversable (ErrorT e f) where- traverse f (ErrorT a) =- ErrorT <$> traverse (either (pure . Left) (fmap Right . f)) a- instance (Foldable f) => Foldable (IdentityT f) where foldMap f (IdentityT a) = foldMap f a instance (Traversable f) => Traversable (IdentityT f) where traverse f (IdentityT a) = IdentityT <$> traverse f a -instance (Foldable f) => Foldable (ListT f) where- foldMap f (ListT a) = foldMap (foldMap f) a--instance (Traversable f) => Traversable (ListT f) where- traverse f (ListT a) = ListT <$> traverse (traverse f) a- instance (Foldable f) => Foldable (MaybeT f) where foldMap f (MaybeT a) = foldMap (foldMap f) a @@ -159,6 +153,21 @@ traverse f = fmap Strict.WriterT . traverse f' . Strict.runWriterT where f' (a, b) = fmap (\ c -> (c, b)) (f a) +# if !(MIN_VERSION_transformers(0,6,0))+instance (Foldable f) => Foldable (ErrorT e f) where+ foldMap f (ErrorT a) = foldMap (either (const mempty) f) a++instance (Traversable f) => Traversable (ErrorT e f) where+ traverse f (ErrorT a) =+ ErrorT <$> traverse (either (pure . Left) (fmap Right . f)) a++instance (Foldable f) => Foldable (ListT f) where+ foldMap f (ListT a) = foldMap (foldMap f) a++instance (Traversable f) => Traversable (ListT f) where+ traverse f (ListT a) = ListT <$> traverse (traverse f) a+# endif+ -- MonadFix instances for IdentityT and MaybeT instance (MonadFix m) => MonadFix (IdentityT m) where mfix f = IdentityT (mfix (runIdentityT . f))@@ -219,17 +228,10 @@ fail msg = ContT $ \ _ -> Fail.fail msg {-# INLINE fail #-} -instance (Monad m, Error e) => Fail.MonadFail (ErrorT e m) where- fail msg = ErrorT $ return (Left (strMsg msg))- instance (Fail.MonadFail m) => Fail.MonadFail (IdentityT m) where fail msg = IdentityT $ Fail.fail msg {-# INLINE fail #-} -instance (Monad m) => Fail.MonadFail (ListT m) where- fail _ = ListT $ return []- {-# INLINE fail #-}- instance (Monad m) => Fail.MonadFail (MaybeT m) where fail _ = MaybeT (return Nothing) {-# INLINE fail #-}@@ -262,6 +264,15 @@ fail msg = Strict.WriterT $ Fail.fail msg {-# INLINE fail #-} +# if !(MIN_VERSION_transformers(0,6,0))+instance (Monad m, Error e) => Fail.MonadFail (ErrorT e m) where+ fail msg = ErrorT $ return (Left (strMsg msg))++instance (Monad m) => Fail.MonadFail (ListT m) where+ fail _ = ListT $ return []+ {-# INLINE fail #-}+# endif+ # if MIN_VERSION_transformers(0,4,0) && !(MIN_VERSION_base(4,9,0)) instance (Fail.MonadFail m) => Fail.MonadFail (ExceptT e m) where fail = ExceptT . Fail.fail@@ -290,9 +301,6 @@ instance (MonadZip m) => MonadZip (IdentityT m) where mzipWith f (IdentityT a) (IdentityT b) = IdentityT (mzipWith f a b) -instance (MonadZip m) => MonadZip (ListT m) where- mzipWith f (ListT a) (ListT b) = ListT $ mzipWith (zipWith f) a b- instance (MonadZip m) => MonadZip (MaybeT m) where mzipWith f (MaybeT a) (MaybeT b) = MaybeT $ mzipWith (liftA2 f) a b @@ -308,6 +316,11 @@ mzipWith f (Strict.WriterT x) (Strict.WriterT y) = Strict.WriterT $ mzipWith (\ (a, w) (b, w') -> (f a b, w `mappend` w')) x y +# if !(MIN_VERSION_transformers(0,6,0))+instance (MonadZip m) => MonadZip (ListT m) where+ mzipWith f (ListT a) (ListT b) = ListT $ mzipWith (zipWith f) a b+# endif+ # if !(MIN_VERSION_base(4,8,0)) instance MonadZip Identity where mzipWith f (Identity x) (Identity y) = Identity (f x y)@@ -336,12 +349,9 @@ -- Typeable instances # if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKELL__ < 710 deriving instance Typeable Backwards-deriving instance Typeable Constant deriving instance Typeable ContT-deriving instance Typeable ErrorT deriving instance Typeable IdentityT deriving instance Typeable Lift-deriving instance Typeable ListT deriving instance Typeable MaybeT deriving instance Typeable MonadTrans deriving instance Typeable Lazy.RWST@@ -350,6 +360,10 @@ deriving instance Typeable Reverse deriving instance Typeable Lazy.StateT deriving instance Typeable Strict.StateT+# if !(MIN_VERSION_transformers(0,6,0))+deriving instance Typeable ErrorT+deriving instance Typeable ListT+# endif # if !(MIN_VERSION_base(4,9,0)) deriving instance Typeable Compose@@ -605,11 +619,13 @@ {-# INLINE (<>) #-} # endif +# if !(MIN_VERSION_transformers(0,6,0)) instance (MonadFix m) => MonadFix (ListT m) where mfix f = ListT $ mfix (runListT . f . head) >>= \ xs -> case xs of [] -> return [] x:_ -> liftM (x:) (runListT (mfix (mapListT (liftM tail) . f))) {-# INLINE mfix #-}+# endif #endif -- Generic(1) instances@@ -748,5 +764,487 @@ # endif # endif +# endif++# if !(MIN_VERSION_transformers(0,6,0))+# if __GLASGOW_HASKELL__ >= 708+-- If we wanted to be 100% faithful to the original Data instance in+-- transformers, we really ought to define an instance like:+--+-- instance (Data a, Typeable k, Typeable (b :: k)) => Data (Constant a b)+--+-- Unfortunately, this is not possible to do with a standalone-derived Data+-- instance (see https://gitlab.haskell.org/ghc/ghc/-/issues/13327).+-- For now, I've opted to just restrict the instance context slightly by using+-- a `Data b` constraint. I'll wait for someone to complain about this before+-- taking further action on it.+deriving instance (Data a, Data b) => Data (Constant a b)+# if __GLASGOW_HASKELL__ < 710+deriving instance Typeable Constant+# endif+# endif++-- The use of GHC 8.0 in this CPP is a conservative lower bound for+-- determining the earliest version of GHC that can derive Generic(1)+-- instances for all data types without bugs. We might be able to pick+-- an earlier GHC version for certain data types, but it doesn't seem+-- worthwhile, given that we'll have to fall back on hand-written instances at+-- some point anyway.+# if __GLASGOW_HASKELL__ >= 800++deriving instance Generic (Constant a b)+deriving instance Generic1 (Constant a)++deriving instance Generic (ContT r m a)++deriving instance Generic (IdentityT f a)+deriving instance Generic1 (IdentityT f)++deriving instance Generic (MaybeT m a)+deriving instance Functor m => Generic1 (MaybeT m)++deriving instance Generic (Lazy.RWST r w s m a)+deriving instance Generic (Strict.RWST r w s m a)++deriving instance Generic (ReaderT r m a)+deriving instance Generic1 (ReaderT r m)++deriving instance Generic (Lazy.StateT s m a)+deriving instance Generic (Strict.StateT s m a)++deriving instance Generic (Lazy.WriterT w m a)+deriving instance Generic (Strict.WriterT w m a)++# if MIN_VERSION_transformers(0,3,0)+deriving instance Generic (Backwards f a)+deriving instance Generic1 (Backwards f)++deriving instance Generic (Lift f a)+deriving instance Generic1 (Lift f)++deriving instance Generic (Reverse f a)+deriving instance Generic1 (Reverse f)+# endif++# if MIN_VERSION_transformers(0,4,0)+deriving instance Generic (ExceptT e m a)+deriving instance Functor m => Generic1 (ExceptT e m)+# endif++# if MIN_VERSION_transformers(0,5,3)+deriving instance Generic (AccumT w m a)+deriving instance Generic (SelectT w m a)+# endif++# elif __GLASGOW_HASKELL__ >= 702 || defined(GENERIC_DERIVING)++instance Generic (Constant a b) where+ type Rep (Constant a b) = D1 D1'Constant (C1 C1_0'Constant (S1 S1_0_0'Constant (Rec0 a)))+ from (Constant x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Constant x++instance Generic1 (Constant a) where+ type Rep1 (Constant a) = D1 D1'Constant (C1 C1_0'Constant (S1 S1_0_0'Constant (Rec0 a)))+ from1 (Constant x) = M1 (M1 (M1 (K1 x)))+ to1 (M1 (M1 (M1 x))) = Constant (unK1 x)++instance Datatype D1'Constant where+ datatypeName _ = "Constant"+ moduleName _ = "Data.Functor.Constant"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'Constant where+ conName _ = "Constant"+ conIsRecord _ = True++instance Selector S1_0_0'Constant where+ selName _ = "getConstant"++data D1'Constant+data C1_0'Constant+data S1_0_0'Constant++-----++instance Generic (ContT r m a) where+ type Rep (ContT r m a) = D1 D1'ContT (C1 C1_0'ContT (S1 S1_0_0'ContT (Rec0 ((a -> m r) -> m r))))+ from (ContT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = ContT x++instance Datatype D1'ContT where+ datatypeName _ = "ContT"+ moduleName _ = "Control.Monad.Trans.Cont"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'ContT where+ conName _ = "ContT"+ conIsRecord _ = True++instance Selector S1_0_0'ContT where+ selName _ = "runContT"++data D1'ContT+data C1_0'ContT+data S1_0_0'ContT++-----++instance Generic (IdentityT f a) where+ type Rep (IdentityT f a) = D1 D1'IdentityT (C1 C1_0'IdentityT (S1 S1_0_0'IdentityT (Rec0 (f a))))+ from (IdentityT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = IdentityT x++instance Generic1 (IdentityT f) where+ type Rep1 (IdentityT f) = D1 D1'IdentityT (C1 C1_0'IdentityT (S1 S1_0_0'IdentityT (Rec1 f)))+ from1 (IdentityT x) = M1 (M1 (M1 (Rec1 x)))+ to1 (M1 (M1 (M1 x))) = IdentityT (unRec1 x)++instance Datatype D1'IdentityT where+ datatypeName _ = "IdentityT"+ moduleName _ = "Control.Monad.Trans.Identity"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'IdentityT where+ conName _ = "IdentityT"+ conIsRecord _ = True++instance Selector S1_0_0'IdentityT where+ selName _ = "runIdentityT"++data D1'IdentityT+data C1_0'IdentityT+data S1_0_0'IdentityT++-----++instance Generic (MaybeT m a) where+ type Rep (MaybeT m a) = D1 D1'MaybeT (C1 C1_0'MaybeT (S1 S1_0_0'MaybeT (Rec0 (m (Maybe a)))))+ from (MaybeT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = MaybeT x++instance Functor m => Generic1 (MaybeT m) where+ type Rep1 (MaybeT m) = D1 D1'MaybeT (C1 C1_0'MaybeT (S1 S1_0_0'MaybeT (m :.: Rec1 Maybe)))+ from1 (MaybeT x) = M1 (M1 (M1 ((.) Comp1 (fmap Rec1) x)))+ to1 (M1 (M1 (M1 x))) = MaybeT ((.) (fmap unRec1) unComp1 x)++instance Datatype D1'MaybeT where+ datatypeName _ = "MaybeT"+ moduleName _ = "Control.Monad.Trans.Maybe"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'MaybeT where+ conName _ = "MaybeT"+ conIsRecord _ = True++instance Selector S1_0_0'MaybeT where+ selName _ = "runMaybeT"++data D1'MaybeT+data C1_0'MaybeT+data S1_0_0'MaybeT++-----++instance Generic (Lazy.RWST r w s m a) where+ type Rep (Lazy.RWST r w s m a) = D1 D1'RWSTLazy (C1 C1_0'RWST (S1 S1_0_0'RWST (Rec0 (r -> s -> m (a, s, w)))))+ from (Lazy.RWST x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Lazy.RWST x++instance Generic (Strict.RWST r w s m a) where+ type Rep (Strict.RWST r w s m a) = D1 D1'RWSTStrict (C1 C1_0'RWST (S1 S1_0_0'RWST (Rec0 (r -> s -> m (a, s, w)))))+ from (Strict.RWST x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Strict.RWST x++instance Datatype D1'RWSTLazy where+ datatypeName _ = "RWST"+ moduleName _ = "Control.Monad.Trans.RWS.Lazy"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Datatype D1'RWSTStrict where+ datatypeName _ = "RWST"+ moduleName _ = "Control.Monad.Trans.RWS.Strict"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'RWST where+ conName _ = "RWST"+ conIsRecord _ = True++instance Selector S1_0_0'RWST where+ selName _ = "runRWST"++data D1'RWSTLazy+data D1'RWSTStrict+data C1_0'RWST+data S1_0_0'RWST++-----++instance Generic (ReaderT r m a) where+ type Rep (ReaderT r m a) = D1 D1'ReaderT (C1 C1_0'ReaderT (S1 S1_0_0'ReaderT (Rec0 (r -> m a))))+ from (ReaderT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = ReaderT x++instance Datatype D1'ReaderT where+ datatypeName _ = "ReaderT"+ moduleName _ = "Control.Monad.Trans.Reader"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'ReaderT where+ conName _ = "ReaderT"+ conIsRecord _ = True++instance Selector S1_0_0'ReaderT where+ selName _ = "runReaderT"++data D1'ReaderT+data C1_0'ReaderT+data S1_0_0'ReaderT++-----++instance Generic (Lazy.StateT s m a) where+ type Rep (Lazy.StateT s m a) = D1 D1'StateTLazy (C1 C1_0'StateT (S1 S1_0_0'StateT (Rec0 (s -> m (a, s)))))+ from (Lazy.StateT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Lazy.StateT x++instance Generic (Strict.StateT s m a) where+ type Rep (Strict.StateT s m a) = D1 D1'StateTStrict (C1 C1_0'StateT (S1 S1_0_0'StateT (Rec0 (s -> m (a, s)))))+ from (Strict.StateT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Strict.StateT x++instance Datatype D1'StateTLazy where+ datatypeName _ = "StateT"+ moduleName _ = "Control.Monad.Trans.State.Lazy"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Datatype D1'StateTStrict where+ datatypeName _ = "StateT"+ moduleName _ = "Control.Monad.Trans.State.Strict"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'StateT where+ conName _ = "StateT"+ conIsRecord _ = True++instance Selector S1_0_0'StateT where+ selName _ = "runStateT"++data D1'StateTLazy+data D1'StateTStrict+data C1_0'StateT+data S1_0_0'StateT++-----++instance Generic (Lazy.WriterT w m a) where+ type Rep (Lazy.WriterT w m a) = D1 D1'WriterTLazy (C1 C1_0'WriterT (S1 S1_0_0'WriterT (Rec0 (m (a, w)))))+ from (Lazy.WriterT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Lazy.WriterT x++instance Generic (Strict.WriterT w m a) where+ type Rep (Strict.WriterT w m a) = D1 D1'WriterTStrict (C1 C1_0'WriterT (S1 S1_0_0'WriterT (Rec0 (m (a, w)))))+ from (Strict.WriterT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Strict.WriterT x++instance Datatype D1'WriterTLazy where+ datatypeName _ = "WriterT"+ moduleName _ = "Control.Monad.Trans.Writer.Lazy"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Datatype D1'WriterTStrict where+ datatypeName _ = "WriterT"+ moduleName _ = "Control.Monad.Trans.Writer.Strict"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'WriterT where+ conName _ = "WriterT"+ conIsRecord _ = True++instance Selector S1_0_0'WriterT where+ selName _ = "runWriterT"++data D1'WriterTLazy+data D1'WriterTStrict+data C1_0'WriterT+data S1_0_0'WriterT++# if MIN_VERSION_transformers(0,3,0)+instance Generic (Backwards f a) where+ type Rep (Backwards f a) = D1 D1'Backwards (C1 C1_0'Backwards (S1 S1_0_0'Backwards (Rec0 (f a))))+ from (Backwards x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Backwards x++instance Generic1 (Backwards f) where+ type Rep1 (Backwards f) = D1 D1'Backwards (C1 C1_0'Backwards (S1 S1_0_0'Backwards (Rec1 f)))+ from1 (Backwards x) = M1 (M1 (M1 (Rec1 x)))+ to1 (M1 (M1 (M1 x))) = Backwards (unRec1 x)++instance Datatype D1'Backwards where+ datatypeName _ = "Backwards"+ moduleName _ = "Control.Applicative.Backwards"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'Backwards where+ conName _ = "Backwards"+ conIsRecord _ = True++instance Selector S1_0_0'Backwards where+ selName _ = "forwards"++data D1'Backwards+data C1_0'Backwards+data S1_0_0'Backwards++-----++instance Generic (Reverse f a) where+ type Rep (Reverse f a) = D1 D1'Reverse (C1 C1_0'Reverse (S1 S1_0_0'Reverse (Rec0 (f a))))+ from (Reverse x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = Reverse x++instance Generic1 (Reverse f) where+ type Rep1 (Reverse f) = D1 D1'Reverse (C1 C1_0'Reverse (S1 S1_0_0'Reverse (Rec1 f)))+ from1 (Reverse x) = M1 (M1 (M1 (Rec1 x)))+ to1 (M1 (M1 (M1 x))) = Reverse (unRec1 x)++instance Datatype D1'Reverse where+ datatypeName _ = "Reverse"+ moduleName _ = "Data.Functor.Reverse"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'Reverse where+ conName _ = "Reverse"+ conIsRecord _ = True++instance Selector S1_0_0'Reverse where+ selName _ = "getReverse"++data D1'Reverse+data C1_0'Reverse+data S1_0_0'Reverse++-----++instance Generic (Lift f a) where+ type Rep (Lift f a) = D1 D1'Lift (C1 C1_0'Lift (S1 NoSelector (Rec0 a)) :+: C1 C1_1'Lift (S1 NoSelector (Rec0 (f a))))+ from (Pure x) = M1 (L1 (M1 (M1 (K1 x))))+ from (Other x) = M1 (R1 (M1 (M1 (K1 x))))+ to (M1 (L1 (M1 (M1 (K1 x))))) = Pure x+ to (M1 (R1 (M1 (M1 (K1 x))))) = Other x++instance Generic1 (Lift f) where+ type Rep1 (Lift f) = D1 D1'Lift (C1 C1_0'Lift (S1 NoSelector Par1) :+: C1 C1_1'Lift (S1 NoSelector (Rec1 f)))+ from1 (Pure x) = M1 (L1 (M1 (M1 (Par1 x))))+ from1 (Other x) = M1 (R1 (M1 (M1 (Rec1 x))))+ to1 (M1 (L1 (M1 (M1 x)))) = Pure (unPar1 x)+ to1 (M1 (R1 (M1 (M1 x)))) = Other (unRec1 x)++instance Datatype D1'Lift where+ datatypeName _ = "Lift"+ moduleName _ = "Control.Applicative.Lift"++instance Constructor C1_0'Lift where+ conName _ = "Pure"++instance Constructor C1_1'Lift where+ conName _ = "Other"++data D1'Lift+data C1_0'Lift+data C1_1'Lift+# endif++# if MIN_VERSION_transformers(0,4,0)+instance Generic (ExceptT e m a) where+ type Rep (ExceptT e m a) = D1 D1'ExceptT (C1 C1_0'ExceptT (S1 NoSelector (Rec0 (m (Either e a)))))+ from (ExceptT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = ExceptT x++instance Functor m => Generic1 (ExceptT e m) where+ type Rep1 (ExceptT e m) = D1 D1'ExceptT (C1 C1_0'ExceptT (S1 NoSelector (m :.: Rec1 (Either e))))+ from1 (ExceptT x) = M1 (M1 (M1 ((.) Comp1 (fmap Rec1) x)))+ to1 (M1 (M1 (M1 x))) = ExceptT ((.) (fmap unRec1) unComp1 x)++instance Datatype D1'ExceptT where+ datatypeName _ = "ExceptT"+ moduleName _ = "Control.Monad.Trans.Except"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'ExceptT where+ conName _ = "ExceptT"++data D1'ExceptT+data C1_0'ExceptT+# endif++# if MIN_VERSION_transformers(0,5,3)+instance Generic (AccumT w m a) where+ type Rep (AccumT w m a) = D1 D1'AccumT (C1 C1_0'AccumT (S1 NoSelector (Rec0 (w -> m (a, w)))))+ from (AccumT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = AccumT x++instance Datatype D1'AccumT where+ datatypeName _ = "AccumT"+ moduleName _ = "Control.Monad.Trans.Accum"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'AccumT where+ conName _ = "AccumT"++data D1'AccumT+data C1_0'AccumT++-----++instance Generic (SelectT r m a) where+ type Rep (SelectT r m a) = D1 D1'SelectT (C1 C1_0'SelectT (S1 NoSelector (Rec0 ((a -> m r) -> m a))))+ from (SelectT x) = M1 (M1 (M1 (K1 x)))+ to (M1 (M1 (M1 (K1 x)))) = SelectT x++instance Datatype D1'SelectT where+ datatypeName _ = "SelectT"+ moduleName _ = "Control.Monad.Trans.Select"+# if MIN_VERSION_base(4,7,0)+ isNewtype _ = True+# endif++instance Constructor C1_0'SelectT where+ conName _ = "SelectT"++data D1'SelectT+data C1_0'SelectT+# endif++# endif # endif #endif
tests/GenericsSpec.hs view
@@ -16,21 +16,21 @@ main :: IO () main = hspec spec -prop_Eq :: (Eq a, Eq (f a), Eq1 f) => f a -> f a -> Bool-prop_Eq x y = (x == y) == eq1 x y+prop_Eq :: (Eq a, Eq (f a), Eq1 f) => f a -> f a -> Expectation+prop_Eq x y = (x == y) `shouldBe` eq1 x y eqSpec :: forall f a. (Arbitrary (f a), Show (f a), Eq a, Eq (f a), Eq1 f) => Proxy (f a) -> Spec-eqSpec _ = prop "has a valid Eq1 instance" (prop_Eq :: f a -> f a -> Bool)+eqSpec _ = prop "has a valid Eq1 instance" (prop_Eq :: f a -> f a -> Expectation) -prop_Ord :: (Ord a, Ord (f a), Ord1 f) => f a -> f a -> Bool-prop_Ord x y = compare x y == compare1 x y+prop_Ord :: (Ord a, Ord (f a), Ord1 f) => f a -> f a -> Expectation+prop_Ord x y = compare x y `shouldBe` compare1 x y ordSpec :: forall f a. (Arbitrary (f a), Show (f a), Ord a, Ord (f a), Ord1 f) => Proxy (f a) -> Spec-ordSpec _ = prop "has a valid Ord1 instance" (prop_Ord :: f a -> f a -> Bool)+ordSpec _ = prop "has a valid Ord1 instance" (prop_Ord :: f a -> f a -> Expectation) -- Adapted from the definition of readEither readEither' :: String -> (Int -> ReadS a) -> Either String a@@ -45,8 +45,8 @@ prop_Read :: forall f a. (Read a, Read (f a), Read1 f, Eq (f a), Show (f a))- => f a -> Bool-prop_Read x = readArb readsPrec == readArb readsPrec1+ => f a -> Expectation+prop_Read x = readArb readsPrec `shouldBe` readArb readsPrec1 where readArb :: (Int -> ReadS (f a)) -> f a readArb = read' (show x)@@ -54,14 +54,14 @@ readSpec :: forall f a. (Arbitrary (f a), Eq (f a), Show (f a), Read a, Read (f a), Read1 f) => Proxy (f a) -> Spec-readSpec _ = prop "has a valid Read1 instance" (prop_Read :: f a -> Bool)+readSpec _ = prop "has a valid Read1 instance" (prop_Read :: f a -> Expectation) -prop_Show :: (Show a, Show (f a), Show1 f) => Int -> f a -> Bool-prop_Show p x = showsPrec p x "" == showsPrec1 p x ""+prop_Show :: (Show a, Show (f a), Show1 f) => Int -> f a -> Expectation+prop_Show p x = showsPrec p x "" `shouldBe` showsPrec1 p x "" showSpec :: forall f a. (Arbitrary (f a), Show a, Show (f a), Show1 f) => Proxy (f a) -> Spec-showSpec _ = prop "has a valid Show1 instance" (prop_Show :: Int -> f a -> Bool)+showSpec _ = prop "has a valid Show1 instance" (prop_Show :: Int -> f a -> Expectation) classes1Spec :: forall f a. (Arbitrary (f a), Ord a, Ord (f a), Ord1 f,
tests/transformers-compat-tests.cabal view
@@ -23,8 +23,9 @@ , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5- , GHC == 8.8.3- , GHC == 8.10.1+ , GHC == 8.8.4+ , GHC == 8.10.4+ , GHC == 9.0.1 source-repository head type: git@@ -48,7 +49,7 @@ , hspec >= 2 && < 3 , QuickCheck >= 2 && < 3 , tagged >= 0.7 && < 1- , transformers >= 0.2 && < 0.6+ , transformers >= 0.2 && < 0.7 , transformers-compat build-tool-depends: hspec-discover:hspec-discover >= 2 && < 3 hs-source-dirs: .
transformers-compat.cabal view
@@ -1,6 +1,6 @@ name: transformers-compat category: Compatibility-version: 0.6.6+version: 0.7 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -33,10 +33,10 @@ , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5- , GHC == 8.8.3- , GHC == 8.10.1+ , GHC == 8.8.4+ , GHC == 8.10.4+ , GHC == 9.0.1 extra-source-files:- .travis.yml .ghci .gitignore .hlint.yaml@@ -97,7 +97,7 @@ -- These are all transformers versions we support. -- each flag below splits this interval into two parts. -- flag-true parts are mutually exclusive, so at least one have to be on.- transformers >= 0.2 && <0.6+ transformers >= 0.2 && <0.7 if !impl(ghc >= 8.0) build-depends: fail == 4.9.*