[commit: packages/time] master: Derive Typeable instances (222f71c)

git at git.haskell.org git at git.haskell.org
Sun Dec 20 07:54:20 UTC 2015


Repository : ssh://git@git.haskell.org/time

On branch  : master
Link       : http://git.haskell.org/packages/time.git/commitdiff/222f71c3c2d97dfcb68e2db171d57835695c91b5

>---------------------------------------------------------------

commit 222f71c3c2d97dfcb68e2db171d57835695c91b5
Author: jpm <jpm at cs.ox.ac.uk>
Date:   Wed Nov 28 06:58:44 2012 -0800

    Derive Typeable instances
    
    Ignore-this: d301bb00a270f5c27cf9bffc27f85828
    
    darcs-hash:20121128145844-ddd07-279620f99a395c40ffc649ee93d3c5bee3e4e7d9


>---------------------------------------------------------------

222f71c3c2d97dfcb68e2db171d57835695c91b5
 Data/Time/Calendar/Days.hs       |  5 +----
 Data/Time/Clock/Scale.hs         | 10 ++--------
 Data/Time/Clock/TAI.hs           |  5 +----
 Data/Time/Clock/UTC.hs           | 10 ++--------
 Data/Time/LocalTime/LocalTime.hs | 10 ++--------
 Data/Time/LocalTime/TimeOfDay.hs |  5 +----
 Data/Time/LocalTime/TimeZone.hs  |  5 +----
 7 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/Data/Time/Calendar/Days.hs b/Data/Time/Calendar/Days.hs
index 6911833..9b535c0 100644
--- a/Data/Time/Calendar/Days.hs
+++ b/Data/Time/Calendar/Days.hs
@@ -18,7 +18,7 @@ import Data.Data
 newtype Day = ModifiedJulianDay {toModifiedJulianDay :: Integer} deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
