[commit: packages/time] master, wip/travis: Typeable instances for all types (1b0f97e)

git at git.haskell.org git at git.haskell.org
Sat May 7 06:46:22 UTC 2016


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

On branches: master,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/1b0f97ef5603d21c23a8db6485e2aeb602196cb5

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

commit 1b0f97ef5603d21c23a8db6485e2aeb602196cb5
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Sun Apr 26 17:48:05 2009 -0700

    Typeable instances for all types
    
    Ignore-this: 48421f072110ddf70b09bd4c030af863
    
    darcs-hash:20090427004805-ac6dd-4cf4de606d27096343156c687b2a37991e055312


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

1b0f97ef5603d21c23a8db6485e2aeb602196cb5
 Data/Time/Calendar/Days.hs       | 4 ++++
 Data/Time/Clock/Scale.hs         | 7 +++++++
 Data/Time/Clock/TAI.hs           | 4 ++++
 Data/Time/Clock/UTC.hs           | 7 +++++++
 Data/Time/LocalTime/LocalTime.hs | 7 +++++++
 Data/Time/LocalTime/TimeOfDay.hs | 4 ++++
 Data/Time/LocalTime/TimeZone.hs  | 4 ++++
 7 files changed, 37 insertions(+)

diff --git a/Data/Time/Calendar/Days.hs b/Data/Time/Calendar/Days.hs
index 2e62400..ad493c4 100644
--- a/Data/Time/Calendar/Days.hs
+++ b/Data/Time/Calendar/Days.hs
@@ -6,10 +6,14 @@ module Data.Time.Calendar.Days
 ) where
 
 import Data.Ix
+import Data.Typeable
 
 -- | The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.
 newtype Day = ModifiedJulianDay {toModifiedJulianDay :: Integer} deriving (Eq,Ord)
 
+instance Typeable Day where
+	typeOf _ = mkTyConApp (mkTyCon "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 30f585b..101b770 100644
--- a/Data/Time/Clock/Scale.hs
+++ b/Data/Time/Clock/Scale.hs
@@ -12,16 +12,23 @@ module Data.Time.Clock.Scale
 
 import Data.Ratio ((%))
 import Data.Fixed
+import Data.Typeable
 
 -- | The Modified Julian Date is the day with the fraction of the day, measured from UT midnight.
 -- It's used to represent UT1, which is time as measured by the earth's rotation, adjusted for various wobbles.
 newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord)
 
+instance Typeable UniversalTime where
+	typeOf _ = mkTyConApp (mkTyCon "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.
 newtype DiffTime = MkDiffTime Pico deriving (Eq,Ord)
 
+instance Typeable DiffTime where
+	typeOf _ = mkTyConApp (mkTyCon "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 835746c..a43e75e 100644
--- a/Data/Time/Clock/TAI.hs
+++ b/Data/Time/Clock/TAI.hs
@@ -16,11 +16,15 @@ module Data.Time.Clock.TAI
 import Data.Time.LocalTime
 import Data.Time.Calendar.Days
 import Data.Time.Clock
+import Data.Typeable
 import Data.Fixed
 
 -- | AbsoluteTime is TAI, time as measured by a clock.
 newtype AbsoluteTime = MkAbsoluteTime {unAbsoluteTime :: DiffTime} deriving (Eq,Ord)
 
+instance Typeable AbsoluteTime where
+	typeOf _ = mkTyConApp (mkTyCon "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 e28ce77..74df8d7 100644
--- a/Data/Time/Clock/UTC.hs
+++ b/Data/Time/Clock/UTC.hs
@@ -16,6 +16,7 @@ module Data.Time.Clock.UTC
 import Data.Time.Calendar.Days
 import Data.Time.Clock.Scale
 import Data.Fixed
+import Data.Typeable
 
 -- | This is the simplest representation of UTC.
 -- It consists of the day number, and a time offset from midnight.
@@ -27,6 +28,9 @@ data UTCTime = UTCTime {
 	utctDayTime :: DiffTime
 }
 
+instance Typeable UTCTime where
+	typeOf _ = mkTyConApp (mkTyCon "Data.Time.Clock.UTC.UTCTime") []
+
 instance Eq UTCTime where
 	(UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
 
@@ -43,6 +47,9 @@ instance Ord UTCTime where
 -- regardless of whether a leap-second intervened.
 newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord)
 
+instance Typeable NominalDiffTime where
+	typeOf _ = mkTyConApp (mkTyCon "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 6d8f219..7125a55 100644
--- a/Data/Time/LocalTime/LocalTime.hs
+++ b/Data/Time/LocalTime/LocalTime.hs
@@ -16,6 +16,7 @@ import Data.Time.LocalTime.TimeOfDay
 import Data.Time.LocalTime.TimeZone
 import Data.Time.Calendar
 import Data.Time.Clock
+import Data.Typeable
 
 -- | A simple day and time aggregate, where the day is of the specified parameter,
 -- and the time is a TimeOfDay.
@@ -26,6 +27,9 @@ data LocalTime = LocalTime {
 	localTimeOfDay   :: TimeOfDay
 } deriving (Eq,Ord)
 
+instance Typeable LocalTime where
+	typeOf _ = mkTyConApp (mkTyCon "Data.Time.LocalTime.LocalTime.LocalTime") []
+
 instance Show LocalTime where
 	show (LocalTime d t) = (showGregorian d) ++ " " ++ (show t)
 
@@ -56,6 +60,9 @@ data ZonedTime = ZonedTime {
 	zonedTimeZone :: TimeZone
 }
 
+instance Typeable ZonedTime where
+	typeOf _ = mkTyConApp (mkTyCon "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 8134d1d..c0b4608 100644
--- a/Data/Time/LocalTime/TimeOfDay.hs
+++ b/Data/Time/LocalTime/TimeOfDay.hs
@@ -11,6 +11,7 @@ module Data.Time.LocalTime.TimeOfDay
 import Data.Time.LocalTime.TimeZone
 import Data.Time.Calendar.Private
 import Data.Time.Clock
+import Data.Typeable
 import Data.Fixed
 
 -- | Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.
@@ -24,6 +25,9 @@ data TimeOfDay = TimeOfDay {
 	todSec     :: Pico
 } deriving (Eq,Ord)
 
+instance Typeable TimeOfDay where
+	typeOf _ = mkTyConApp (mkTyCon "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 da4a9cb..34c85a5 100644
--- a/Data/Time/LocalTime/TimeZone.hs
+++ b/Data/Time/LocalTime/TimeZone.hs
@@ -17,6 +17,7 @@ import Data.Time.Clock.POSIX
 
 import Foreign
 import Foreign.C
+import Data.Typeable
 
 -- | A TimeZone is a whole number of minutes offset from UTC, together with a name and a \"just for summer\" flag.
 data TimeZone = TimeZone {
@@ -28,6 +29,9 @@ data TimeZone = TimeZone {
 	timeZoneName :: String
 } deriving (Eq,Ord)
 
+instance Typeable TimeZone where
+	typeOf _ = mkTyConApp (mkTyCon "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