free 5.1.2 → 5.1.3
raw patch · 8 files changed
+196/−79 lines, 8 filesdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
+ Control.Comonad.Trans.Cofree: instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => Data.Functor.Classes.Eq1 (Control.Comonad.Trans.Cofree.CofreeF f a)
+ Control.Comonad.Trans.Cofree: instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => Data.Functor.Classes.Ord1 (Control.Comonad.Trans.Cofree.CofreeF f a)
+ Control.Comonad.Trans.Cofree: instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => Data.Functor.Classes.Read1 (Control.Comonad.Trans.Cofree.CofreeF f a)
+ Control.Comonad.Trans.Cofree: instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => Data.Functor.Classes.Show1 (Control.Comonad.Trans.Cofree.CofreeF f a)
+ Control.Comonad.Trans.Cofree: instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq2 (Control.Comonad.Trans.Cofree.CofreeF f)
+ Control.Comonad.Trans.Cofree: instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord2 (Control.Comonad.Trans.Cofree.CofreeF f)
+ Control.Comonad.Trans.Cofree: instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read2 (Control.Comonad.Trans.Cofree.CofreeF f)
+ Control.Comonad.Trans.Cofree: instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show2 (Control.Comonad.Trans.Cofree.CofreeF f)
Files
- .hlint.yaml +15/−0
- .travis.yml +87/−60
- CHANGELOG.markdown +6/−0
- HLint.hs +0/−15
- examples/free-examples.cabal +1/−0
- free.cabal +3/−2
- src/Control/Comonad/Trans/Cofree.hs +70/−0
- src/Control/Monad/Free/TH.hs +14/−2
+ .hlint.yaml view
@@ -0,0 +1,15 @@+- arguments: [--cpp-define=HLINT, --cpp-ansi, --cpp-include=include]++- fixity: "infixr 5 :<"++# This affects performance+- ignore: {name: Redundant lambda}++# This is not valid for improve+- ignore: {name: Eta reduce}++# DeriveDataTypable noise+- ignore: {name: Unused LANGUAGE pragma}++# They are clearer in places+- ignore: {name: Avoid lambda}
.travis.yml view
@@ -4,9 +4,11 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci #-# version: 0.3.20190425+# version: 0.9.20191126 #+version: ~> 1.0 language: c+os: linux dist: xenial git: # whether to recursively clone submodules@@ -22,6 +24,7 @@ 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,42 +34,55 @@ - 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.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.0"]}}+ os: linux - compiler: ghc-8.8.1- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}- env: GHCHEAD=true+ 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.1","cabal-install-3.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ 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.0"]}}+ os: linux - compiler: ghc-head- addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}- env: GHCHEAD=true+ 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-head","cabal-install-head"]}}+ os: linux allow_failures: - compiler: ghc-head- - compiler: ghc-8.8.1+ - compiler: ghc-8.10.1 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" - set -o pipefail@@ -93,35 +109,47 @@ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" - TEST=--enable-tests - BENCH=--enable-benchmarks- - GHCHEAD=${GHCHEAD-false}+ - HEADHACKAGE=false+ - if [ $HCNUMVER -ge 81000 ] ; then HEADHACKAGE=true ; fi - rm -f $CABALHOME/config - |- echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config- echo "remote-build-reporting: anonymous" >> $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+ 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+ echo " secure: True" >> $CABALHOME/config+ echo " key-threshold: 3" >> $CABALHOME/config+ echo " root-keys:" >> $CABALHOME/config+ echo " fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0" >> $CABALHOME/config+ echo " 1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42" >> $CABALHOME/config+ echo " 2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3" >> $CABALHOME/config+ echo " 0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d" >> $CABALHOME/config+ echo " 51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921" >> $CABALHOME/config - |- if $GHCHEAD; then+ if $HEADHACKAGE; 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 "repository head.hackage.ghc.haskell.org" >> $CABALHOME/config+ echo " url: https://ghc.gitlab.haskell.org/head.hackage/" >> $CABALHOME/config echo " secure: True" >> $CABALHOME/config- echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config- echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config- echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config+ echo " root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config+ echo " 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config+ echo " f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config echo " key-threshold: 3" >> $CABALHOME/config fi+ - |+ 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@@ -129,22 +157,20 @@ - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "."' >> cabal.project- echo 'packages: "./examples"' >> cabal.project+ echo "packages: ." >> cabal.project+ echo "packages: ./examples" >> cabal.project - |- echo "package free-examples" >> cabal.project- echo " flags: -mandelbrot-iter" >> cabal.project- echo "" >> cabal.project- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(free|free-examples)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ echo "package free-examples" >> cabal.project+ echo " flags: -mandelbrot-iter" >> cabal.project+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(free|free-examples)$' || 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 "./examples/configure.ac" ]; then (cd "./examples" && autoreconf -i); fi- - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'" - rm cabal.project.freeze- - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all | color_cabal_output+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output script: - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) # Packaging...@@ -152,29 +178,30 @@ # 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_free="$(find . -maxdepth 1 -type d -regex '.*/free-[0-9.]*')"+ - PKGDIR_free_examples="$(find . -maxdepth 1 -type d -regex '.*/free-examples-[0-9.]*')" # Generate cabal.project - rm -rf cabal.project cabal.project.local cabal.project.freeze - touch cabal.project - |- echo 'packages: "free-*/*.cabal"' >> cabal.project- echo 'packages: "free-examples-*/*.cabal"' >> cabal.project+ echo "packages: ${PKGDIR_free}" >> cabal.project+ echo "packages: ${PKGDIR_free_examples}" >> cabal.project - |- echo "package free-examples" >> cabal.project- echo " flags: -mandelbrot-iter" >> cabal.project- echo "" >> cabal.project- echo "write-ghc-environment-files: always" >> cabal.project- - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(free|free-examples)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+ echo "package free-examples" >> cabal.project+ echo " flags: -mandelbrot-iter" >> cabal.project+ - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(free|free-examples)$' || 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 | color_cabal_output # cabal check...- - (cd free-* && ${CABAL} -vnormal check)- - (cd free-examples-* && ${CABAL} -vnormal check)+ - (cd ${PKGDIR_free} && ${CABAL} -vnormal check)+ - (cd ${PKGDIR_free_examples} && ${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 | color_cabal_output -# REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]+# REGENDATA ("0.9.20191126",["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]) # EOF
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+5.1.3 [2019.11.26]+------------------+* Allow building with `template-haskell-2.16` (GHC 8.10).+* Add `Eq{1,2}`, `Ord{1,2}`, `Read{1,2}`, and `Show{1,2}` instances for+ `CofreeF`.+ 5.1.2 [2019.08.27] ------------------ * Implement more performant versions of `some` and `many` in the `Alternative`
− HLint.hs
@@ -1,15 +0,0 @@-import "hint" HLint.HLint--infixr 5 :<---- This affects performance-ignore "Redundant lambda"---- This is not valid for improve-ignore "Eta reduce"---- DeriveDataTypable noise-ignore "Unused LANGUAGE pragma"---- They are clearer in places-ignore "Avoid lambda"
examples/free-examples.cabal view
@@ -19,6 +19,7 @@ , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.1+ , GHC == 8.10.1 synopsis: Monads for free description: Examples projects using @free@ build-type: Simple
free.cabal view
@@ -1,6 +1,6 @@ name: free category: Control, Monads-version: 5.1.2+version: 5.1.3 license: BSD3 cabal-version: 1.18 license-file: LICENSE@@ -19,6 +19,7 @@ , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.1+ , GHC == 8.10.1 synopsis: Monads for free description: Free monads are useful for many tree-like structures and domain specific languages.@@ -44,11 +45,11 @@ extra-source-files: .ghci .gitignore+ .hlint.yaml .travis.yml .vim.custom README.markdown CHANGELOG.markdown- HLint.hs doc/proof/Control/Comonad/Cofree/*.md doc/proof/Control/Comonad/Trans/Cofree/*.md examples/free-examples.cabal
src/Control/Comonad/Trans/Cofree.hs view
@@ -7,6 +7,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} #endif+#include "free-common.h" ----------------------------------------------------------------------------- -- |@@ -42,6 +43,7 @@ import Data.Bifoldable import Data.Bitraversable import Data.Foldable+import Data.Functor.Classes import Data.Functor.Identity import Data.Traversable import Control.Monad (liftM)@@ -66,6 +68,74 @@ ,Typeable, Generic, Generic1 #endif )++#ifdef LIFTED_FUNCTOR_CLASSES+instance Show1 f => Show2 (CofreeF f) where+ liftShowsPrec2 spa _sla spb slb d (a :< fb) =+ showParen (d > 5) $+ spa 6 a . showString " :< " . liftShowsPrec spb slb 6 fb++instance (Show1 f, Show a) => Show1 (CofreeF f a) where+ liftShowsPrec = liftShowsPrec2 showsPrec showList++#else+instance (Functor f, Show1 f, Show a) => Show1 (CofreeF f a) where+ showsPrec1 d (a :< fb) = showParen (d > 5) $+ showsPrec 6 a . showString " :< " . showsPrec1 6 fb+#endif++#ifdef LIFTED_FUNCTOR_CLASSES+instance Read1 f => Read2 (CofreeF f) where+ liftReadsPrec2 rpa _rla rpb rlb d =+ readParen (d > 5) $+ (\r' -> [ (u :< v, w)+ | (u, s) <- rpa 6 r'+ , (":<", t) <- lex s+ , (v, w) <- liftReadsPrec rpb rlb 6 t+ ])++instance (Read1 f, Read a) => Read1 (CofreeF f a) where+ liftReadsPrec = liftReadsPrec2 readsPrec readList+#else+instance (Read1 f, Read a) => Read1 (CofreeF f a) where+ readsPrec1 d =+ readParen (d > 5) $+ (\r' -> [ (u :< v,w)+ | (u, s) <- readsPrec 6 r'+ , (":<", t) <- lex s+ , (v, w) <- readsPrec1 6 t+ ])+#endif++#ifdef LIFTED_FUNCTOR_CLASSES+instance Eq1 f => Eq2 (CofreeF f) where+ liftEq2 eqa eqfb (a :< fb) (a' :< fb') = eqa a a' && liftEq eqfb fb fb'++instance (Eq1 f, Eq a) => Eq1 (CofreeF f a) where+ liftEq = liftEq2 (==)+#else+instance (Eq1 f, Eq a) => Eq1 (CofreeF f a) where+ eq1 (a :< fb) (a' :< fb') = a == a' && eq1 fb fb'+#endif++#ifdef LIFTED_FUNCTOR_CLASSES+instance Ord1 f => Ord2 (CofreeF f) where+ liftCompare2 cmpa cmpfb (a :< fb) (a' :< fb') =+ case cmpa a a' of+ LT -> LT+ EQ -> liftCompare cmpfb fb fb'+ GT -> GT++instance (Ord1 f, Ord a) => Ord1 (CofreeF f a) where+ liftCompare = liftCompare2 compare+#else+instance (Ord1 f, Ord a) => Ord1 (CofreeF f a) where+ compare1 (a :< fb) (a' :< fb') =+ case compare a a' of+ LT -> LT+ EQ -> compare1 fb fb'+ GT -> GT+#endif -- | Extract the head of the base functor headF :: CofreeF f a b -> a
src/Control/Monad/Free/TH.hs view
@@ -110,9 +110,9 @@ [ "expected final return type `" ++ pprint n ++ "'" , "but got `" ++ pprint name ++ "'" , "in a constructor's argument type: `" ++ pprint t ++ "'" ]- let tup = foldl AppT (TupleT $ length ts) ts+ let tup = nonUnaryTupleT ts xs <- mapM (const $ newName "x") ts- return $ Captured tup (LamE (map VarP xs) (TupE (map VarE xs)))+ return $ Captured tup (LamE (map VarP xs) (nonUnaryTupE $ map VarE xs)) _ -> fail $ unlines [ "expected a type variable `" ++ pprint n ++ "'" , "or a type like (a1 -> ... -> aN -> " ++ pprint n ++ ")"@@ -128,6 +128,18 @@ [ "expected final return type `" ++ pprint n ++ "'" , "but got `" ++ pprint rt ++ "'" , "in a constructor's argument type: `" ++ pprint t ++ "'" ]++ nonUnaryTupleT :: [Type] -> Type+ nonUnaryTupleT [t'] = t'+ nonUnaryTupleT ts = foldl AppT (TupleT $ length ts) ts++ nonUnaryTupE :: [Exp] -> Exp+ nonUnaryTupE [e] = e+ nonUnaryTupE es = TupE $+#if MIN_VERSION_template_haskell(2,16,0)+ map Just+#endif+ es mkArg n _ = fail $ unlines [ "expected a type variable"