[commit: packages/time] format-widths, improve-leapseconds, master, posix-perf, tasty: Simplify LeapSecondMap type (7b1dddd)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:18:51 UTC 2017


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

On branches: format-widths,improve-leapseconds,master,posix-perf,tasty
Link       : http://git.haskell.org/packages/time.git/commitdiff/7b1dddd9d1d0fe4bc3c82d8dedb9ca3232b556b1

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

commit 7b1dddd9d1d0fe4bc3c82d8dedb9ca3232b556b1
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Sat Nov 19 00:15:25 2016 -0800

    Simplify LeapSecondMap type


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

7b1dddd9d1d0fe4bc3c82d8dedb9ca3232b556b1
 lib/Data/Time/Clock/TAI.hs | 10 +++++-----
 test/Test/TestTAI.hs       |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/Data/Time/Clock/TAI.hs b/lib/Data/Time/Clock/TAI.hs
index 054e0ad..dbde65f 100644
--- a/lib/Data/Time/Clock/TAI.hs
+++ b/lib/Data/Time/Clock/TAI.hs
@@ -56,25 +56,25 @@ diffAbsoluteTime (MkAbsoluteTime a) (MkAbsoluteTime b) = a - b
 -- | TAI - UTC during this day.
 -- No table is provided, as any program compiled with it would become
 -- out of date in six months.
-type LeapSecondMap m = Day -> m Int
+type LeapSecondMap = Day -> Maybe Int
 
-utcDayLength :: Monad m => LeapSecondMap m -> Day -> m DiffTime
+utcDayLength :: LeapSecondMap -> Day -> Maybe DiffTime
 utcDayLength lsmap day = do
     i0 <- lsmap day
     i1 <- lsmap $ addDays 1 day
     return $ realToFrac (86400 + i1 - i0)
 
-dayStart :: Monad m => LeapSecondMap m -> Day -> m AbsoluteTime
+dayStart :: LeapSecondMap -> Day -> Maybe AbsoluteTime
 dayStart lsmap day = do
     i <- lsmap day
     return $ addAbsoluteTime (realToFrac $ (toModifiedJulianDay day) * 86400 + toInteger i) taiEpoch
 
-utcToTAITime :: Monad m => LeapSecondMap m -> UTCTime -> m AbsoluteTime
+utcToTAITime :: LeapSecondMap -> UTCTime -> Maybe AbsoluteTime
 utcToTAITime lsmap (UTCTime day dtime) = do
     t <- dayStart lsmap day
     return $ addAbsoluteTime dtime t
 
-taiToUTCTime :: Monad m => LeapSecondMap m -> AbsoluteTime -> m UTCTime
+taiToUTCTime :: LeapSecondMap -> AbsoluteTime -> Maybe UTCTime
 taiToUTCTime lsmap abstime = let
     stable day = do
         dayt <- dayStart lsmap day
diff --git a/test/Test/TestTAI.hs b/test/Test/TestTAI.hs
index 9284f35..dfaf605 100644
--- a/test/Test/TestTAI.hs
+++ b/test/Test/TestTAI.hs
@@ -5,7 +5,7 @@ import Data.Time.Clock.TAI
 import Test.TestUtil
 
 
-sampleLeapSecondMap :: LeapSecondMap Maybe
+sampleLeapSecondMap :: LeapSecondMap
 sampleLeapSecondMap d | d < fromGregorian 1972 1 1 = Nothing
 sampleLeapSecondMap d | d < fromGregorian 1972 7 1 = Just 10
 sampleLeapSecondMap d | d < fromGregorian 1975 1 1 = Just 11



More information about the ghc-commits mailing list