diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c9086..687677a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +0.2.0.2 Lars Petersen 2018-10-12 + + * Resolved error about constrained class methods. + * Added more annotation about SafeHaskell. + 0.2.0.1 Lars Petersen 2015-06-17 * Resolved issue with Monad/Applicative/Functor (affected only older base). @@ -9,5 +14,5 @@ * Removed `Midnight` in favour of `Epoch`. * Only expose module `Data.UTC` as it contains everything anyway. * Added functions for rendering according to ISO8601. - * Use `MonadThrow` and `UtcException` instead of `Monad.fail` - (`fail` is just for pattern-match fail as I learned). \ No newline at end of file + * Use `MonadThrow` and `UtcException` instead of `Monad.fail` + (`fail` is just for pattern-match fail as I learned). diff --git a/Data/UTC.hs b/Data/UTC.hs index 15829a7..550b6cb 100644 --- a/Data/UTC.hs +++ b/Data/UTC.hs @@ -1,5 +1,6 @@ +{-# LANGUAGE Safe #-} module Data.UTC - ( + ( -- * Introduction -- ** Quick Start -- $quickstart @@ -64,7 +65,7 @@ import Data.UTC.Format.Iso8601 -- $quickstart -- --- Just import the main module and use the 'DateTime' type! +-- Just import the main module and use the 'DateTime' type! -- It supports all functions you'll find below. -- Use 'Maybe' for all occurences of 'm'. -- @@ -127,4 +128,4 @@ import Data.UTC.Format.Iso8601 -- In reality the problem is less severe than it seems: Your system clock is most probably -- counting unix seconds and does not know about leap seconds either. So chances are that -- when dealing with computer generated timestamps you'll never encounter problems with --- leap seconds. \ No newline at end of file +-- leap seconds. diff --git a/Data/UTC/Class.hs b/Data/UTC/Class.hs index acde103..ef22a56 100644 --- a/Data/UTC/Class.hs +++ b/Data/UTC/Class.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Class ( module Data.UTC.Class.IsDate , module Data.UTC.Class.IsTime @@ -10,4 +11,4 @@ import Data.UTC.Class.Epoch import Data.UTC.Class.IsDate import Data.UTC.Class.IsTime import Data.UTC.Class.IsUnixTime -import Data.UTC.Class.HasUnixTime \ No newline at end of file +import Data.UTC.Class.HasUnixTime diff --git a/Data/UTC/Class/HasUnixTime.hs b/Data/UTC/Class/HasUnixTime.hs index c374d49..ea028ed 100644 --- a/Data/UTC/Class/HasUnixTime.hs +++ b/Data/UTC/Class/HasUnixTime.hs @@ -1,6 +1,5 @@ {-# LANGUAGE Safe #-} -{-# LANGUAGE ConstrainedClassMethods #-} - +{-# OPTIONS_GHC -XConstrainedClassMethods #-} module Data.UTC.Class.HasUnixTime where @@ -34,7 +33,7 @@ class HasUnixTime m where -- /Example:/ -- -- > import Data.UTC - -- > + -- > -- > printCurrentYear :: IO () -- > printCurrentYear -- > = do now <- getUnixTime :: IO DateTime @@ -47,4 +46,3 @@ instance HasUnixTime IO where case fromUnixSeconds ((fromIntegral s) % 1 + (fromIntegral ns) % 1000000000) of Just t -> return t Nothing -> throwM $ UtcException "HasUnixTime IO: getUnixTime" - diff --git a/Data/UTC/Class/IsDate/Test.hs b/Data/UTC/Class/IsDate/Test.hs index 313f42d..9e46639 100644 --- a/Data/UTC/Class/IsDate/Test.hs +++ b/Data/UTC/Class/IsDate/Test.hs @@ -76,7 +76,7 @@ test , (month `fmap` d) === Just 2 , (day `fmap` d) === Just 29 ] - ] + ] , testGroup "addDays" [ testProperty "addDays 366 '2000-01-01'" $ let d = setYear 2000 (epoch :: Date) >>= setMonth 1 >>= setDay 1 >>= addDays 366 diff --git a/Data/UTC/Format/Iso8601.hs b/Data/UTC/Format/Iso8601.hs index 09af7c7..db2193e 100644 --- a/Data/UTC/Format/Iso8601.hs +++ b/Data/UTC/Format/Iso8601.hs @@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE Safe #-} module Data.UTC.Format.Iso8601 where import Control.Monad.Catch @@ -74,9 +75,9 @@ instance Iso8601Renderer TL.Text where = renderIso8601TimeHm' t >>= return . TL.decodeUtf8 instance Iso8601Renderer [Char] where - renderIso8601CalendarDate t + renderIso8601CalendarDate t = renderIso8601CalendarDate t >>= return . T.unpack - renderIso8601CalendarDate' t + renderIso8601CalendarDate' t = renderIso8601CalendarDate' t >>= return . T.unpack renderIso8601TimeHms t = renderIso8601TimeHms t >>= return . T.unpack @@ -195,4 +196,3 @@ timeDigits t m0 = fromIntegral $ mm `div` 1 `mod` 10 s1 = fromIntegral $ ss `div` 10 `mod` 10 s0 = fromIntegral $ ss `div` 1 `mod` 10 - diff --git a/Data/UTC/Format/Rfc3339.hs b/Data/UTC/Format/Rfc3339.hs index b5a6426..cfac149 100644 --- a/Data/UTC/Format/Rfc3339.hs +++ b/Data/UTC/Format/Rfc3339.hs @@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE Safe #-} module Data.UTC.Format.Rfc3339 ( -- * Parsing Rfc3339Parser(..) @@ -52,12 +53,12 @@ instance Rfc3339Parser [Char] where parseRfc3339 s = parseRfc3339 (T.pack s) --- | > setYear 1987 (epoch :: DateTime) --- > >>= setMonth 7 --- > >>= setDay 10 --- > >>= setHour 12 --- > >>= setMinute 4 --- > >>= return . (flip Local) (Just 0) +-- | > setYear 1987 (epoch :: DateTime) +-- > >>= setMonth 7 +-- > >>= setDay 10 +-- > >>= setHour 12 +-- > >>= setMinute 4 +-- > >>= return . (flip Local) (Just 0) -- > >>= renderRfc3339 :: Maybe String -- > > Just "1987-07-10T12:04:00Z" class Rfc3339Renderer string where @@ -80,5 +81,5 @@ instance Rfc3339Renderer TL.Text where = renderRfc3339 t >>= return . TL.decodeUtf8 instance Rfc3339Renderer [Char] where - renderRfc3339 t + renderRfc3339 t = renderRfc3339 t >>= return . T.unpack diff --git a/Data/UTC/Format/Rfc3339/Parser.hs b/Data/UTC/Format/Rfc3339/Parser.hs index c9f8070..b4776a8 100644 --- a/Data/UTC/Format/Rfc3339/Parser.hs +++ b/Data/UTC/Format/Rfc3339/Parser.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Format.Rfc3339.Parser ( rfc3339Parser ) where @@ -15,7 +16,7 @@ import Data.UTC.Class.IsTime import Data.UTC.Type.Local rfc3339Parser :: (MonadThrow m, IsDate t, IsTime t) => Parser (m (Local t)) -rfc3339Parser +rfc3339Parser = do year' <- dateFullYear _ <- char '-' month' <- dateMonth @@ -111,4 +112,4 @@ rfc3339Parser return $ d1 * 1000 + d2 * 100 + d3 * 10 - + d4 \ No newline at end of file + + d4 diff --git a/Data/UTC/Internal.hs b/Data/UTC/Internal.hs index dd30987..7868698 100644 --- a/Data/UTC/Internal.hs +++ b/Data/UTC/Internal.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Internal ( daysToYearMonthDay , yearMonthDayToDays @@ -120,7 +121,7 @@ daysToYearMonthDay d' ((year `mod` 400 == 0) || (year `mod` 100 /= 0)) then (1+) else id doy = d - yearToDays year - (month,day) + (month,day) | doy < 31 = ( 1, doy + 1) | doy < ld 59 = ( 2, doy - 31 + 1) | doy < ld 90 = ( 3, doy - ld 59 + 1) @@ -189,4 +190,4 @@ decimalFraction limit r where r10 = r' * 10 ch = toEnum $ fromIntegral $ 48 + (truncate $ r10) `mod` (10 :: Integer) - s = r10 - (truncate r10 % 1) \ No newline at end of file + s = r10 - (truncate r10 % 1) diff --git a/Data/UTC/Internal/Test.hs b/Data/UTC/Internal/Test.hs index dcb1ea8..2297e03 100644 --- a/Data/UTC/Internal/Test.hs +++ b/Data/UTC/Internal/Test.hs @@ -122,7 +122,7 @@ testYearToDays testDaysToYearMonthDay :: Test testDaysToYearMonthDay = testGroup "daysToYearMonthDay" - $ [ + $ [ testProperty "daysToYearMonthDay 366 === (1,1,1)" $ daysToYearMonthDay 366 === (1,1,1) @@ -320,4 +320,4 @@ testYearMonthDayToDaysAndDaysToYearMonthDay , testProperty ("yearMonthDayToDays (daysToYearMonthDay x) - x === 0 for -1000000 < x < 5000000") $ forAll (choose (-1000000, 5000000)) -- 0000-01-01 to 9999-12-31 $ \x-> yearMonthDayToDays (daysToYearMonthDay x) - x === 0 - ] \ No newline at end of file + ] diff --git a/Data/UTC/Type.hs b/Data/UTC/Type.hs index c92858a..e0aef5f 100644 --- a/Data/UTC/Type.hs +++ b/Data/UTC/Type.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Type ( module Data.UTC.Type.Date , module Data.UTC.Type.Time diff --git a/Data/UTC/Type/Date.hs b/Data/UTC/Type/Date.hs index eb42f41..600d79a 100644 --- a/Data/UTC/Type/Date.hs +++ b/Data/UTC/Type/Date.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Type.Date ( Date () ) where @@ -89,4 +90,3 @@ instance IsDate Date where = if isValidDate (year t, month t, x) then return $ t { dDay = x } else throwM $ UtcException $ "IsDate Date: setDay " ++ show x ++ " " ++ show t - diff --git a/Data/UTC/Type/DateTime.hs b/Data/UTC/Type/DateTime.hs index dad90d0..eb58d7e 100644 --- a/Data/UTC/Type/DateTime.hs +++ b/Data/UTC/Type/DateTime.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE FlexibleInstances #-} module Data.UTC.Type.DateTime ( -- * Type @@ -86,7 +87,7 @@ instance IsTime DateTime where = do tm <- setSecondFraction y (time t) return $ t { time = tm } - -- The default implementation of addHours fails whena day flows over. + -- The default implementation of addHours fails whena day flows over. -- For DateTimes we can let it ripple into the days. addHours h t = setHour hors t >>= addDays days @@ -199,4 +200,4 @@ instance IsTime (Local DateTime) where where h' = h + (hour t) days = h' `div` hoursPerDay - hors = h' `mod` hoursPerDay \ No newline at end of file + hors = h' `mod` hoursPerDay diff --git a/Data/UTC/Type/Exception.hs b/Data/UTC/Type/Exception.hs index 6fbc1ba..487693e 100644 --- a/Data/UTC/Type/Exception.hs +++ b/Data/UTC/Type/Exception.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} {-# LANGUAGE DeriveDataTypeable #-} module Data.UTC.Type.Exception where @@ -15,4 +16,4 @@ data UtcException = UtcException String deriving (Show, Typeable) -instance Exception UtcException \ No newline at end of file +instance Exception UtcException diff --git a/Data/UTC/Type/Time.hs b/Data/UTC/Type/Time.hs index 7a49ca5..f8fae92 100644 --- a/Data/UTC/Type/Time.hs +++ b/Data/UTC/Type/Time.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE Safe #-} module Data.UTC.Type.Time ( Time () ) where @@ -81,4 +82,4 @@ instance IsTime Time where | otherwise = return $ t { tSecond = x } setSecondFraction x t | x < 0 || 1 <= x = throwM $ UtcException $ "Time: setSecondFraction " ++ show x ++ " " ++ show t - | otherwise = return $ t { tSecondFraction = x } \ No newline at end of file + | otherwise = return $ t { tSecondFraction = x } diff --git a/utc.cabal b/utc.cabal index 5fdbf92..a664191 100644 --- a/utc.cabal +++ b/utc.cabal @@ -1,5 +1,5 @@ name: utc -version: 0.2.0.1 +version: 0.2.0.2 stability: experimental synopsis: A pragmatic time and date library. description: This library aims to supply you with common