time-compat 1.9.5 → 1.9.6
raw patch · 10 files changed
+121/−47 lines, 10 filesdep +hashabledep ~basedep ~base-orphansdep ~time
Dependencies added: hashable
Dependency ranges changed: base, base-orphans, time
Files
- CHANGELOG.md +7/−0
- src/Data/Time/Calendar/Compat.hs +1/−1
- src/Data/Time/Calendar/Month/Compat.hs +4/−0
- src/Data/Time/Calendar/Quarter/Compat.hs +7/−0
- src/Data/Time/Calendar/WeekDate/Compat.hs +4/−0
- src/Data/Time/Clock/Compat.hs +0/−4
- src/Data/Time/LocalTime/Compat.hs +1/−1
- src/Data/Time/Orphans.hs +66/−32
- test-instances/Test.hs +21/−0
- time-compat.cabal +10/−9
CHANGELOG.md view
@@ -1,3 +1,10 @@+# 1.9.6++- Move `Hashable` instance here from `hashable-time` package.+ Note: `ZonedTime` instance is dropped, as `ZonedTime` doesn't have `Eq`+ instance.+- Drop GHC-7.0 and GHC-7.2 support.+ # 1.9.5 - Support `time-1.11.1`
src/Data/Time/Calendar/Compat.hs view
@@ -61,7 +61,7 @@ -- CalendarDiffTime ------------------------------------------------------------------------------- -#if MIN_VERSION_time(1,9,0) && !MIN_VERSION_base(1,9,2)+#if MIN_VERSION_time(1,9,0) && !MIN_VERSION_time(1,9,2) deriving instance Typeable CalendarDiffDays deriving instance Data CalendarDiffDays #endif
src/Data/Time/Calendar/Month/Compat.hs view
@@ -60,6 +60,7 @@ import Text.ParserCombinators.ReadP import Control.DeepSeq (NFData (..)) import Data.Ix (Ix (..))+import Data.Hashable (Hashable (..)) -- | An absolute count of common calendar months. -- Number is equal to @(year * 12) + (monthOfYear - 1)@.@@ -67,6 +68,9 @@ instance NFData Month where rnf (MkMonth m) = rnf m++instance Hashable Month where+ hashWithSalt salt (MkMonth x) = hashWithSalt salt x instance Enum Month where succ (MkMonth a) = MkMonth (succ a)
src/Data/Time/Calendar/Quarter/Compat.hs view
@@ -40,6 +40,7 @@ import Text.ParserCombinators.ReadP (char) import Control.DeepSeq (NFData (..)) import Data.Ix (Ix (..))+import Data.Hashable (Hashable (..)) import Data.Time.Calendar import Data.Time.Calendar.Types@@ -55,6 +56,9 @@ rnf Q3 = () rnf Q4 = () +instance Hashable QuarterOfYear where+ hashWithSalt salt = hashWithSalt salt . fromEnum+ -- | maps Q1..Q4 to 1..4 instance Enum QuarterOfYear where toEnum i =@@ -78,6 +82,9 @@ instance NFData Quarter where rnf (MkQuarter m) = rnf m++instance Hashable Quarter where+ hashWithSalt salt (MkQuarter x) = hashWithSalt salt x instance Enum Quarter where succ (MkQuarter a) = MkQuarter (succ a)
src/Data/Time/Calendar/WeekDate/Compat.hs view
@@ -41,6 +41,7 @@ #endif import Control.DeepSeq (NFData (..))+import Data.Hashable (Hashable (..)) #if !MIN_VERSION_time(1,11,0)@@ -135,6 +136,9 @@ instance NFData DayOfWeek where rnf !_ = ()++instance Hashable DayOfWeek where+ hashWithSalt salt = hashWithSalt salt . fromEnum -- | \"Circular\", so for example @[Tuesday ..]@ gives an endless sequence. -- Also: 'fromEnum' gives [1 .. 7] for [Monday .. Sunday], and 'toEnum' performs mod 7 to give a cycle of days.
src/Data/Time/Clock/Compat.hs view
@@ -66,9 +66,5 @@ #if !MIN_VERSION_time(1,6,0) -- | Get the number of picoseconds in a 'DiffTime'. diffTimeToPicoseconds :: DiffTime -> Integer-#if MIN_VERSION_time(1,4,0) diffTimeToPicoseconds = truncate . (1000000000000 *)-#else-diffTimeToPicoseconds = truncate . toRational . (1000000000000 *)-#endif #endif
src/Data/Time/LocalTime/Compat.hs view
@@ -79,7 +79,7 @@ -- CalendarDiffTime ------------------------------------------------------------------------------- -#if MIN_VERSION_time(1,9,0) && !MIN_VERSION_base(1,9,2)+#if MIN_VERSION_time(1,9,0) && !MIN_VERSION_time(1,9,2) deriving instance Typeable CalendarDiffTime deriving instance Data CalendarDiffTime #endif
src/Data/Time/Orphans.hs view
@@ -13,7 +13,14 @@ import Data.Time.Clock import Data.Time.Clock.TAI import Data.Time.Format+import Data.Hashable (Hashable (..)) +#if MIN_VERSION_time(1,5,0)+import Data.Time.Format (TimeLocale (..))+#else+import System.Locale (TimeLocale (..))+#endif+ #if MIN_VERSION_time(1,8,0) import Data.Time.Clock.System #endif@@ -31,38 +38,6 @@ import Data.Time.Calendar.Quarter #endif -#if !MIN_VERSION_time(1,4,0)-instance NFData Day where- rnf (ModifiedJulianDay d) = rnf d--instance NFData UniversalTime where- rnf (ModJulianDate d) = rnf d--instance NFData DiffTime where- rnf d = d `seq` ()--instance NFData AbsoluteTime where- rnf d = d `seq` ()--instance NFData UTCTime where- rnf (UTCTime d t) = rnf d `seq` rnf t--instance NFData NominalDiffTime where- rnf d = d `seq` ()--instance NFData LocalTime where- rnf (LocalTime d tod) = rnf d `seq` rnf tod--instance NFData ZonedTime where- rnf (ZonedTime lt tz) = rnf lt `seq` rnf tz--instance NFData TimeOfDay where- rnf (TimeOfDay h m s) = rnf h `seq` rnf m `seq` rnf s--instance NFData TimeZone where- rnf (TimeZone a b c) = rnf a `seq` rnf b `seq` rnf c-#endif- #if !MIN_VERSION_time(1,6,0) instance ParseTime UniversalTime where -- substituteTimeSpecifier _ = timeSubstituteTimeSpecifier@@ -172,4 +147,63 @@ index (MkQuarter a, MkQuarter b) (MkQuarter c) = index (a, b) c inRange (MkQuarter a, MkQuarter b) (MkQuarter c) = inRange (a, b) c rangeSize (MkQuarter a, MkQuarter b) = rangeSize (a, b)+#endif++-------------------------------------------------------------------------------+-- Hashable+-------------------------------------------------------------------------------++instance Hashable UniversalTime where+ hashWithSalt salt = hashWithSalt salt . getModJulianDate++instance Hashable DiffTime where+ hashWithSalt salt = hashWithSalt salt . toRational++instance Hashable UTCTime where+ hashWithSalt salt (UTCTime d dt) =+ salt `hashWithSalt` d `hashWithSalt` dt++instance Hashable NominalDiffTime where+ hashWithSalt salt = hashWithSalt salt . toRational++instance Hashable Day where+ hashWithSalt salt (ModifiedJulianDay d) = hashWithSalt salt d++instance Hashable TimeZone where+ hashWithSalt salt (TimeZone m s n) =+ salt `hashWithSalt` m `hashWithSalt` s `hashWithSalt` n++instance Hashable TimeOfDay where+ hashWithSalt salt (TimeOfDay h m s) =+ salt `hashWithSalt` h `hashWithSalt` m `hashWithSalt` s++instance Hashable LocalTime where+ hashWithSalt salt (LocalTime d tod) =+ salt `hashWithSalt` d `hashWithSalt` tod++instance Hashable TimeLocale where+ hashWithSalt salt (TimeLocale a b c d e f g h) =+ salt `hashWithSalt` a+ `hashWithSalt` b+ `hashWithSalt` c+ `hashWithSalt` d+ `hashWithSalt` e+ `hashWithSalt` f+ `hashWithSalt` g+ `hashWithSalt` h++#if MIN_VERSION_time(1,9,0)+instance Hashable DayOfWeek where+ hashWithSalt salt = hashWithSalt salt . fromEnum+#endif++#if MIN_VERSION_time(1,11,0)+instance Hashable Month where+ hashWithSalt salt (MkMonth x) = hashWithSalt salt x++instance Hashable Quarter where+ hashWithSalt salt (MkQuarter x) = hashWithSalt salt x++instance Hashable QuarterOfYear where+ hashWithSalt salt = hashWithSalt salt . fromEnum #endif
test-instances/Test.hs view
@@ -1,6 +1,7 @@ module Main where import Control.DeepSeq (NFData (rnf), force)+import Data.Hashable (Hashable) import Data.Time.Calendar.Compat import Data.Time.Calendar.Month.Compat@@ -102,4 +103,24 @@ ] where test :: Enum t => t -> ()+ test _ = ()++_HashableInstances :: [()]+_HashableInstances =+ [ test (undefined :: TimeLocale)+ , test (undefined :: LocalTime)+ , test (undefined :: TimeOfDay)+ , test (undefined :: TimeZone)+ , test (undefined :: UniversalTime)+ , test (undefined :: UTCTime)+ , test (undefined :: NominalDiffTime)+ , test (undefined :: DiffTime)+ , test (undefined :: DayOfWeek)+ , test (undefined :: Day)+ , test (undefined :: QuarterOfYear)+ , test (undefined :: Quarter)+ , test (undefined :: Month)+ ]+ where+ test :: Hashable t => t -> () test _ = ()
time-compat.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: time-compat-version: 1.9.5+version: 1.9.6 synopsis: Compatibility package for time description: This packages tries to compat as much of @time@ features as possible.@@ -23,9 +23,7 @@ build-type: Simple extra-source-files: CHANGELOG.md tested-with:- GHC ==7.0.4- || ==7.2.2- || ==7.4.2+ GHC ==7.4.2 || ==7.6.3 || ==7.8.4 || ==7.10.3@@ -34,7 +32,8 @@ || ==8.4.4 || ==8.6.5 || ==8.8.4- || ==8.10.2+ || ==8.10.4+ || ==9.0.1 source-repository head type: git@@ -54,15 +53,16 @@ default-extensions: Trustworthy build-depends:- base >=4.3 && <4.15- , base-orphans >=0.8.1 && <0.9+ base >=4.5 && <4.16+ , base-orphans >=0.8.4 && <0.9 , deepseq >=1.3.0.0 && <1.4 || >=1.4.1.1 && <1.5- , time >=1.2 && <1.3 || >=1.4 && <1.7 || >=1.8 && <1.9 || >=1.9.2 && <1.9.4 || >=1.10 && <1.10.1 || >=1.11 && <1.11.2+ , time >=1.4 && <1.7 || >=1.8 && <1.9 || >=1.9.2 && <1.9.4 || >=1.10 && <1.10.1 || >=1.11 && <1.11.2+ , hashable >=1.3.2.0 && <1.4 if flag(old-locale) build-depends: old-locale >=1.0.0.2 && <1.1- , time >=0 && <1.5+ , time >=1.4 && <1.5 else build-depends: time >=1.5@@ -105,6 +105,7 @@ base , deepseq , HUnit >=1.3.1 && <1.3.2 || >=1.6.0.0 && <1.7+ , hashable >=1.3.1.0 && <1.4 , time-compat -- This test-suite is from time library