@@ -26,9 +26,6 @@ newtype Day = ModifiedJulianDay {toModifiedJulianDay :: Integer} deriving (Eq,Or
 instance NFData Day where
 	rnf (ModifiedJulianDay a) = rnf a
 
-instance Typeable Day where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Calendar.Days" "Day") []
-
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance Enum Day where
 	succ (ModifiedJulianDay a) = ModifiedJulianDay (succ a)
diff --git a/Data/Time/Clock/Scale.hs b/Data/Time/Clock/Scale.hs
index 237a77b..9e91795 100644
--- a/Data/Time/Clock/Scale.hs
+++ b/Data/Time/Clock/Scale.hs
@@ -25,7 +25,7 @@ import Data.Data
 newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
@@ -34,9 +34,6 @@ newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (E
 instance NFData UniversalTime where
 	rnf (ModJulianDate a) = rnf a
 
-instance Typeable UniversalTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.Scale" "UniversalTime") []
-
 -- | This is a length of time, as measured by a clock.
 -- Conversion functions will treat it as seconds.
 -- It has a precision of 10^-12 s.
@@ -44,7 +41,7 @@ newtype DiffTime = MkDiffTime Pico deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #else
 #endif
 #endif
@@ -54,9 +51,6 @@ newtype DiffTime = MkDiffTime Pico deriving (Eq,Ord
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance NFData DiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing
 
-instance Typeable DiffTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.Scale" "DiffTime") []
-
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance Enum DiffTime where
 	succ (MkDiffTime a) = MkDiffTime (succ a)
diff --git a/Data/Time/Clock/TAI.hs b/Data/Time/Clock/TAI.hs
index 5e6bfef..271f750 100644
--- a/Data/Time/Clock/TAI.hs
+++ b/Data/Time/Clock/TAI.hs
@@ -30,7 +30,7 @@ newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -39,9 +39,6 @@ newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,
 instance NFData AbsoluteTime where
 	rnf (MkAbsoluteTime a) = rnf a
 
-instance Typeable AbsoluteTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.TAI" "AbsoluteTime") []
-
 instance Show AbsoluteTime where
 	show t = show (utcToLocalTime utc (taiToUTCTime (const 0) t)) ++ " TAI" -- ugly, but standard apparently
 
diff --git a/Data/Time/Clock/UTC.hs b/Data/Time/Clock/UTC.hs
index da1ecc2..3ba3309 100644
--- a/Data/Time/Clock/UTC.hs
+++ b/Data/Time/Clock/UTC.hs
@@ -36,7 +36,7 @@ data UTCTime = UTCTime {
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    deriving (Data)
+    deriving (Data, Typeable)
 #endif
 #endif
 #endif
@@ -44,9 +44,6 @@ data UTCTime = UTCTime {
 instance NFData UTCTime where
 	rnf (UTCTime d t) = d `deepseq` t `deepseq` ()
 
-instance Typeable UTCTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.UTC" "UTCTime") []
-
 instance Eq UTCTime where
 	(UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
 
@@ -65,7 +62,7 @@ newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -74,9 +71,6 @@ newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord
 -- necessary because H98 doesn't have "cunning newtype" derivation
 instance NFData NominalDiffTime -- FIXME: Data.Fixed had no NFData instances yet at time of writing
 
-instance Typeable NominalDiffTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.Clock.UTC" "NominalDiffTime") []
-
 instance Enum NominalDiffTime where
 	succ (MkNominalDiffTime a) = MkNominalDiffTime (succ a)
 	pred (MkNominalDiffTime a) = MkNominalDiffTime (pred a)
diff --git a/Data/Time/LocalTime/LocalTime.hs b/Data/Time/LocalTime/LocalTime.hs
index 02f06a4..b32af80 100644
--- a/Data/Time/LocalTime/LocalTime.hs
+++ b/Data/Time/LocalTime/LocalTime.hs
@@ -34,7 +34,7 @@ data LocalTime = LocalTime {
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -43,9 +43,6 @@ data LocalTime = LocalTime {
 instance NFData LocalTime where
 	rnf (LocalTime d t) = d `deepseq` t `deepseq` ()
 
-instance Typeable LocalTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.LocalTime" "LocalTime") []
-
 instance Show LocalTime where
 	show (LocalTime d t) = (showGregorian d) ++ " " ++ (show t)
 
@@ -78,7 +75,7 @@ data ZonedTime = ZonedTime {
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    deriving (Data)
+    deriving (Data, Typeable)
 #endif
 #endif
 #endif
@@ -86,9 +83,6 @@ data ZonedTime = ZonedTime {
 instance NFData ZonedTime where
 	rnf (ZonedTime lt z) = lt `deepseq` z `deepseq` ()
 
-instance Typeable ZonedTime where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.LocalTime" "ZonedTime") []
-
 utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime
 utcToZonedTime zone time = ZonedTime (utcToLocalTime zone time) zone
 
diff --git a/Data/Time/LocalTime/TimeOfDay.hs b/Data/Time/LocalTime/TimeOfDay.hs
index 8fdf539..93c0c70 100644
--- a/Data/Time/LocalTime/TimeOfDay.hs
+++ b/Data/Time/LocalTime/TimeOfDay.hs
@@ -33,7 +33,7 @@ data TimeOfDay = TimeOfDay {
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
 #if HAS_DataPico
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
 #endif
@@ -42,9 +42,6 @@ data TimeOfDay = TimeOfDay {
 instance NFData TimeOfDay where
 	rnf (TimeOfDay h m s) = h `deepseq` m `deepseq` s `seq` () -- FIXME: Data.Fixed had no NFData instances yet at time of writing
 
-instance Typeable TimeOfDay where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.TimeOfDay" "TimeOfDay") []
-
 -- | Hour zero
 midnight :: TimeOfDay
 midnight = TimeOfDay 0 0 0
diff --git a/Data/Time/LocalTime/TimeZone.hs b/Data/Time/LocalTime/TimeZone.hs
index 689288f..fa70026 100644
--- a/Data/Time/LocalTime/TimeZone.hs
+++ b/Data/Time/LocalTime/TimeZone.hs
@@ -36,7 +36,7 @@ data TimeZone = TimeZone {
 } deriving (Eq,Ord
 #if LANGUAGE_DeriveDataTypeable
 #if LANGUAGE_Rank2Types
-    ,Data
+    ,Data, Typeable
 #endif
 #endif
     )
@@ -44,9 +44,6 @@ data TimeZone = TimeZone {
 instance NFData TimeZone where
 	rnf (TimeZone m so n) = m `deepseq` so `deepseq` n `deepseq` ()
 
-instance Typeable TimeZone where
-	typeOf _ = mkTyConApp (mkTyCon3 "time" "Data.Time.LocalTime.TimeZone" "TimeZone") []
-
 -- | Create a nameless non-summer timezone for this number of minutes
 minutesToTimeZone :: Int -> TimeZone
 minutesToTimeZone m = TimeZone m False ""



More information about the ghc-commits mailing list