From ef1cc06cabc81ff8438dab36326ff1807464d5ec Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 27 Mar 2014 12:29:34 -0700 Subject: [PATCH] avoid pretty-show with GHC < 7.4; update tested-with (fixes #155) hledger builds with GHC 7.2 through 7.8. 7.0 is not supported because we require shakespeare which requires the DeriveGeneric extension. --- hledger-lib/Hledger/Utils.hs | 11 ++++++++++- hledger-lib/hledger-lib.cabal | 12 +++++++----- hledger/hledger.cabal | 15 ++++++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index 9d530f474..96b18e818 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -24,7 +24,9 @@ module Hledger.Utils (---- provide these frequently used modules - or not, for c -- module Data.PPrint, -- module Hledger.Utils.UTF8IOCompat SystemString,fromSystemString,toSystemString,error',userError', +#if __GLASGOW_HASKELL__ >= 704 ppShow +#endif -- the rest need to be done in each module I think ) where @@ -52,13 +54,20 @@ import Text.ParserCombinators.Parsec import Text.Printf import Text.Regex.TDFA import Text.RegexPR -import Text.Show.Pretty -- import qualified Data.Map as Map -- -- import Prelude hiding (readFile,writeFile,appendFile,getContents,putStr,putStrLn) -- import Hledger.Utils.UTF8IOCompat (readFile,writeFile,appendFile,getContents,putStr,putStrLn) import Hledger.Utils.UTF8IOCompat (SystemString,fromSystemString,toSystemString,error',userError') +#if __GLASGOW_HASKELL__ >= 704 +import Text.Show.Pretty (ppShow) +#else +-- the required pretty-show version requires GHC >= 7.4 +ppShow :: Show a => a -> String +ppShow = show +#endif + -- strings lowercase = map toLower diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 202ddd24a..9cc5c2c27 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -17,7 +17,7 @@ author: Simon Michael maintainer: Simon Michael homepage: http://hledger.org bug-reports: http://hledger.org/bugs -tested-with: GHC==7.4.2, GHC==7.6.3 +tested-with: GHC==7.2.2, GHC==7.4.2, GHC==7.6.3, GHC==7.8 cabal-version: >= 1.10 build-type: Simple -- data-dir: data @@ -31,6 +31,7 @@ extra-source-files: tests/suite.hs library -- should set patchlevel here as in Makefile cpp-options: -DPATCHLEVEL=0 + default-language: Haskell2010 exposed-modules: Hledger Hledger.Data @@ -75,7 +76,6 @@ library ,old-locale ,old-time ,parsec - ,pretty-show >= 1.6.4 ,regex-tdfa ,regexpr >= 0.5.1 ,safe >= 0.2 @@ -84,7 +84,8 @@ library ,transformers >= 0.2 && < 0.4 ,utf8-string >= 0.3.5 && < 0.4 ,HUnit - default-language: Haskell2010 + if impl(ghc >= 7.4) + build-depends: pretty-show >= 1.6.4 source-repository head type: git @@ -94,6 +95,7 @@ test-suite tests type: exitcode-stdio-1.0 main-is: tests/suite.hs ghc-options: -Wall + default-language: Haskell2010 build-depends: hledger-lib , base >= 4.3 && < 5 , cmdargs @@ -107,7 +109,6 @@ test-suite tests , old-locale , old-time , parsec - , pretty-show >= 1.6.4 , regex-tdfa , regexpr , safe @@ -116,7 +117,8 @@ test-suite tests , test-framework-hunit , time , transformers - default-language: Haskell2010 + if impl(ghc >= 7.4) + build-depends: pretty-show >= 1.6.4 -- cf http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 99f40ba4e..c2f288d9f 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -18,7 +18,7 @@ author: Simon Michael maintainer: Simon Michael homepage: http://hledger.org bug-reports: http://hledger.org/bugs -tested-with: GHC==7.4.2, GHC==7.6.3 +tested-with: GHC==7.2.2, GHC==7.4.2, GHC==7.6.3, GHC==7.8 cabal-version: >= 1.10 build-type: Simple -- data-dir: data @@ -43,6 +43,7 @@ flag threaded library cpp-options: -DVERSION="0.22.98" ghc-options: -W + default-language: Haskell2010 -- should be the same as below exposed-modules: Hledger.Cli @@ -86,7 +87,8 @@ library ,time ,utf8-string >= 0.3.5 && < 0.4 ,wizards == 1.0.* - default-language: Haskell2010 + if impl(ghc >= 7.4) + build-depends: pretty-show >= 1.6.4 -- should depend on the above to avoid double compilation but this is -- still too complicated as of 2011/6/1 because: @@ -119,6 +121,7 @@ executable hledger if flag(threaded) ghc-options: -threaded -- should be the same as above + default-language: Haskell2010 build-depends: hledger-lib == 0.22.98 ,base >= 4.3 && < 5 @@ -143,12 +146,14 @@ executable hledger ,time ,utf8-string >= 0.3.5 && < 0.4 ,wizards == 1.0.* - default-language: Haskell2010 + if impl(ghc >= 7.4) + build-depends: pretty-show >= 1.6.4 test-suite tests type: exitcode-stdio-1.0 main-is: tests/suite.hs ghc-options: -Wall + default-language: Haskell2010 build-depends: hledger-lib , hledger , base >= 4.3 && < 5 @@ -164,7 +169,6 @@ test-suite tests , old-locale , old-time , parsec - , pretty-show >= 1.6.4 , process , regexpr , safe @@ -177,4 +181,5 @@ test-suite tests , time , transformers , wizards == 1.0.* - default-language: Haskell2010 + if impl(ghc >= 7.4) + build-depends: pretty-show >= 1.6.4