From e60eb71467fa3f693a94292532e439882da767a6 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 27 Mar 2015 15:42:32 -0700 Subject: [PATCH] adapt to GHC-7.10's time-1.5 (#239) --- hledger-lib/Hledger/Data/Dates.hs | 7 ++++++- hledger-lib/Hledger/Data/TimeLog.hs | 3 +++ hledger-lib/Hledger/Read/CsvReader.hs | 7 ++++++- hledger-lib/hledger-lib.cabal | 19 ++++++++++++----- hledger-web/hledger-web.cabal | 17 +++++++++++---- hledger/hledger.cabal | 30 ++++++++++++++++++++------- 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/hledger-lib/Hledger/Data/Dates.hs b/hledger-lib/Hledger/Data/Dates.hs index d905a4a06..a78adc2a2 100644 --- a/hledger-lib/Hledger/Data/Dates.hs +++ b/hledger-lib/Hledger/Data/Dates.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE NoMonoLocalBinds #-} {-# LANGUAGE FlexibleContexts #-} {-| @@ -67,14 +68,18 @@ import Control.Applicative ((<*)) import Control.Monad import Data.List import Data.Maybe +#if MIN_VERSION_time(1,5,0) +import Data.Time.Format hiding (months) +#else import Data.Time.Format +import System.Locale (defaultTimeLocale) +#endif import Data.Time.Calendar import Data.Time.Calendar.OrdinalDate import Data.Time.Calendar.WeekDate import Data.Time.Clock import Data.Time.LocalTime import Safe (headMay, lastMay, readMay) -import System.Locale (defaultTimeLocale) import Test.HUnit import Text.Parsec import Text.Printf diff --git a/hledger-lib/Hledger/Data/TimeLog.hs b/hledger-lib/Hledger/Data/TimeLog.hs index 0d8b4fa0a..74705f364 100644 --- a/hledger-lib/Hledger/Data/TimeLog.hs +++ b/hledger-lib/Hledger/Data/TimeLog.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-| A 'TimeLogEntry' is a clock-in, clock-out, or other directive in a timelog @@ -13,7 +14,9 @@ import Data.Time.Calendar import Data.Time.Clock import Data.Time.Format import Data.Time.LocalTime +#if !MIN_VERSION_time(1,5,0) import System.Locale (defaultTimeLocale) +#endif import Test.HUnit import Text.Printf diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index dd55f4f9f..8ec72eb80 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-| A reader for CSV data, using an extra rules file to help interpret the data. @@ -30,11 +31,15 @@ import Data.Maybe import Data.Ord import Data.Time.Calendar (Day) import Data.Time.Format (parseTime) +#if MIN_VERSION_time(1,5,0) +import Data.Time.Format (defaultTimeLocale) +#else +import System.Locale (defaultTimeLocale) +#endif import Safe import System.Directory (doesFileExist) import System.FilePath import System.IO (stderr) -import System.Locale (defaultTimeLocale) import Test.HUnit import Text.CSV (parseCSV, CSV) import Text.Parsec hiding (parse) diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index bbc7f1cdc..f28f3952f 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -39,6 +39,12 @@ flag double Default: False +flag old-locale + description: A compatibility flag, set automatically by cabal. + If false then depend on time >= 1.5, + if true then depend on time < 1.5 together with old-locale. + default: False + library -- should set patchlevel here as in Makefile cpp-options: -DPATCHLEVEL=0 @@ -93,20 +99,21 @@ library ,directory ,filepath ,mtl - ,old-locale ,old-time ,parsec >= 3 ,regex-tdfa ,regexpr >= 0.5.1 ,safe >= 0.2 ,split >= 0.1 && < 0.3 - ,time ,transformers >= 0.2 && < 0.5 ,utf8-string >= 0.3.5 && < 1.1 ,HUnit if impl(ghc >= 7.4) build-depends: pretty-show >= 1.6.4 - + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 test-suite tests type: exitcode-stdio-1.0 @@ -128,7 +135,6 @@ test-suite tests , filepath , HUnit , mtl - , old-locale , old-time , parsec >= 3 , regex-tdfa @@ -137,10 +143,13 @@ test-suite tests , split , test-framework , test-framework-hunit - , time , transformers if impl(ghc >= 7.4) build-depends: pretty-show >= 1.6.4 + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 -- cf http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html diff --git a/hledger-web/hledger-web.cabal b/hledger-web/hledger-web.cabal index 292b532f9..0f85d6cb5 100644 --- a/hledger-web/hledger-web.cabal +++ b/hledger-web/hledger-web.cabal @@ -110,6 +110,11 @@ flag library-only Description: Build for use with "yesod devel" Default: False +flag old-locale + description: A compatibility flag, set automatically by cabal. + If false then depend on time >= 1.5, + if true then depend on time < 1.5 together with old-locale. + default: False library cpp-options: -DVERSION="0.24.98" @@ -171,14 +176,12 @@ library , HUnit , network-conduit , conduit-extra - , old-locale , parsec >= 3 , regexpr >= 0.5.1 , safe >= 0.2 , shakespeare >= 2.0 , template-haskell , text - , time , transformers , wai , wai-extra @@ -194,6 +197,10 @@ library -- , fsnotify -- , hsdev -- , mtl + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 executable hledger-web @@ -243,14 +250,12 @@ executable hledger-web , HUnit , network-conduit , conduit-extra - , old-locale , parsec >= 3 , regexpr >= 0.5.1 , safe >= 0.2 , shakespeare >= 2.0 && < 2.1 , template-haskell , text - , time , transformers , wai , wai-extra @@ -266,6 +271,10 @@ executable hledger-web -- , fsnotify -- , hsdev -- , mtl + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 test-suite test type: exitcode-stdio-1.0 diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 661240344..51458e15d 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -45,6 +45,12 @@ flag curses Description: On POSIX systems, enable curses support for auto-detecting terminal width. Default: True +flag old-locale + description: A compatibility flag, set automatically by cabal. + If false then depend on time >= 1.5, + if true then depend on time < 1.5 together with old-locale. + default: False + library cpp-options: -DVERSION="0.24.98" @@ -81,7 +87,6 @@ library ,haskeline >= 0.6 && <= 0.8 ,HUnit ,mtl - ,old-locale ,old-time ,parsec >= 3 ,process @@ -101,9 +106,12 @@ library ,split >= 0.1 && < 0.3 ,text >= 0.11 ,tabular >= 0.2 && < 0.3 - ,time ,utf8-string >= 0.3.5 && < 1.1 ,wizards == 1.0.* + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 if impl(ghc >= 7.4) build-depends: pretty-show >= 1.6.4 if !os(windows) && flag(curses) @@ -132,7 +140,6 @@ executable hledger ,haskeline >= 0.6 && <= 0.8 ,HUnit ,mtl - ,old-locale ,old-time ,parsec >= 3 ,process @@ -144,9 +151,12 @@ executable hledger ,split >= 0.1 && < 0.3 ,tabular >= 0.2 && < 0.3 ,text >= 0.11 - ,time ,utf8-string >= 0.3.5 && < 1.1 ,wizards == 1.0.* + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 if impl(ghc >= 7.4) build-depends: pretty-show >= 1.6.4 @@ -171,7 +181,6 @@ test-suite tests , haskeline , HUnit , mtl - , old-locale , old-time , parsec >= 3 , process @@ -185,9 +194,12 @@ test-suite tests , test-framework , test-framework-hunit , text - , time , transformers , wizards == 1.0.* + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5 if impl(ghc >= 7.4) build-depends: pretty-show >= 1.6.4 @@ -203,11 +215,13 @@ benchmark bench build-depends: hledger-lib, hledger, base >= 4.3 && < 5, - old-locale, - time, html, tabular >= 0.2 && < 0.3, process, filepath, directory + if flag(old-locale) + build-depends: time < 1.5, old-locale + else + build-depends: time >= 1.5