From 425c3c087260b00777f71631eea38edd9dad6a92 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Mon, 20 Aug 2018 10:14:27 +0200 Subject: [PATCH] Core: derive 'MonadFail X' instance for GHC 8.6.x and beyond A side effect of that change is that our code no longer compiles with GHC versions prior to 8.0.x. We could work around that, no doubt, but the resulting code would require CPP and Cabal flags and whatnot. It feels more reasonable to just require a moderately recent compiler instead of going through all that trouble. --- .travis.yml | 35 +++++++++++++++++++++++++---------- CHANGES.md | 9 +++++++++ src/XMonad/Core.hs | 3 ++- xmonad.cabal | 12 ++++-------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 782df42..991b364 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ # # runghc make_travis_yml_2.hs '-o' '.travis.yml' 'xmonad.cabal' 'libxrandr-dev' # -# For more information, see https://github.com/hvr/multi-ghc-travis +# For more information, see https://github.com/haskell-CI/haskell-ci # language: c sudo: false @@ -28,6 +28,9 @@ before_cache: matrix: include: + - compiler: "ghc-8.6.1" + env: GHCHEAD=true + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.1,libxrandr-dev], sources: [hvr-ghc]}} - compiler: "ghc-8.4.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3,libxrandr-dev], sources: [hvr-ghc]}} @@ -37,15 +40,9 @@ matrix: - compiler: "ghc-8.0.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2,libxrandr-dev], sources: [hvr-ghc]}} - - compiler: "ghc-7.10.3" - # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.10.3,libxrandr-dev], sources: [hvr-ghc]}} - - compiler: "ghc-7.8.4" - # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.8.4,libxrandr-dev], sources: [hvr-ghc]}} - - compiler: "ghc-7.6.3" - # env: TEST=--disable-tests BENCH=--disable-benchmarks - addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.6.3,libxrandr-dev], sources: [hvr-ghc]}} + + allow_failures: + - compiler: "ghc-8.6.1" before_install: - HC=${CC} @@ -69,6 +66,24 @@ install: - travis_retry cabal update -v - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config" - rm -fv cabal.project cabal.project.local + # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage + - | + if $GHCHEAD; then + sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config + for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done + + echo 'repository head.hackage' >> ${HOME}/.cabal/config + echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config + echo ' secure: True' >> ${HOME}/.cabal/config + echo ' root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config + echo ' 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config + echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config + echo ' key-threshold: 3' >> ${HOME}/.cabal.config + + grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' + + cabal new-update head.hackage -v + fi - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' - "printf 'packages: \".\"\\n' > cabal.project" - touch cabal.project.local diff --git a/CHANGES.md b/CHANGES.md index 05fdaae..cff04c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,15 @@ and to install them into proper locations where their users expect them. [https://github.com/xmonad/xmonad/pull/127] +### Bug Fixes + + * Add support for GHC 8.6.x by providing an instance for 'MonadFail X'. A + side effect of that change is that our code no longer compiles with GHC + versions prior to 8.0.x. We could work around that, no doubt, but the + resulting code would require CPP and Cabal flags and whatnot. It feels more + reasonable to just require a moderately recent compiler instead of going + through all that trouble. + ## 0.14 (July 30, 2018) ### Bug Fixes diff --git a/src/XMonad/Core.hs b/src/XMonad/Core.hs index 3c891ea..5333696 100644 --- a/src/XMonad/Core.hs +++ b/src/XMonad/Core.hs @@ -37,6 +37,7 @@ import Prelude import Control.Exception.Extensible (fromException, try, bracket, throw, finally, SomeException(..)) import qualified Control.Exception.Extensible as E import Control.Applicative(Applicative, pure, (<$>), (<*>)) +import Control.Monad.Fail import Control.Monad.State import Control.Monad.Reader import Data.Semigroup @@ -147,7 +148,7 @@ data ScreenDetail = SD { screenRect :: !Rectangle } deriving (Eq,Show, Read) -- instantiated on 'XConf' and 'XState' automatically. -- newtype X a = X (ReaderT XConf (StateT XState IO) a) - deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader XConf, Typeable) + deriving (Functor, Monad, MonadFail, MonadIO, MonadState XState, MonadReader XConf, Typeable) instance Applicative X where pure = return diff --git a/xmonad.cabal b/xmonad.cabal index 8a16c25..e41d144 100644 --- a/xmonad.cabal +++ b/xmonad.cabal @@ -28,13 +28,7 @@ cabal-version: >= 1.8 bug-reports: https://github.com/xmonad/xmonad/issues build-type: Simple -tested-with: - GHC==7.6.3, - GHC==7.8.4, - GHC==7.10.3, - GHC==8.0.2, - GHC==8.2.2, - GHC==8.4.3 +tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.3, GHC==8.6.1 source-repository head type: git @@ -62,7 +56,7 @@ library XMonad.StackSet other-modules: Paths_xmonad - build-depends: base >= 4.6 && < 4.12, + build-depends: base >= 4.6 && < 5, containers, data-default, directory, @@ -86,6 +80,8 @@ library -- needed for XMonad.Config's instance Default (XConfig a) if flag(testing) buildable: False + if !impl(ghc > 8) + build-depends: fail executable xmonad main-is: Main.hs