diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml index da80cbc..2d81f09 100644 --- a/.stylish-haskell.yaml +++ b/.stylish-haskell.yaml @@ -1,16 +1,24 @@ steps: + - simple_align: + cases: false + top_level_patterns: false + records: false - imports: align: group list_align: new_line long_list_align: new_line empty_list_align: right_after list_padding: module_name + separate_lists: true + - language_pragmas: style: vertical + align: true remove_redundant: true - trailing_whitespace: {} columns: 80 +newline: lf language_extensions: - - MultiParamTypeClasses - FlexibleContexts - - ExplicitForAll + - TemplateHaskell + - QuasiQuotes diff --git a/.travis.yml b/.travis.yml index 87d068e..611e7ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.3.20190815 +# version: 0.5.20190916 # language: c dist: xenial @@ -32,28 +32,63 @@ matrix: - compiler: ghc-8.8.1 addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}} - compiler: ghc-8.6.5 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-3.0"]}} + - compiler: ghc-8.6.4 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.4","cabal-install-3.0"]}} + - compiler: ghc-8.6.3 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.3","cabal-install-3.0"]}} + - compiler: ghc-8.6.2 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.2","cabal-install-3.0"]}} + - compiler: ghc-8.6.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.1","cabal-install-3.0"]}} - compiler: ghc-8.4.4 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-3.0"]}} + - compiler: ghc-8.4.3 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.3","cabal-install-3.0"]}} + - compiler: ghc-8.4.2 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.2","cabal-install-3.0"]}} + - compiler: ghc-8.4.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.1","cabal-install-3.0"]}} - compiler: ghc-8.2.2 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-3.0"]}} + - compiler: ghc-8.2.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.1","cabal-install-3.0"]}} - compiler: ghc-8.0.2 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-3.0"]}} + - compiler: ghc-8.0.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.1","cabal-install-3.0"]}} - compiler: ghc-7.10.3 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-3.0"]}} + - compiler: ghc-7.10.2 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.2","cabal-install-3.0"]}} + - compiler: ghc-7.10.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.1","cabal-install-3.0"]}} - compiler: ghc-7.8.4 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-3.0"]}} + - compiler: ghc-7.8.3 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.3","cabal-install-3.0"]}} + - compiler: ghc-7.8.2 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.2","cabal-install-3.0"]}} + - compiler: ghc-7.8.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.1","cabal-install-3.0"]}} - compiler: ghc-7.6.3 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-3.0"]}} + - compiler: ghc-7.6.2 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.2","cabal-install-3.0"]}} + - compiler: ghc-7.6.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.1","cabal-install-3.0"]}} - compiler: ghc-7.4.2 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-3.0"]}} + - compiler: ghc-7.4.1 + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.1","cabal-install-3.0"]}} - compiler: ghc-7.2.2 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.2.2","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.2.2","cabal-install-3.0"]}} - compiler: ghc-7.0.4 - addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.4","cabal-install-2.4"]}} + addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.0.4","cabal-install-3.0"]}} 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 @@ -105,6 +140,9 @@ install: echo " prefix: $CABALHOME" >> $CABALHOME/config echo "repository hackage.haskell.org" >> $CABALHOME/config echo " url: http://hackage.haskell.org/" >> $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 @@ -163,7 +201,7 @@ script: - if [ $HCNUMVER -ge 71000 ] ; then (cd ${PKGDIR_simple_example} && ${CABAL} -vnormal check) ; fi - if [ $HCNUMVER -ge 71000 ] ; then (cd ${PKGDIR_multiple_components_example} && ${CABAL} -vnormal check) ; fi # haddock... - - ${CABAL} v2-haddock $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output + - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output # Building without installed constraints for packages in global-db... - rm -f cabal.project.local - ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output diff --git a/ChangeLog.md b/ChangeLog.md index df35156..d165583 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,9 @@ -# 1.0.7 -- 2019-??-?? +# 1.0.8 -- 2019-10-02 + +* Pass `-package-env=-` when compiler supports it +* Amend examples to `unsetEnv "GHC_ENVIRONMENT"` + +# 1.0.7 -- 2019-08-26 * Make `Distribution.Extra.Doctest` `-Wall`-clean * Support GHC-8.8, base-4.13, and Cabal-3.0 diff --git a/cabal-doctest.cabal b/cabal-doctest.cabal index 45c723b..3fa9ff7 100644 --- a/cabal-doctest.cabal +++ b/cabal-doctest.cabal @@ -1,53 +1,46 @@ -name: cabal-doctest -version: 1.0.7 -synopsis: A Setup.hs helper for doctests running +name: cabal-doctest +version: 1.0.8 +synopsis: A Setup.hs helper for doctests running description: Currently (beginning of 2017), there isn't @cabal doctest@ command. Yet, to properly work doctest needs plenty of configuration. This library provides the common bits for writing custom Setup.hs - See for the progress of @cabal doctest@, i.e. whether this library is obsolete. -homepage: https://github.com/phadej/cabal-doctest -license: BSD3 -license-file: LICENSE -author: Oleg Grenrus -maintainer: Oleg Grenrus -copyright: (c) 2017 Oleg Grenrus -category: Distribution -build-type: Simple -cabal-version: >=1.10 -extra-source-files: ChangeLog.md README.md -tested-with: - GHC==7.0.4, - GHC==7.2.2, - GHC==7.4.2, - GHC==7.6.3, - GHC==7.8.4, - GHC==7.10.3, - GHC==8.0.2, - GHC==8.2.2, - GHC==8.4.4, - GHC==8.6.5, - GHC==8.8.1 +homepage: https://github.com/phadej/cabal-doctest +license: BSD3 +license-file: LICENSE +author: Oleg Grenrus +maintainer: Oleg Grenrus +copyright: (c) 2017 Oleg Grenrus +category: Distribution +build-type: Simple +cabal-version: >=1.10 +extra-source-files: + ChangeLog.md + README.md + +tested-with: GHC ==8.8.1 || >=7.4 && <8.8 || ==7.2.2 || ==7.0.4 source-repository head type: git location: https://github.com/phadej/cabal-doctest library - exposed-modules: Distribution.Extra.Doctest + exposed-modules: Distribution.Extra.Doctest other-modules: other-extensions: build-depends: - base >=4.3 && <4.14, - Cabal >= 1.10 && <3.1, - filepath, - directory - hs-source-dirs: src - default-language: Haskell2010 - ghc-options: -Wall - if !impl(ghc >= 7.2) + base >=4.3 && <4.14 + , Cabal >=1.10 && <3.1 + , directory + , filepath + + hs-source-dirs: src + default-language: Haskell2010 + ghc-options: -Wall + + if !impl(ghc >=7.2) -- Work around a pattern-match coverage checking bug in GHC 7.0 - ghc-options: -fno-warn-overlapping-patterns + ghc-options: -fno-warn-overlapping-patterns diff --git a/multiple-components-example/multiple-components-example.cabal b/multiple-components-example/multiple-components-example.cabal index 4328fab..4421be2 100644 --- a/multiple-components-example/multiple-components-example.cabal +++ b/multiple-components-example/multiple-components-example.cabal @@ -15,7 +15,7 @@ maintainer: Oleg Grenrus copyright: (c) 2017 Oleg Grenrus category: Example build-type: Custom -tested-with: GHC ==8.8.1 || ==8.6.5 || ==8.4.4 || ==8.2.2 || ==8.0.2 || ==7.10.3 +tested-with: GHC >=7.10 && <8.8 || ==8.8.1 custom-setup setup-depends: diff --git a/simple-example/simple-example.cabal b/simple-example/simple-example.cabal index d33af84..43195b6 100644 --- a/simple-example/simple-example.cabal +++ b/simple-example/simple-example.cabal @@ -14,7 +14,7 @@ copyright: (c) 2017 Oleg Grenrus category: Example build-type: Custom cabal-version: 1.12 -tested-with: GHC ==8.8.1 || ==8.6.5 || ==8.4.4 || ==8.2.2 || ==8.0.2 || ==7.10.3 +tested-with: GHC >=7.10 && <8.8 || ==8.8.1 custom-setup setup-depends: diff --git a/src/Distribution/Extra/Doctest.hs b/src/Distribution/Extra/Doctest.hs index a6d1645..e434c16 100644 --- a/src/Distribution/Extra/Doctest.hs +++ b/src/Distribution/Extra/Doctest.hs @@ -46,47 +46,51 @@ module Distribution.Extra.Doctest ( import Control.Monad (when) +import Data.IORef + (modifyIORef, newIORef, readIORef) import Data.List (nub) import Data.Maybe - (maybeToList, mapMaybe) + (mapMaybe, maybeToList) import Data.String (fromString) -import qualified Data.Foldable as F - (for_) -import qualified Data.Traversable as T - (traverse) -import Distribution.Package - (InstalledPackageId) import Distribution.Package - (Package (..), PackageId, packageVersion) + (InstalledPackageId, Package (..)) import Distribution.PackageDescription - (BuildInfo (..), Executable (..), Library (..), GenericPackageDescription, - PackageDescription (), TestSuite (..)) + (BuildInfo (..), Executable (..), GenericPackageDescription, + Library (..), PackageDescription, TestSuite (..)) import Distribution.Simple - (UserHooks (..), autoconfUserHooks, defaultMainWithHooks, simpleUserHooks) + (UserHooks (..), autoconfUserHooks, defaultMainWithHooks, + simpleUserHooks) import Distribution.Simple.Compiler - (PackageDB (..), showCompilerId) + (CompilerFlavor (GHC), CompilerId (..), PackageDB (..), compilerId) import Distribution.Simple.LocalBuildInfo - (ComponentLocalBuildInfo (componentPackageDeps), LocalBuildInfo (), + (ComponentLocalBuildInfo (componentPackageDeps), LocalBuildInfo, compiler, withExeLBI, withLibLBI, withPackageDB, withTestLBI) import Distribution.Simple.Setup - (BuildFlags (buildDistPref, buildVerbosity), HaddockFlags (haddockDistPref, haddockVerbosity), fromFlag, emptyBuildFlags) + (BuildFlags (buildDistPref, buildVerbosity), + HaddockFlags (haddockDistPref, haddockVerbosity), emptyBuildFlags, + fromFlag) import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, info) import Distribution.Text - (display, simpleParse) + (display) import System.FilePath (()) -import Data.IORef (newIORef, modifyIORef, readIORef) +import qualified Data.Foldable as F + (for_) +import qualified Data.Traversable as T + (traverse) -import Distribution.Simple.BuildPaths #if MIN_VERSION_Cabal(1,25,0) +import Distribution.Simple.BuildPaths (autogenComponentModulesDir) #else +import Distribution.Simple.BuildPaths (autogenModulesDir) #endif + #if MIN_VERSION_Cabal(2,0,0) import Distribution.Types.MungedPackageId (MungedPackageId) @@ -94,20 +98,31 @@ import Distribution.Types.UnqualComponentName (unUnqualComponentName) -- For amendGPD -import Distribution.Types.GenericPackageDescription - (GenericPackageDescription (condTestSuites)) import Distribution.PackageDescription (CondTree (..)) +import Distribution.Types.GenericPackageDescription + (GenericPackageDescription (condTestSuites)) + +import Distribution.Version + (mkVersion) +#else +import Data.Version + (Version (..)) +import Distribution.Package + (PackageId) #endif #if MIN_VERSION_Cabal(3,0,0) -import Distribution.Simple.Utils (findFileEx) +import Distribution.Simple.Utils + (findFileEx) #else -import Distribution.Simple.Utils (findFile) +import Distribution.Simple.Utils + (findFile) #endif #if MIN_VERSION_Cabal(3,0,0) -import Distribution.Types.LibraryName (libraryNameString) +import Distribution.Types.LibraryName + (libraryNameString) #endif #if MIN_VERSION_directory(1,2,2) @@ -131,6 +146,15 @@ findFileEx :: verbosity -> [FilePath] -> FilePath -> IO FilePath findFileEx _ = findFile #endif +#if !MIN_VERSION_Cabal(2,0,0) +mkVersion :: [Int] -> Version +mkVersion ds = Version ds [] +#endif + +------------------------------------------------------------------------------- +-- Mains +------------------------------------------------------------------------------- + -- | A default main with doctests: -- -- @ @@ -392,15 +416,14 @@ generateBuildModule testSuiteName flags pkg lbi = do parseComponentName _ = Nothing -- we do this check in Setup, as then doctests don't need to depend on Cabal - isOldCompiler = maybe False id $ do - a <- simpleParse $ showCompilerId $ compiler lbi - b <- simpleParse "7.5" - return $ packageVersion (a :: PackageId) < b + isNewCompiler = case compilerId $ compiler lbi of + CompilerId GHC v -> v >= mkVersion [7,6] + _ -> False - ghcCanBeToldToIgnorePkgEnvs = maybe False id $ do - a <- simpleParse "8.2" - b <- simpleParse $ showCompilerId $ compiler lbi - return $ packageVersion (a :: PackageId) < b + ghcCanBeToldToIgnorePkgEnvs :: Bool + ghcCanBeToldToIgnorePkgEnvs = case compilerId $ compiler lbi of + CompilerId GHC v -> v >= mkVersion [8,4,4] + _ -> False formatDeps = map formatOne formatOne (installedPkgId, pkgId) @@ -417,8 +440,8 @@ generateBuildModule testSuiteName flags pkg lbi = do -- From Distribution.Simple.Program.GHC packageDbArgs :: [PackageDB] -> [String] - packageDbArgs | isOldCompiler = packageDbArgsConf - | otherwise = packageDbArgsDb + packageDbArgs | isNewCompiler = packageDbArgsDb + | otherwise = packageDbArgsConf -- GHC <7.6 uses '-package-conf' instead of '-package-db'. packageDbArgsConf :: [PackageDB] -> [String] @@ -485,7 +508,7 @@ amendGPD -> GenericPackageDescription -> GenericPackageDescription #if !(MIN_VERSION_Cabal(2,0,0)) -amendGPD _ = id +amendGPD _ gpd = gpd #else amendGPD testSuiteName gpd = gpd { condTestSuites = map f (condTestSuites gpd)