diff --git a/.github/workflows/ci.mhs.yml b/.github/workflows/ci.mhs.yml index 91f1ef5e..89cb0f0d 100644 --- a/.github/workflows/ci.mhs.yml +++ b/.github/workflows/ci.mhs.yml @@ -16,7 +16,7 @@ jobs: path: time - name: checkout mhs repo # workaround for `act`: https://github.com/nektos/act/issues/678#issuecomment-1693751996 - run: git clone https://github.com/augustss/MicroHs.git --branch stable-2 mhs + run: git clone https://github.com/augustss/MicroHs.git --branch stable-4 mhs - name: make and install mhs run: | cd mhs diff --git a/lib/Data/Time/Calendar/Gregorian.hs b/lib/Data/Time/Calendar/Gregorian.hs index fd10f5c7..be5a8481 100644 --- a/lib/Data/Time/Calendar/Gregorian.hs +++ b/lib/Data/Time/Calendar/Gregorian.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} {-# LANGUAGE TypeSynonymInstances #-} @@ -7,12 +6,9 @@ module Data.Time.Calendar.Gregorian ( -- * Year, month and day Year, -#ifdef __GLASGOW_HASKELL__ pattern CommonEra, pattern BeforeCommonEra, -#endif MonthOfYear, -#ifdef __GLASGOW_HASKELL__ pattern January, pattern February, pattern March, @@ -25,15 +21,12 @@ module Data.Time.Calendar.Gregorian ( pattern October, pattern November, pattern December, -#endif DayOfMonth, -- * Gregorian calendar toGregorian, fromGregorian, -#ifdef __GLASGOW_HASKELL__ pattern YearMonthDay, -#endif fromGregorianValid, showGregorian, gregorianMonthLength, @@ -70,7 +63,6 @@ toGregorian date = (year, month, day) fromGregorian :: Year -> MonthOfYear -> DayOfMonth -> Day fromGregorian year month day = fromOrdinalDate year (monthAndDayToDayOfYear (isLeapYear year) month day) -#if __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor for the proleptic Gregorian calendar. -- Invalid values will be clipped to the correct range, month first, then day. pattern YearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day @@ -78,7 +70,6 @@ pattern YearMonthDay y m d <- (toGregorian -> (y, m, d)) where YearMonthDay y m d = fromGregorian y m d -#endif {-# COMPLETE YearMonthDay #-} @@ -193,10 +184,8 @@ diffGregorianDurationRollOver day2 day1 = instance Show Day where show = showGregorian -#ifdef __GLASGOW_HASKELL__ -- orphan instance instance DayPeriod Year where periodFirstDay y = YearMonthDay y January 1 periodLastDay y = YearMonthDay y December 31 dayPeriod (YearMonthDay y _ _) = y -#endif diff --git a/lib/Data/Time/Calendar/Julian.hs b/lib/Data/Time/Calendar/Julian.hs index b60a63e8..861c4b9e 100644 --- a/lib/Data/Time/Calendar/Julian.hs +++ b/lib/Data/Time/Calendar/Julian.hs @@ -1,10 +1,8 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} module Data.Time.Calendar.Julian ( Year, MonthOfYear, -#ifdef __GLASGOW_HASKELL__ pattern January, pattern February, pattern March, @@ -17,15 +15,12 @@ module Data.Time.Calendar.Julian ( pattern October, pattern November, pattern December, -#endif DayOfMonth, DayOfYear, module Data.Time.Calendar.JulianYearDay, toJulian, fromJulian, -#ifdef __GLASGOW_HASKELL__ pattern JulianYearMonthDay, -#endif fromJulianValid, showJulian, julianMonthLength, @@ -60,7 +55,6 @@ toJulian date = (year, month, day) fromJulian :: Year -> MonthOfYear -> DayOfMonth -> Day fromJulian year month day = fromJulianYearAndDay year (monthAndDayToDayOfYear (isJulianLeapYear year) month day) -#ifdef __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor for the proleptic Julian calendar. -- Invalid values will be clipped to the correct range, month first, then day. pattern JulianYearMonthDay :: Year -> MonthOfYear -> DayOfMonth -> Day @@ -70,7 +64,6 @@ pattern JulianYearMonthDay y m d <- JulianYearMonthDay y m d = fromJulian y m d {-# COMPLETE JulianYearMonthDay #-} -#endif -- | Convert from proleptic Julian calendar. -- Invalid values will return Nothing. diff --git a/lib/Data/Time/Calendar/Month.hs b/lib/Data/Time/Calendar/Month.hs index 6fa3563c..832ecbb8 100644 --- a/lib/Data/Time/Calendar/Month.hs +++ b/lib/Data/Time/Calendar/Month.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | An absolute count of common calendar months. @@ -6,12 +5,10 @@ module Data.Time.Calendar.Month ( Month (..), addMonths, diffMonths, -#if __GLASGOW_HASKELL__ pattern YearMonth, fromYearMonthValid, pattern MonthDay, fromMonthDayValid, -#endif ) where import Control.DeepSeq @@ -50,7 +47,6 @@ instance Ix Month where inRange (MkMonth a, MkMonth b) (MkMonth c) = inRange (a, b) c rangeSize (MkMonth a, MkMonth b) = rangeSize (a, b) -#ifdef __GLASGOW_HASKELL__ -- | Show as @yyyy-mm@. instance Show Month where show (YearMonth y m) = show4 y ++ "-" ++ show2 m @@ -67,7 +63,6 @@ instance DayPeriod Month where periodFirstDay (YearMonth y m) = YearMonthDay y m 1 periodLastDay (YearMonth y m) = YearMonthDay y m 31 -- clips to correct day dayPeriod (YearMonthDay y my _) = YearMonth y my -#endif addMonths :: Integer -> Month -> Month addMonths n (MkMonth a) = MkMonth $ a + n @@ -75,12 +70,11 @@ addMonths n (MkMonth a) = MkMonth $ a + n diffMonths :: Month -> Month -> Integer diffMonths (MkMonth a) (MkMonth b) = a - b -#ifdef __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor. -- Invalid months of year will be clipped to the correct range. pattern YearMonth :: Year -> MonthOfYear -> Month pattern YearMonth y my <- - MkMonth ((\m -> divMod' m 12) -> (y, succ . fromInteger -> my)) + MkMonth ((\m -> divMod' m 12) -> (y, (succ . fromInteger -> my))) where YearMonth y my = MkMonth $ (y * 12) + toInteger (pred $ clip 1 12 my) @@ -103,4 +97,3 @@ fromMonthDayValid :: Month -> DayOfMonth -> Maybe Day fromMonthDayValid = periodToDayValid {-# COMPLETE MonthDay #-} -#endif diff --git a/lib/Data/Time/Calendar/MonthDay.hs b/lib/Data/Time/Calendar/MonthDay.hs index 02ba0d34..8bd23c6b 100644 --- a/lib/Data/Time/Calendar/MonthDay.hs +++ b/lib/Data/Time/Calendar/MonthDay.hs @@ -1,9 +1,7 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} module Data.Time.Calendar.MonthDay ( MonthOfYear, -#ifdef __GLASGOW_HASKELL__ pattern January, pattern February, pattern March, @@ -16,7 +14,6 @@ module Data.Time.Calendar.MonthDay ( pattern October, pattern November, pattern December, -#endif DayOfMonth, DayOfYear, monthAndDayToDayOfYear, diff --git a/lib/Data/Time/Calendar/OrdinalDate.hs b/lib/Data/Time/Calendar/OrdinalDate.hs index c4743253..31cb9ad6 100644 --- a/lib/Data/Time/Calendar/OrdinalDate.hs +++ b/lib/Data/Time/Calendar/OrdinalDate.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | ISO 8601 Ordinal Date format @@ -46,7 +45,6 @@ fromOrdinalDate year day = ModifiedJulianDay mjd + (div y 400) - 678576 -#ifdef __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor for ISO 8601 Ordinal Date format. -- Invalid day numbers will be clipped to the correct range (1 to 365 or 366). pattern YearDay :: Year -> DayOfYear -> Day @@ -56,7 +54,6 @@ pattern YearDay y d <- YearDay y d = fromOrdinalDate y d {-# COMPLETE YearDay #-} -#endif -- | Convert from ISO 8601 Ordinal Date format. -- Invalid day numbers return 'Nothing' diff --git a/lib/Data/Time/Calendar/Quarter.hs b/lib/Data/Time/Calendar/Quarter.hs index 52d83519..19d7a656 100644 --- a/lib/Data/Time/Calendar/Quarter.hs +++ b/lib/Data/Time/Calendar/Quarter.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | Year quarters. @@ -7,18 +6,12 @@ module Data.Time.Calendar.Quarter ( addQuarters, diffQuarters, Quarter (..), -#ifdef __GLASGOW_HASKELL__ pattern YearQuarter, -#endif monthOfYearQuarter, -#ifdef __GLASGOW_HASKELL__ monthQuarter, dayQuarter, -#endif DayOfQuarter, -#ifdef __GLASGOW_HASKELL__ pattern QuarterDay, -#endif ) where import Control.DeepSeq @@ -84,7 +77,6 @@ instance Ix Quarter where inRange (MkQuarter a, MkQuarter b) (MkQuarter c) = inRange (a, b) c rangeSize (MkQuarter a, MkQuarter b) = rangeSize (a, b) -#ifdef __GLASGOW_HASKELL__ -- | Show as @yyyy-Qn@. instance Show Quarter where show (YearQuarter y qy) = show4 y ++ "-" ++ show qy @@ -111,7 +103,6 @@ instance DayPeriod Quarter where Q3 -> periodLastDay $ YearMonth y September Q4 -> periodLastDay $ YearMonth y December dayPeriod (MonthDay m _) = monthQuarter m -#endif addQuarters :: Integer -> Quarter -> Quarter addQuarters n (MkQuarter a) = MkQuarter $ a + n @@ -119,16 +110,14 @@ addQuarters n (MkQuarter a) = MkQuarter $ a + n diffQuarters :: Quarter -> Quarter -> Integer diffQuarters (MkQuarter a) (MkQuarter b) = a - b -#ifdef __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor. pattern YearQuarter :: Year -> QuarterOfYear -> Quarter pattern YearQuarter y qy <- - MkQuarter ((\q -> divMod' q 4) -> (y, toEnum . succ . fromInteger -> qy)) + MkQuarter ((\q -> divMod' q 4) -> (y, (toEnum . succ . fromInteger -> qy))) where YearQuarter y qy = MkQuarter $ (y * 4) + toInteger (pred $ fromEnum qy) {-# COMPLETE YearQuarter #-} -#endif -- | The 'QuarterOfYear' this 'MonthOfYear' is in. monthOfYearQuarter :: MonthOfYear -> QuarterOfYear @@ -137,7 +126,6 @@ monthOfYearQuarter my | my <= 6 = Q2 monthOfYearQuarter my | my <= 9 = Q3 monthOfYearQuarter _ = Q4 -#ifdef __GLASGOW_HASKELL__ -- | The 'Quarter' this 'Month' is in. monthQuarter :: Month -> Quarter monthQuarter (YearMonth y my) = YearQuarter y $ monthOfYearQuarter my @@ -157,4 +145,3 @@ pattern QuarterDay q dq <- QuarterDay = periodToDay {-# COMPLETE QuarterDay #-} -#endif diff --git a/lib/Data/Time/Calendar/Types.hs b/lib/Data/Time/Calendar/Types.hs index c5de90d7..515e437e 100644 --- a/lib/Data/Time/Calendar/Types.hs +++ b/lib/Data/Time/Calendar/Types.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} module Data.Time.Calendar.Types where @@ -6,7 +5,6 @@ module Data.Time.Calendar.Types where -- | Year of Common Era (when positive). type Year = Integer -#ifdef __GLASGOW_HASKELL__ -- | Also known as Anno Domini. pattern CommonEra :: Integer -> Year pattern CommonEra n <- @@ -24,12 +22,10 @@ pattern BeforeCommonEra n <- BeforeCommonEra n = 1 - n {-# COMPLETE CommonEra, BeforeCommonEra #-} -#endif -- | Month of year, in range 1 (January) to 12 (December). type MonthOfYear = Int -#ifdef __GLASGOW_HASKELL__ pattern January :: MonthOfYear pattern January = 1 @@ -68,7 +64,6 @@ pattern December :: MonthOfYear pattern December = 12 {-# COMPLETE January, February, March, April, May, June, July, August, September, October, November, December #-} -#endif -- | Day of month, in range 1 to 31. type DayOfMonth = Int diff --git a/lib/Data/Time/Calendar/WeekDate.hs b/lib/Data/Time/Calendar/WeekDate.hs index d464e427..f69d27b2 100644 --- a/lib/Data/Time/Calendar/WeekDate.hs +++ b/lib/Data/Time/Calendar/WeekDate.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | Week-based calendars @@ -15,9 +14,7 @@ module Data.Time.Calendar.WeekDate ( -- * ISO 8601 Week Date format toWeekDate, fromWeekDate, -#ifdef __GLASGOW_HASKELL__ pattern YearWeekDay, -#endif fromWeekDateValid, showWeekDate, ) where @@ -26,20 +23,14 @@ import Data.Time.Calendar.Days import Data.Time.Calendar.OrdinalDate import Data.Time.Calendar.Private import Data.Time.Calendar.Week -#ifdef __GLASGOW_HASKELL__ import qualified Language.Haskell.TH.Syntax as TH -#endif data FirstWeekType = -- | first week is the first whole week of the year FirstWholeWeek | -- | first week is the first week with four days in the year FirstMostWeek - deriving (Eq -#ifdef __GLASGOW_HASKELL__ - , TH.Lift -#endif - ) + deriving (Eq, TH.Lift) firstDayOfWeekCalendar :: FirstWeekType -> DayOfWeek -> Year -> Day firstDayOfWeekCalendar wt dow year = @@ -129,17 +120,15 @@ toWeekDate d = fromWeekDate :: Year -> WeekOfYear -> Int -> Day fromWeekDate y wy dw = fromWeekCalendar FirstMostWeek Monday y wy (toEnum $ clip 1 7 dw) -#ifdef __GLASGOW_HASKELL__ -- | Bidirectional abstract constructor for ISO 8601 Week Date format. -- Invalid week values will be clipped to the correct range. pattern YearWeekDay :: Year -> WeekOfYear -> DayOfWeek -> Day pattern YearWeekDay y wy dw <- - (toWeekDate -> (y, wy, toEnum -> dw)) + (toWeekDate -> (y, wy, (toEnum -> dw))) where YearWeekDay y wy dw = fromWeekDate y wy (fromEnum dw) {-# COMPLETE YearWeekDay #-} -#endif -- | Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday). -- Invalid week and day values will return Nothing. diff --git a/lib/Data/Time/Clock/Internal/AbsoluteTime.hs b/lib/Data/Time/Clock/Internal/AbsoluteTime.hs index 4d1158d6..0f6991e6 100644 --- a/lib/Data/Time/Clock/Internal/AbsoluteTime.hs +++ b/lib/Data/Time/Clock/Internal/AbsoluteTime.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | TAI and leap-second maps for converting to UTC: most people won't need this module. @@ -15,18 +14,12 @@ import Control.DeepSeq import Data.Data import Data.Time.Calendar.Days import Data.Time.Clock.Internal.DiffTime -#ifdef __GLASGOW_HASKELL__ import qualified Language.Haskell.TH.Syntax as TH -#endif -- | AbsoluteTime is TAI, time as measured by a clock. newtype AbsoluteTime = MkAbsoluteTime DiffTime - deriving (Eq, Ord, Data, Typeable -#ifdef __GLASGOW_HASKELL__ - , TH.Lift -#endif - ) + deriving (Eq, Ord, Data, Typeable, TH.Lift) instance NFData AbsoluteTime where rnf (MkAbsoluteTime a) = rnf a diff --git a/lib/Data/Time/Clock/Internal/DiffTime.hs b/lib/Data/Time/Clock/Internal/DiffTime.hs index 07987601..d22a86cc 100644 --- a/lib/Data/Time/Clock/Internal/DiffTime.hs +++ b/lib/Data/Time/Clock/Internal/DiffTime.hs @@ -17,8 +17,8 @@ import Data.Data import Data.Fixed #ifdef __GLASGOW_HASKELL__ import GHC.Read -import qualified Language.Haskell.TH.Syntax as TH #endif +import qualified Language.Haskell.TH.Syntax as TH import Text.Read import Text.ParserCombinators.ReadP diff --git a/lib/Data/Time/Clock/Internal/NominalDiffTime.hs b/lib/Data/Time/Clock/Internal/NominalDiffTime.hs index ff27eea5..cd273b91 100644 --- a/lib/Data/Time/Clock/Internal/NominalDiffTime.hs +++ b/lib/Data/Time/Clock/Internal/NominalDiffTime.hs @@ -16,8 +16,8 @@ import Data.Data import Data.Fixed #ifdef __GLASGOW_HASKELL__ import GHC.Read -import qualified Language.Haskell.TH.Syntax as TH #endif +import qualified Language.Haskell.TH.Syntax as TH import Text.ParserCombinators.ReadP import Text.ParserCombinators.ReadPrec diff --git a/lib/Data/Time/Clock/System.hs b/lib/Data/Time/Clock/System.hs index de569f7a..c6a47f86 100644 --- a/lib/Data/Time/Clock/System.hs +++ b/lib/Data/Time/Clock/System.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | Fast access to the system clock. @@ -30,10 +29,8 @@ truncateSystemTimeLeapSecond t = t systemToUTCTime :: SystemTime -> UTCTime systemToUTCTime (MkSystemTime seconds nanoseconds) = let -#ifdef __GLASGOW_HASKELL__ days :: Int64 timeSeconds :: Int64 -#endif (days, timeSeconds) = seconds `divMod` 86400 day :: Day day = addDays (fromIntegral days) systemEpochDay @@ -56,10 +53,8 @@ utcToSystemTime (UTCTime day time) = timePicoseconds = fromIntegral $ diffTimeToPicoseconds time timeNanoseconds :: Int64 timeNanoseconds = timePicoseconds `div` 1000 -#ifdef __GLASGOW_HASKELL__ timeSeconds :: Int64 nanoseconds :: Int64 -#endif (timeSeconds, nanoseconds) = if timeNanoseconds >= 86400000000000 then (86399, timeNanoseconds - 86399000000000) diff --git a/lib/Data/Time/Format/Format/Instances.hs b/lib/Data/Time/Format/Format/Instances.hs index 53893a24..9e8cb662 100644 --- a/lib/Data/Time/Format/Format/Instances.hs +++ b/lib/Data/Time/Format/Format/Instances.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} {-# OPTIONS -fno-warn-orphans #-} @@ -112,7 +111,6 @@ instance FormatTime DayOfWeek where formatCharacter _ _ = Nothing instance FormatTime Month where -#ifdef __GLASGOW_HASKELL__ -- Year Count formatCharacter _ 'Y' = Just $ formatNumber False 4 '0' $ \(YearMonth y _) -> y formatCharacter _ 'y' = Just $ formatNumber True 2 '0' $ \(YearMonth y _) -> mod100 y @@ -125,7 +123,6 @@ instance FormatTime Month where formatCharacter _ 'h' = Just $ formatString $ \locale (YearMonth _ my) -> snd $ (months locale) !! (my - 1) formatCharacter _ 'm' = Just $ formatNumber True 2 '0' $ \(YearMonth _ m) -> m -#endif -- Default formatCharacter _ _ = Nothing @@ -135,7 +132,6 @@ instance FormatTime Day where formatCharacter _ 'F' = Just $ formatString $ \locale -> formatTime locale "%Y-%m-%d" formatCharacter _ 'x' = Just $ formatString $ \locale -> formatTime locale (dateFmt locale) -- Day of Month -#ifdef __GLASGOW_HASKELL__ formatCharacter _ 'd' = Just $ formatNumber True 2 '0' $ \(YearMonthDay _ _ dm) -> dm formatCharacter _ 'e' = Just $ formatNumber True 2 ' ' $ \(YearMonthDay _ _ dm) -> dm -- Day of Year @@ -146,7 +142,6 @@ instance FormatTime Day where formatCharacter _ 'f' = Just $ formatNumber False 2 '0' $ \(YearWeekDay y _ _) -> div100 y formatCharacter _ 'V' = Just $ formatNumber True 2 '0' $ \(YearWeekDay _ wy _) -> wy formatCharacter _ 'u' = Just $ formatNumber True 1 '0' $ \(YearWeekDay _ _ dw) -> fromEnum dw -#endif -- Day of week formatCharacter _ 'a' = Just $ formatString $ \locale -> snd . ((wDays locale) !!) . snd . sundayStartWeek formatCharacter _ 'A' = Just $ formatString $ \locale -> fst . ((wDays locale) !!) . snd . sundayStartWeek @@ -154,9 +149,7 @@ instance FormatTime Day where formatCharacter _ 'w' = Just $ formatNumber True 1 '0' $ snd . sundayStartWeek formatCharacter _ 'W' = Just $ formatNumber True 2 '0' $ fst . mondayStartWeek -- Default -#ifdef __GLASGOW_HASKELL__ formatCharacter alt c = mapFormatCharacter (\(MonthDay m _) -> m) $ formatCharacter alt c -#endif instance FormatTime UTCTime where formatCharacter alt c = mapFormatCharacter (utcToZonedTime utc) $ formatCharacter alt c diff --git a/lib/Data/Time/Format/Parse/Instances.hs b/lib/Data/Time/Format/Parse/Instances.hs index 4ae55bd0..9c2b9bdf 100644 --- a/lib/Data/Time/Format/Parse/Instances.hs +++ b/lib/Data/Time/Format/Parse/Instances.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} {-# OPTIONS -fno-warn-orphans #-} @@ -278,7 +277,6 @@ instance ParseTime DayOfWeek where in rest cs -#ifdef __GLASGOW_HASKELL__ dayMonth :: Day -> Month dayMonth (MonthDay m _) = m @@ -296,7 +294,6 @@ instance ParseTime Month where rest (_ : xs) = rest xs rest [] = fromYearMonthValid y 1 rest cs -#endif mfoldl :: Monad m => (a -> b -> m a) -> m a -> [b] -> m a mfoldl f =