From fdd0b201dee163e936bf0c728915b76992be5a23 Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 18:33:40 -0400 Subject: [PATCH 1/8] using stack Signed-off-by: buckie --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 178135c..15e62b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /dist/ +.stack-work/ From eb9c1c6b16fad5bb3228c01c83ba8b43fd56301d Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 20:02:08 -0400 Subject: [PATCH 2/8] updated stack to use ghcjs Signed-off-by: buckie --- stack.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 40c6d39..27a0166 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,18 @@ +resolver: lts-6.19 + +compiler: ghcjs-0.2.0.9006019_ghc-7.10.3 +compiler-check: match-exact +allow-different-user: true + +setup-info: + ghcjs: + source: + ghcjs-0.2.0.9006019_ghc-7.10.3: + url: http://ghcjs.tolysz.org/lts-6.19-9006019.tar.gz + sha1: ef4264d5a93b269ee4ec8f9d5139da030331d65a + flags: {} extra-package-dbs: [] packages: - '.' extra-deps: [] -resolver: lts-5.11 From 988d3ee66b43075153e5e208dc593c45e3cca72b Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 20:07:00 -0400 Subject: [PATCH 3/8] cleaning up cpp needs Signed-off-by: buckie --- include/thyme.h | 8 +------- src/Data/Thyme/Calendar/Internal.hs | 20 ++++++++++---------- src/Data/Thyme/Calendar/WeekdayOfMonth.hs | 2 +- src/Data/Thyme/Clock/Internal.hs | 10 +++++----- src/Data/Thyme/Clock/TAI.hs | 6 +++--- src/Data/Thyme/Internal/Micro.hs | 2 +- src/Data/Thyme/LocalTime.hs | 8 ++++---- 7 files changed, 25 insertions(+), 31 deletions(-) diff --git a/include/thyme.h b/include/thyme.h index ee4449c..b860b4c 100644 --- a/include/thyme.h +++ b/include/thyme.h @@ -1,7 +1 @@ -#define INSTANCES_USUAL Eq, Ord, Data, Typeable, Generic -#define INSTANCES_NEWTYPE INSTANCES_USUAL, Enum, Ix, Hashable, NFData -#define INSTANCES_MICRO INSTANCES_NEWTYPE, Bounded, Random, Arbitrary, CoArbitrary -#define LensP Lens' -#define LENS(S,F,A) {-# INLINE _/**/F #-}; _/**/F :: LensP S A; _/**/F = lens F $ \ S {..} F/**/_ -> S {F = F/**/_, ..} - -#define W_GREGORIAN +#define LENS(S,F,A) {-# INLINE _/**/F #-}; _/**/F :: Lens' S A; _/**/F = lens F $ \ S {..} F/**/_ -> S {F = F/**/_, ..} diff --git a/src/Data/Thyme/Calendar/Internal.hs b/src/Data/Thyme/Calendar/Internal.hs index 3a9f60b..64bc88c 100644 --- a/src/Data/Thyme/Calendar/Internal.hs +++ b/src/Data/Thyme/Calendar/Internal.hs @@ -59,7 +59,7 @@ type Days = Int -- -- (MJD) epoch. -- --- To convert a 'Day' to the corresponding 'YearMonthDay' in the W_GREGORIAN +-- To convert a 'Day' to the corresponding 'YearMonthDay' in the -- calendar, see 'gregorian'. -- -- @ @@ -84,7 +84,7 @@ type Days = Int -- Other ways of viewing a 'Day' include 'ordinalDate', and 'weekDate'. newtype Day = ModifiedJulianDay { toModifiedJulianDay :: Int - } deriving (INSTANCES_NEWTYPE, CoArbitrary) + } deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, CoArbitrary) instance AffineSpace Day where type Diff Day = Days @@ -110,7 +110,7 @@ instance AffineSpace Day where modifiedJulianDay :: Iso' Day Int modifiedJulianDay = iso toModifiedJulianDay ModifiedJulianDay --- | Conversion between a W_GREGORIAN 'OrdinalDate' and the corresponding +-- | Conversion between a 'OrdinalDate' and the corresponding -- 'YearMonthDay'. -- -- @ @@ -204,7 +204,7 @@ data YearMonthDay = YearMonthDay { ymdYear :: {-# UNPACK #-}!Year , ymdMonth :: {-# UNPACK #-}!Month , ymdDay :: {-# UNPACK #-}!DayOfMonth - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(YearMonthDay,ymdYear,Year) LENS(YearMonthDay,ymdMonth,Month) @@ -215,7 +215,7 @@ instance NFData YearMonthDay ------------------------------------------------------------------------ --- | Is it a leap year according to the W_GREGORIAN calendar? +-- | Is it a leap year according to the calendar? isLeapYear :: Year -> Bool isLeapYear y = y .&. 3 == 0 && (r100 /= 0 || q100 .&. 3 == 0) where (q100, r100) = y `quotRem` 100 @@ -228,7 +228,7 @@ type DayOfYear = Int data OrdinalDate = OrdinalDate { odYear :: {-# UNPACK #-}!Year , odDay :: {-# UNPACK #-}!DayOfYear - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(OrdinalDate,odYear,Year) LENS(OrdinalDate,odDay,DayOfYear) @@ -368,7 +368,7 @@ randomIsoR l (x, y) = first (^. l) . randomR (l # x, l # y) data MonthDay = MonthDay { mdMonth :: {-# UNPACK #-}!Month , mdDay :: {-# UNPACK #-}!DayOfMonth - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(MonthDay,mdMonth,Month) LENS(MonthDay,mdDay,DayOfMonth) @@ -512,7 +512,7 @@ data WeekDate = WeekDate -- belong to the previous year. , wdDay :: {-# UNPACK #-}!DayOfWeek -- ^ /1 = Monday/ … /7 = Sunday/. - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(WeekDate,wdYear,Year) LENS(WeekDate,wdWeek,WeekOfYear) @@ -602,7 +602,7 @@ data SundayWeek = SundayWeek -- /Sunday/ of the year as the first day of week /01/. , swDay :: {-# UNPACK #-}!DayOfWeek -- ^ /0 = Sunday/. - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(SundayWeek,swYear,Year) LENS(SundayWeek,swWeek,WeekOfYear) @@ -668,7 +668,7 @@ data MondayWeek = MondayWeek -- /Monday/ of the year as the first day of week /01/. , mwDay :: {-# UNPACK #-}!DayOfWeek -- ^ /7 = Sunday/. - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(MondayWeek,mwYear,Year) LENS(MondayWeek,mwWeek,WeekOfYear) diff --git a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs index 0c56ffa..6b6039f 100644 --- a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs +++ b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs @@ -52,7 +52,7 @@ data WeekdayOfMonth = WeekdayOfMonth -- last 'DayOfWeek' of the month. , womDayOfWeek :: {-# UNPACK #-}!DayOfWeek -- ^ Day of week. /1 = Monday, 7 = Sunday/, like ISO 8601 'WeekDate'. - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) LENS(WeekdayOfMonth,womYear,Year) LENS(WeekdayOfMonth,womMonth,Month) diff --git a/src/Data/Thyme/Clock/Internal.hs b/src/Data/Thyme/Clock/Internal.hs index 82dd339..1c86cac 100644 --- a/src/Data/Thyme/Clock/Internal.hs +++ b/src/Data/Thyme/Clock/Internal.hs @@ -130,7 +130,7 @@ fromSecondsIntegral _ = review microseconds . (*) 1000000 . fromIntegral -- > 'fromSeconds'' 100 '^-^' 'fromSeconds'' 100 '^/' 4 -- 75s -- @ -newtype DiffTime = DiffTime Micro deriving (INSTANCES_MICRO, AdditiveGroup) +newtype DiffTime = DiffTime Micro deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary, AdditiveGroup) derivingUnbox "DiffTime" [t| DiffTime -> Micro |] [| \ (DiffTime a) -> a |] [| DiffTime |] @@ -188,7 +188,7 @@ instance TimeDiff DiffTime where -- @ -- -- See also: 'UTCTime'. -newtype NominalDiffTime = NominalDiffTime Micro deriving (INSTANCES_MICRO, AdditiveGroup) +newtype NominalDiffTime = NominalDiffTime Micro deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary, AdditiveGroup) derivingUnbox "NominalDiffTime" [t| NominalDiffTime -> Micro |] [| \ (NominalDiffTime a) -> a |] [| NominalDiffTime |] @@ -239,7 +239,7 @@ posixDayLength = microseconds # 86400000000 -- -- The difference between UT1 and UTC is -- . -newtype UniversalTime = UniversalRep NominalDiffTime deriving (INSTANCES_MICRO) +newtype UniversalTime = UniversalRep NominalDiffTime deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary) derivingUnbox "UniversalTime" [t| UniversalTime -> NominalDiffTime |] [| \ (UniversalRep a) -> a |] [| UniversalRep |] @@ -313,7 +313,7 @@ pattern UniversalTime mjd <- (view modJulianDate -> mjd) -- If leap seconds matter, use 'Data.Thyme.Clock.TAI.AbsoluteTime' from -- "Data.Thyme.Clock.TAI" instead, along with -- 'Data.Thyme.Clock.TAI.absoluteTime'' and 'UTCView' for presentation. -newtype UTCTime = UTCRep NominalDiffTime deriving (INSTANCES_MICRO) +newtype UTCTime = UTCRep NominalDiffTime deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary) derivingUnbox "UTCTime" [t| UTCTime -> NominalDiffTime |] [| \ (UTCRep a) -> a |] [| UTCRep |] @@ -326,7 +326,7 @@ data UTCView = UTCView -- ^ Calendar date. , utcvDayTime :: {-# UNPACK #-}!DiffTime -- ^ Time elapsed since midnight; /0/ ≤ 'utcvDayTime' < /86401s/. - } deriving (INSTANCES_USUAL, Show) + } deriving (Eq, Ord, Data, Typeable, Generic, Show) -- | 'Lens'' for the calendar 'Day' component of a 'UTCView'. LENS(UTCView,utcvDay,Day) diff --git a/src/Data/Thyme/Clock/TAI.hs b/src/Data/Thyme/Clock/TAI.hs index 336d81d..af6ef4c 100644 --- a/src/Data/Thyme/Clock/TAI.hs +++ b/src/Data/Thyme/Clock/TAI.hs @@ -74,7 +74,7 @@ import Test.QuickCheck -- -- Internally this is the number of seconds since 'taiEpoch'. TAI days are -- exactly 86400 SI seconds long. -newtype AbsoluteTime = AbsoluteTime DiffTime deriving (INSTANCES_MICRO) +newtype AbsoluteTime = AbsoluteTime DiffTime deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary) derivingUnbox "AbsoluteTime" [t| AbsoluteTime -> DiffTime |] [| \ (AbsoluteTime a) -> a |] [| AbsoluteTime |] @@ -107,7 +107,7 @@ instance AffineSpace AbsoluteTime where -- program shipped with such a table could become out-of-date in as little -- as 6 months. See 'parseTAIUTCDAT' for details. data TAIUTCMap = TAIUTCMap (Map UTCTime TAIUTCRow) (Map AbsoluteTime TAIUTCRow) - deriving (INSTANCES_USUAL, Show) + deriving (Eq, Ord, Data, Typeable, Generic, Show) -- | Each line of TAIUTCDAT (see 'parseTAIUTCDAT') specifies the difference -- between TAI and UTC for a particular period. For example: @@ -161,7 +161,7 @@ data TAIUTCMap = TAIUTCMap (Map UTCTime TAIUTCRow) (Map AbsoluteTime TAIUTCRow) data TAIUTCRow = TAIUTCRow !DiffTime !UTCTime !Rational -- ^ Each row comprises of an /additive/ component, the /base/ of the -- scaled component, and the /coefficient/ of the scaled component. - deriving (INSTANCES_USUAL, Show) + deriving (Eq, Ord, Data, Typeable, Generic, Show) {-# INLINE lookupLE #-} lookupLE :: (Ord k) => k -> Map k TAIUTCRow -> TAIUTCRow diff --git a/src/Data/Thyme/Internal/Micro.hs b/src/Data/Thyme/Internal/Micro.hs index 611a16f..f17ce29 100644 --- a/src/Data/Thyme/Internal/Micro.hs +++ b/src/Data/Thyme/Internal/Micro.hs @@ -41,7 +41,7 @@ import Text.ParserCombinators.ReadP import Text.Read #endif -newtype Micro = Micro Int64 deriving (INSTANCES_MICRO) +newtype Micro = Micro Int64 deriving (Eq, Ord, Data, Typeable, Generic, Enum, Ix, Hashable, NFData, Bounded, Random, Arbitrary, CoArbitrary) derivingUnbox "Micro" [t| Micro -> Int64 |] [| \ (Micro a) -> a |] [| Micro |] diff --git a/src/Data/Thyme/LocalTime.hs b/src/Data/Thyme/LocalTime.hs index 941b902..e50d0fa 100644 --- a/src/Data/Thyme/LocalTime.hs +++ b/src/Data/Thyme/LocalTime.hs @@ -71,7 +71,7 @@ data TimeZone = TimeZone -- ^ Is this a summer-only (i.e. daylight savings) time zone? , timeZoneName :: String -- ^ The name of the zone, typically a three- or four-letter acronym. - } deriving (INSTANCES_USUAL) + } deriving (Eq, Ord, Data, Typeable, Generic) LENS(TimeZone,timeZoneMinutes,Minutes) LENS(TimeZone,timeZoneSummerOnly,Bool) @@ -184,7 +184,7 @@ data TimeOfDay = TimeOfDay { todHour :: {-# UNPACK #-}!Hour , todMin :: {-# UNPACK #-}!Minute , todSec :: {-# UNPACK #-}!DiffTime -- ^ Second. - } deriving (INSTANCES_USUAL) + } deriving (Eq, Ord, Data, Typeable, Generic) LENS(TimeOfDay,todHour,Hour) LENS(TimeOfDay,todMin,Minute) @@ -353,7 +353,7 @@ data LocalTime = LocalTime -- ^ Local calendar date. , localTimeOfDay :: {-only 3 words…-} {-# UNPACK #-}!TimeOfDay -- ^ Local time-of-day. - } deriving (INSTANCES_USUAL) + } deriving (Eq, Ord, Data, Typeable, Generic) LENS(LocalTime,localDay,Day) LENS(LocalTime,localTimeOfDay,TimeOfDay) @@ -461,7 +461,7 @@ ut1LocalTime long = iso localise globalise where data ZonedTime = ZonedTime { zonedTimeToLocalTime :: {-only 4 words…-} {-# UNPACK #-}!LocalTime , zonedTimeZone :: !TimeZone - } deriving (INSTANCES_USUAL) + } deriving (Eq, Ord, Data, Typeable, Generic) LENS(ZonedTime,zonedTimeToLocalTime,LocalTime) LENS(ZonedTime,zonedTimeZone,TimeZone) From 50f8b14da4cbeb92ecd1d223c02174f7c65b8148 Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 20:42:07 -0400 Subject: [PATCH 4/8] removed cpp defs because they break ghcjs and are unneccessary Signed-off-by: buckie --- include/thyme.h | 1 - src/Data/Thyme/Calendar/Internal.hs | 39 +++++++++++--------- src/Data/Thyme/Calendar/WeekdayOfMonth.hs | 11 +++--- src/Data/Thyme/Clock/Internal.hs | 9 +++-- src/Data/Thyme/Format.hs | 44 ++++++++++++++--------- src/Data/Thyme/Format/Human.hs | 5 ++- src/Data/Thyme/LocalTime.hs | 26 +++++++------- thyme.cabal | 4 --- 8 files changed, 75 insertions(+), 64 deletions(-) delete mode 100644 include/thyme.h diff --git a/include/thyme.h b/include/thyme.h deleted file mode 100644 index b860b4c..0000000 --- a/include/thyme.h +++ /dev/null @@ -1 +0,0 @@ -#define LENS(S,F,A) {-# INLINE _/**/F #-}; _/**/F :: Lens' S A; _/**/F = lens F $ \ S {..} F/**/_ -> S {F = F/**/_, ..} diff --git a/src/Data/Thyme/Calendar/Internal.hs b/src/Data/Thyme/Calendar/Internal.hs index 64bc88c..2eb3836 100644 --- a/src/Data/Thyme/Calendar/Internal.hs +++ b/src/Data/Thyme/Calendar/Internal.hs @@ -206,9 +206,10 @@ data YearMonthDay = YearMonthDay , ymdDay :: {-# UNPACK #-}!DayOfMonth } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(YearMonthDay,ymdYear,Year) -LENS(YearMonthDay,ymdMonth,Month) -LENS(YearMonthDay,ymdDay,DayOfMonth) +makeLensesFor [("ymdYear","_ymdYear"),("ymdMonth","_ymdMonth"),("ymdDay","_ymdDay")] ''YearMonthDay +{-# INLINE _ymdYear #-} +{-# INLINE _ymdMonth #-} +{-# INLINE _ymdDay #-} instance Hashable YearMonthDay instance NFData YearMonthDay @@ -230,8 +231,9 @@ data OrdinalDate = OrdinalDate , odDay :: {-# UNPACK #-}!DayOfYear } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(OrdinalDate,odYear,Year) -LENS(OrdinalDate,odDay,DayOfYear) +makeLensesFor [("odYear","_odYear"),("odDay","_odDay")] ''OrdinalDate +{-# INLINE _odYear #-} +{-# INLINE _odDay #-} instance Hashable OrdinalDate instance NFData OrdinalDate @@ -370,8 +372,9 @@ data MonthDay = MonthDay , mdDay :: {-# UNPACK #-}!DayOfMonth } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(MonthDay,mdMonth,Month) -LENS(MonthDay,mdDay,DayOfMonth) +makeLensesFor [("mdMonth","_mdMonth"),("mdDay","_mdDay")] ''MonthDay +{-# INLINE _mdMonth #-} +{-# INLINE _mdDay #-} instance Hashable MonthDay instance NFData MonthDay @@ -514,9 +517,10 @@ data WeekDate = WeekDate -- ^ /1 = Monday/ … /7 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(WeekDate,wdYear,Year) -LENS(WeekDate,wdWeek,WeekOfYear) -LENS(WeekDate,wdDay,DayOfWeek) +makeLensesFor [("wdYear","_wdYear"),("wdWeek","_wdWeek"),("wdDay","_wdDay")] ''WeekDate +{-# INLINE _wdYear #-} +{-# INLINE _wdWeek #-} +{-# INLINE _wdDay #-} instance Hashable WeekDate instance NFData WeekDate @@ -604,9 +608,10 @@ data SundayWeek = SundayWeek -- ^ /0 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(SundayWeek,swYear,Year) -LENS(SundayWeek,swWeek,WeekOfYear) -LENS(SundayWeek,swDay,DayOfWeek) +makeLensesFor [("swYear","_swYear"),("swWeek","_swWeek"),("swDay","_swDay")] ''SundayWeek +{-# INLINE _swYear #-} +{-# INLINE _swWeek #-} +{-# INLINE _swDay #-} instance Hashable SundayWeek instance NFData SundayWeek @@ -670,9 +675,10 @@ data MondayWeek = MondayWeek -- ^ /7 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(MondayWeek,mwYear,Year) -LENS(MondayWeek,mwWeek,WeekOfYear) -LENS(MondayWeek,mwDay,DayOfWeek) +makeLensesFor [("mwYear","_mwYear"),("mwWeek","_mwWeek"),("mwDay","_mwDay")] ''MondayWeek +{-# INLINE _mwYear #-} +{-# INLINE _mwWeek #-} +{-# INLINE _mwDay #-} instance Hashable MondayWeek instance NFData MondayWeek @@ -747,4 +753,3 @@ derivingUnbox "SundayWeek" [t| SundayWeek -> Int |] derivingUnbox "MondayWeek" [t| MondayWeek -> Int |] [| \ MondayWeek {..} -> shiftL mwYear 9 .|. shiftL mwWeek 3 .|. mwDay |] [| \ n -> MondayWeek (shiftR n 9) (shiftR n 3 .&. 0x3f) (n .&. 0x7) |] - diff --git a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs index 6b6039f..53b0256 100644 --- a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs +++ b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs @@ -7,7 +7,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} -#include "thyme.h" #if HLINT #include "cabal_macros.h" #endif @@ -54,10 +53,11 @@ data WeekdayOfMonth = WeekdayOfMonth -- ^ Day of week. /1 = Monday, 7 = Sunday/, like ISO 8601 'WeekDate'. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -LENS(WeekdayOfMonth,womYear,Year) -LENS(WeekdayOfMonth,womMonth,Month) -LENS(WeekdayOfMonth,womNth,Int) -LENS(WeekdayOfMonth,womDayOfWeek,DayOfWeek) +makeLensesFor [("womYear","_womYear"),("womMonth","_womMonth"),("womNth","_womNth"),("womDayOfWeek","_womDayOfWeek")] ''WeekdayOfMonth +{-# INLINE _womYear #-} +{-# INLINE _womMonth #-} +{-# INLINE _womNth #-} +{-# INLINE _womDayOfWeek #-} derivingUnbox "WeekdayOfMonth" [t| WeekdayOfMonth -> Int |] @@ -145,4 +145,3 @@ weekdayOfMonthValid (WeekdayOfMonth y m n wd) = (refDay .+^ s * offset) s = signum n wo = s * (wd - wd1) offset = (abs n - 1) * 7 + if wo < 0 then wo + 7 else wo - diff --git a/src/Data/Thyme/Clock/Internal.hs b/src/Data/Thyme/Clock/Internal.hs index 1c86cac..4670760 100644 --- a/src/Data/Thyme/Clock/Internal.hs +++ b/src/Data/Thyme/Clock/Internal.hs @@ -14,8 +14,6 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_HADDOCK hide #-} -#include "thyme.h" - module Data.Thyme.Clock.Internal where import Prelude @@ -329,10 +327,12 @@ data UTCView = UTCView } deriving (Eq, Ord, Data, Typeable, Generic, Show) -- | 'Lens'' for the calendar 'Day' component of a 'UTCView'. -LENS(UTCView,utcvDay,Day) +makeLensesFor [("utcvDay","_utcvDay")] ''UTCView +{-# INLINE _utcvDay #-} -- | 'Lens'' for the time-of-day 'DiffTime' component of a 'UTCView'. -LENS(UTCView,utcvDayTime,DiffTime) +makeLensesFor [("utcvDayTime","_utcvDayTime")] ''UTCView +{-# INLINE _utcvDayTime #-} derivingUnbox "UTCView" [t| UTCView -> (Day, DiffTime) |] [| \ UTCView {..} -> (utcvDay, utcvDayTime) |] @@ -431,4 +431,3 @@ mkUTCTime :: Year -> Month -> DayOfMonth -> Hour -> Minute -> Double -> UTCTime mkUTCTime yy mm dd h m s = utcTime # UTCView (gregorian # YearMonthDay yy mm dd) (fromSeconds (3600 * h + 60 * m) ^+^ fromSeconds s) - diff --git a/src/Data/Thyme/Format.hs b/src/Data/Thyme/Format.hs index 207dee9..24f2e5a 100644 --- a/src/Data/Thyme/Format.hs +++ b/src/Data/Thyme/Format.hs @@ -4,7 +4,6 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -#include "thyme.h" -- | Formatting and parsing for dates and times. module Data.Thyme.Format @@ -486,20 +485,34 @@ data TimeParse = TimeParse , tpTimeZone :: !TimeZone } deriving (Show) -LENS(TimeParse,tpCentury,Int) -LENS(TimeParse,tpCenturyYear,Int{-YearOfCentury-}) -LENS(TimeParse,tpMonth,Month) -LENS(TimeParse,tpWeekOfYear,WeekOfYear) -LENS(TimeParse,tpDayOfMonth,DayOfMonth) -LENS(TimeParse,tpDayOfWeek,DayOfWeek) -LENS(TimeParse,tpDayOfYear,DayOfYear) -LENS(TimeParse,tpFlags,Int{-BitSet TimeFlag-}) -LENS(TimeParse,tpHour,Hour) -LENS(TimeParse,tpMinute,Minute) -LENS(TimeParse,tpSecond,Int) -LENS(TimeParse,tpSecFrac,DiffTime) -LENS(TimeParse,tpPOSIXTime,POSIXTime) -LENS(TimeParse,tpTimeZone,TimeZone) +makeLensesFor [ ("tpCentury","_tpCentury") + , ("tpCenturyYear","_tpCenturyYear") + , ("tpMonth","_tpMonth") + , ("tpWeekOfYear","_tpWeekOfYear") + , ("tpDayOfMonth","_tpDayOfMonth") + , ("tpDayOfWeek","_tpDayOfWeek") + , ("tpDayOfYear","_tpDayOfYear") + , ("tpFlags","_tpFlags") + , ("tpHour","_tpHour") + , ("tpMinute","_tpMinute") + , ("tpSecond","_tpSecond") + , ("tpSecFrac","_tpSecFrac") + , ("tpPOSIXTime","_tpPOSIXTime") + , ("tpTimeZone","_tpTimeZone")] ''TimeParse +{-# INLINE _tpCentury #-} +{-# INLINE _tpCenturyYear #-} +{-# INLINE _tpMonth #-} +{-# INLINE _tpWeekOfYear #-} +{-# INLINE _tpDayOfMonth #-} +{-# INLINE _tpDayOfWeek #-} +{-# INLINE _tpDayOfYear #-} +{-# INLINE _tpFlags #-} +{-# INLINE _tpHour #-} +{-# INLINE _tpMinute #-} +{-# INLINE _tpSecond #-} +{-# INLINE _tpSecFrac #-} +{-# INLINE _tpPOSIXTime #-} +{-# INLINE _tpTimeZone #-} {-# INLINE flag #-} flag :: TimeFlag -> Lens' TimeParse Bool @@ -985,4 +998,3 @@ timeZoneParser = zone "TAI" 0 False <|> zone "UT1" 0 False zone name offset dst = TimeZone offset dst name <$ P.string (S.pack name) ($+) h m = h * 60 + m ($-) h m = negate (h * 60 + m) - diff --git a/src/Data/Thyme/Format/Human.hs b/src/Data/Thyme/Format/Human.hs index 9147460..706c062 100644 --- a/src/Data/Thyme/Format/Human.hs +++ b/src/Data/Thyme/Format/Human.hs @@ -3,7 +3,6 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} -#include "thyme.h" #if HLINT #include "cabal_macros.h" #endif @@ -36,7 +35,8 @@ data Unit = Unit , single :: ShowS , plural :: ShowS } -LENS(Unit,plural,ShowS) +makeLensesFor [("plural","_plural")] ''Unit +{-# INLINE _plural #-} -- | Display 'DiffTime' or 'NominalDiffTime' in a human-readable form. {-# INLINE humanTimeDiff #-} @@ -91,4 +91,3 @@ units = scanl (&) times :: String -> Rational -> Unit -> Unit times ((++) . (:) ' ' -> single) r Unit {unit} = Unit {unit = r *^ unit, plural = single . (:) 's', ..} - diff --git a/src/Data/Thyme/LocalTime.hs b/src/Data/Thyme/LocalTime.hs index e50d0fa..36510c8 100644 --- a/src/Data/Thyme/LocalTime.hs +++ b/src/Data/Thyme/LocalTime.hs @@ -10,7 +10,6 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -#include "thyme.h" #if HLINT #include "cabal_macros.h" #endif @@ -73,9 +72,10 @@ data TimeZone = TimeZone -- ^ The name of the zone, typically a three- or four-letter acronym. } deriving (Eq, Ord, Data, Typeable, Generic) -LENS(TimeZone,timeZoneMinutes,Minutes) -LENS(TimeZone,timeZoneSummerOnly,Bool) -LENS(TimeZone,timeZoneName,String) +makeLensesFor [("timeZoneMinutes","_timeZoneMinutes"),("timeZoneSummerOnly","_timeZoneSummerOnly"),("timeZoneName","_timeZoneName")] ''TimeZone +{-# INLINE _timeZoneMinutes #-} +{-# INLINE _timeZoneSummerOnly #-} +{-# INLINE _timeZoneName #-} instance Hashable TimeZone instance NFData TimeZone @@ -186,9 +186,10 @@ data TimeOfDay = TimeOfDay , todSec :: {-# UNPACK #-}!DiffTime -- ^ Second. } deriving (Eq, Ord, Data, Typeable, Generic) -LENS(TimeOfDay,todHour,Hour) -LENS(TimeOfDay,todMin,Minute) -LENS(TimeOfDay,todSec,DiffTime) +makeLensesFor [("todHour","_todHour"),("todMin","_todMin"),("todSec","_todSec")] ''TimeOfDay +{-# INLINE _todHour #-} +{-# INLINE _todMin #-} +{-# INLINE _todSec #-} derivingUnbox "TimeOfDay" [t| TimeOfDay -> Int64 |] [| \ TimeOfDay {..} -> fromIntegral (todHour .|. shiftL todMin 8) @@ -355,8 +356,9 @@ data LocalTime = LocalTime -- ^ Local time-of-day. } deriving (Eq, Ord, Data, Typeable, Generic) -LENS(LocalTime,localDay,Day) -LENS(LocalTime,localTimeOfDay,TimeOfDay) +makeLensesFor [("localDay","_localDay"),("localTimeOfDay","_localTimeOfDay")] ''LocalTime +{-# INLINE _localDay #-} +{-# INLINE _localTimeOfDay #-} derivingUnbox "LocalTime" [t| LocalTime -> (Day, TimeOfDay) |] [| \ LocalTime {..} -> (localDay, localTimeOfDay) |] @@ -463,8 +465,9 @@ data ZonedTime = ZonedTime , zonedTimeZone :: !TimeZone } deriving (Eq, Ord, Data, Typeable, Generic) -LENS(ZonedTime,zonedTimeToLocalTime,LocalTime) -LENS(ZonedTime,zonedTimeZone,TimeZone) +makeLensesFor [("zonedTimeToLocalTime","_zonedTimeToLocalTime"),("zonedTimeZone","_zonedTimeZone")] ''ZonedTime +{-# INLINE _zonedTimeToLocalTime #-} +{-# INLINE _zonedTimeZone #-} instance Hashable ZonedTime instance NFData ZonedTime where @@ -668,4 +671,3 @@ utcToZonedTime z t = view zonedTime (z, t) {-# INLINE zonedTimeToUTC #-} zonedTimeToUTC :: ZonedTime -> UTCTime zonedTimeToUTC = snd . review zonedTime - diff --git a/thyme.cabal b/thyme.cabal index e12ee98..bbc7899 100644 --- a/thyme.cabal +++ b/thyme.cabal @@ -17,8 +17,6 @@ category: Data, System build-type: Simple cabal-version: >= 1.10 stability: experimental -extra-source-files: - include/thyme.h tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 7.10.3, @@ -55,7 +53,6 @@ flag show-internal library default-language: Haskell2010 - include-dirs: include hs-source-dirs: src if !(flag(lens) || flag(docs)) hs-source-dirs: lens @@ -195,4 +192,3 @@ benchmark bench ghc-options: -Wall -- vim: et sw=4 ts=4 sts=4: - From 41baf2cd2813182dbd2a4a87ee9dca722188b8b2 Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 20:44:31 -0400 Subject: [PATCH 5/8] purged thyme.h imports from other files Signed-off-by: buckie --- src/Data/Thyme/Calendar.hs | 2 +- src/Data/Thyme/Calendar/Internal.hs | 2 +- src/Data/Thyme/Calendar/MonthDay.hs | 2 +- src/Data/Thyme/Calendar/OrdinalDate.hs | 2 +- src/Data/Thyme/Calendar/WeekDate.hs | 2 +- src/Data/Thyme/Clock/TAI.hs | 2 +- src/Data/Thyme/Internal/Micro.hs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Data/Thyme/Calendar.hs b/src/Data/Thyme/Calendar.hs index 5d4793a..536c63e 100644 --- a/src/Data/Thyme/Calendar.hs +++ b/src/Data/Thyme/Calendar.hs @@ -3,7 +3,7 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -#include "thyme.h" + #if HLINT #include "cabal_macros.h" #endif diff --git a/src/Data/Thyme/Calendar/Internal.hs b/src/Data/Thyme/Calendar/Internal.hs index 2eb3836..6889a32 100644 --- a/src/Data/Thyme/Calendar/Internal.hs +++ b/src/Data/Thyme/Calendar/Internal.hs @@ -13,7 +13,7 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_HADDOCK hide #-} -#include "thyme.h" + #if HLINT #include "cabal_macros.h" #endif diff --git a/src/Data/Thyme/Calendar/MonthDay.hs b/src/Data/Thyme/Calendar/MonthDay.hs index e60893d..8cd5877 100644 --- a/src/Data/Thyme/Calendar/MonthDay.hs +++ b/src/Data/Thyme/Calendar/MonthDay.hs @@ -2,7 +2,7 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} -#include "thyme.h" + -- | Calendar months and day-of-months. module Data.Thyme.Calendar.MonthDay diff --git a/src/Data/Thyme/Calendar/OrdinalDate.hs b/src/Data/Thyme/Calendar/OrdinalDate.hs index e467d6e..59bc932 100644 --- a/src/Data/Thyme/Calendar/OrdinalDate.hs +++ b/src/Data/Thyme/Calendar/OrdinalDate.hs @@ -3,7 +3,7 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -#include "thyme.h" + #if HLINT #include "cabal_macros.h" #endif diff --git a/src/Data/Thyme/Calendar/WeekDate.hs b/src/Data/Thyme/Calendar/WeekDate.hs index fcc8ea1..5697826 100644 --- a/src/Data/Thyme/Calendar/WeekDate.hs +++ b/src/Data/Thyme/Calendar/WeekDate.hs @@ -6,7 +6,7 @@ {-# OPTIONS_GHC -fsimpl-tick-factor=120 #-} -- 7.6.3 only, it seems; fixes #29 #endif -#include "thyme.h" + #if HLINT #include "cabal_macros.h" #endif diff --git a/src/Data/Thyme/Clock/TAI.hs b/src/Data/Thyme/Clock/TAI.hs index af6ef4c..5867c37 100644 --- a/src/Data/Thyme/Clock/TAI.hs +++ b/src/Data/Thyme/Clock/TAI.hs @@ -9,7 +9,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} -#include "thyme.h" + #if HLINT #include "cabal_macros.h" #endif diff --git a/src/Data/Thyme/Internal/Micro.hs b/src/Data/Thyme/Internal/Micro.hs index f17ce29..7d10f77 100644 --- a/src/Data/Thyme/Internal/Micro.hs +++ b/src/Data/Thyme/Internal/Micro.hs @@ -7,7 +7,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} -#include "thyme.h" + -- | FOR INTERNAL USE ONLY. module Data.Thyme.Internal.Micro where From e9bd168313c51098afb9bd621b89001add0369c7 Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 21:12:46 -0400 Subject: [PATCH 6/8] made a ghcjs buildable version Signed-off-by: buckie --- lens/Control/Lens.hs | 156 ---------------------- src/Data/Thyme/Calendar/Internal.hs | 41 ++---- src/Data/Thyme/Calendar/WeekdayOfMonth.hs | 8 +- src/Data/Thyme/Clock/Internal.hs | 2 - src/Data/Thyme/Format.hs | 15 +-- src/Data/Thyme/Format/Human.hs | 2 +- src/Data/Thyme/LocalTime.hs | 10 -- stack.yaml | 14 +- thyme.cabal | 41 +----- 9 files changed, 23 insertions(+), 266 deletions(-) delete mode 100644 lens/Control/Lens.hs diff --git a/lens/Control/Lens.hs b/lens/Control/Lens.hs deleted file mode 100644 index e5035fe..0000000 --- a/lens/Control/Lens.hs +++ /dev/null @@ -1,156 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveFunctor #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} - -#if HLINT -#include "cabal_macros.h" -#endif - --- | Small replacement for . -module Control.Lens - ( (&) - , Iso, Iso', iso - , from - , review, ( # ) - , Lens, Lens', lens - , view, (^.) - , set, over, (%~), assign, (.=) - ) where - -import Control.Applicative -import Control.Monad.Identity -import Control.Monad.State.Class as State -import Data.Profunctor -import Data.Profunctor.Unsafe -#if __GLASGOW_HASKELL__ >= 708 && MIN_VERSION_profunctors(4,4,0) -import Data.Coerce -#else -import Unsafe.Coerce -#endif - -infixl 1 & -(&) :: a -> (a -> b) -> b -a & f = f a -{-# INLINE (&) #-} - -type Overloaded p f s t a b = p a (f b) -> p s (f t) - ------------------------------------------------------------------------- - -type Iso s t a b = forall p f. (Profunctor p, Functor f) => Overloaded p f s t a b -type Iso' s a = Iso s s a a - -iso :: (s -> a) -> (b -> t) -> Iso s t a b -iso sa bt = dimap sa (fmap bt) -{-# INLINE iso #-} - ------------------------------------------------------------------------- - -data Exchange a b s t = Exchange (s -> a) (b -> t) - -instance Profunctor (Exchange a b) where - dimap f g (Exchange sa bt) = Exchange (sa . f) (g . bt) - {-# INLINE dimap #-} - lmap f (Exchange sa bt) = Exchange (sa . f) bt - {-# INLINE lmap #-} - rmap f (Exchange sa bt) = Exchange sa (f . bt) - {-# INLINE rmap #-} -#if __GLASGOW_HASKELL__ >= 708 && MIN_VERSION_profunctors(4,4,0) - ( #. ) _ = coerce (id :: t -> t) :: forall t u. Coercible t u => u -> t - ( .# ) p _ = coerce p -#else - ( #. ) _ = unsafeCoerce - ( .# ) p _ = unsafeCoerce p -#endif - {-# INLINE ( #. ) #-} - {-# INLINE ( .# ) #-} - -type AnIso s t a b = Overloaded (Exchange a b) Identity s t a b - -from :: AnIso s t a b -> Iso b a t s -from l = case l (Exchange id Identity) of - Exchange sa bt -> iso (runIdentity #. bt) sa -{-# INLINE from #-} - ------------------------------------------------------------------------- - -newtype Reviewed a b = Reviewed - { runReviewed :: b - } deriving (Functor) - -instance Profunctor Reviewed where - dimap _ f (Reviewed c) = Reviewed (f c) - {-# INLINE dimap #-} - lmap _ (Reviewed c) = Reviewed c - {-# INLINE lmap #-} - rmap = fmap - {-# INLINE rmap #-} - Reviewed b .# _ = Reviewed b - {-# INLINE ( .# ) #-} -#if __GLASGOW_HASKELL__ >= 708 && MIN_VERSION_profunctors(4,4,0) - ( #. ) _ = coerce (id :: t -> t) :: forall t u. Coercible t u => u -> t -#else - ( #. ) _ = unsafeCoerce -#endif - {-# INLINE ( #. ) #-} - -type AReview s t a b = Overloaded Reviewed Identity s t a b - -review :: AReview s t a b -> b -> t -review p = runIdentity #. runReviewed #. p .# Reviewed .# Identity -{-# INLINE review #-} - -infixr 8 # -( # ) :: AReview s t a b -> b -> t -( # ) = review -{-# INLINE ( # ) #-} - ------------------------------------------------------------------------- - -type Lens s t a b = forall f. Functor f => Overloaded (->) f s t a b -type Lens' s a = Lens s s a a - -lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b -lens sa sbt afb s = sbt s <$> afb (sa s) -{-# INLINE lens #-} - ------------------------------------------------------------------------- - -type Getting r s a = Overloaded (->) (Const r) s s a a - -view :: Getting a s a -> s -> a -view l s = getConst (l Const s) -{-# INLINE view #-} - -infixl 8 ^. -(^.) :: s -> Getting a s a -> a -(^.) = flip view -{-# INLINE (^.) #-} - ------------------------------------------------------------------------- - -type Setter s t a b = Overloaded (->) Identity s t a b - -set :: Setter s t a b -> b -> s -> t -set l b = runIdentity #. l (\ _ -> Identity b) -{-# INLINE set #-} - -over :: Setter s t a b -> (a -> b) -> s -> t -over l f = runIdentity #. l (Identity #. f) -{-# INLINE over #-} - -infixr 4 %~ -(%~) :: Setter s t a b -> (a -> b) -> s -> t -(%~) = over -{-# INLINE (%~) #-} - -assign :: (MonadState s m) => Setter s s a b -> b -> m () -assign l b = State.modify (set l b) -{-# INLINE assign #-} - -infix 4 .= -(.=) :: (MonadState s m) => Setter s s a b -> b -> m () -(.=) = assign -{-# INLINE (.=) #-} - diff --git a/src/Data/Thyme/Calendar/Internal.hs b/src/Data/Thyme/Calendar/Internal.hs index 6889a32..5203caf 100644 --- a/src/Data/Thyme/Calendar/Internal.hs +++ b/src/Data/Thyme/Calendar/Internal.hs @@ -13,7 +13,6 @@ {-# LANGUAGE ViewPatterns #-} {-# OPTIONS_HADDOCK hide #-} - #if HLINT #include "cabal_macros.h" #endif @@ -206,11 +205,6 @@ data YearMonthDay = YearMonthDay , ymdDay :: {-# UNPACK #-}!DayOfMonth } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("ymdYear","_ymdYear"),("ymdMonth","_ymdMonth"),("ymdDay","_ymdDay")] ''YearMonthDay -{-# INLINE _ymdYear #-} -{-# INLINE _ymdMonth #-} -{-# INLINE _ymdDay #-} - instance Hashable YearMonthDay instance NFData YearMonthDay @@ -231,10 +225,6 @@ data OrdinalDate = OrdinalDate , odDay :: {-# UNPACK #-}!DayOfYear } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("odYear","_odYear"),("odDay","_odDay")] ''OrdinalDate -{-# INLINE _odYear #-} -{-# INLINE _odDay #-} - instance Hashable OrdinalDate instance NFData OrdinalDate @@ -372,10 +362,6 @@ data MonthDay = MonthDay , mdDay :: {-# UNPACK #-}!DayOfMonth } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("mdMonth","_mdMonth"),("mdDay","_mdDay")] ''MonthDay -{-# INLINE _mdMonth #-} -{-# INLINE _mdDay #-} - instance Hashable MonthDay instance NFData MonthDay @@ -517,11 +503,6 @@ data WeekDate = WeekDate -- ^ /1 = Monday/ … /7 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("wdYear","_wdYear"),("wdWeek","_wdWeek"),("wdDay","_wdDay")] ''WeekDate -{-# INLINE _wdYear #-} -{-# INLINE _wdWeek #-} -{-# INLINE _wdDay #-} - instance Hashable WeekDate instance NFData WeekDate @@ -608,11 +589,6 @@ data SundayWeek = SundayWeek -- ^ /0 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("swYear","_swYear"),("swWeek","_swWeek"),("swDay","_swDay")] ''SundayWeek -{-# INLINE _swYear #-} -{-# INLINE _swWeek #-} -{-# INLINE _swDay #-} - instance Hashable SundayWeek instance NFData SundayWeek @@ -675,11 +651,6 @@ data MondayWeek = MondayWeek -- ^ /7 = Sunday/. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("mwYear","_mwYear"),("mwWeek","_mwWeek"),("mwDay","_mwDay")] ''MondayWeek -{-# INLINE _mwYear #-} -{-# INLINE _mwWeek #-} -{-# INLINE _mwDay #-} - instance Hashable MondayWeek instance NFData MondayWeek @@ -753,3 +724,15 @@ derivingUnbox "SundayWeek" [t| SundayWeek -> Int |] derivingUnbox "MondayWeek" [t| MondayWeek -> Int |] [| \ MondayWeek {..} -> shiftL mwYear 9 .|. shiftL mwWeek 3 .|. mwDay |] [| \ n -> MondayWeek (shiftR n 9) (shiftR n 3 .&. 0x3f) (n .&. 0x7) |] + +makeLensesFor [("ymdYear","_ymdYear"),("ymdMonth","_ymdMonth"),("ymdDay","_ymdDay")] ''YearMonthDay + +makeLensesFor [("odYear","_odYear"),("odDay","_odDay")] ''OrdinalDate + +makeLensesFor [("mdMonth","_mdMonth"),("mdDay","_mdDay")] ''MonthDay + +makeLensesFor [("wdYear","_wdYear"),("wdWeek","_wdWeek"),("wdDay","_wdDay")] ''WeekDate + +makeLensesFor [("swYear","_swYear"),("swWeek","_swWeek"),("swDay","_swDay")] ''SundayWeek + +makeLensesFor [("mwYear","_mwYear"),("mwWeek","_mwWeek"),("mwDay","_mwDay")] ''MondayWeek diff --git a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs index 53b0256..c0578b6 100644 --- a/src/Data/Thyme/Calendar/WeekdayOfMonth.hs +++ b/src/Data/Thyme/Calendar/WeekdayOfMonth.hs @@ -53,12 +53,6 @@ data WeekdayOfMonth = WeekdayOfMonth -- ^ Day of week. /1 = Monday, 7 = Sunday/, like ISO 8601 'WeekDate'. } deriving (Eq, Ord, Data, Typeable, Generic, Show) -makeLensesFor [("womYear","_womYear"),("womMonth","_womMonth"),("womNth","_womNth"),("womDayOfWeek","_womDayOfWeek")] ''WeekdayOfMonth -{-# INLINE _womYear #-} -{-# INLINE _womMonth #-} -{-# INLINE _womNth #-} -{-# INLINE _womDayOfWeek #-} - derivingUnbox "WeekdayOfMonth" [t| WeekdayOfMonth -> Int |] [| \ WeekdayOfMonth {..} -> shiftL womYear 11 .|. shiftL womMonth 7 @@ -145,3 +139,5 @@ weekdayOfMonthValid (WeekdayOfMonth y m n wd) = (refDay .+^ s * offset) s = signum n wo = s * (wd - wd1) offset = (abs n - 1) * 7 + if wo < 0 then wo + 7 else wo + +makeLensesFor [("womYear","_womYear"),("womMonth","_womMonth"),("womNth","_womNth"),("womDayOfWeek","_womDayOfWeek")] ''WeekdayOfMonth diff --git a/src/Data/Thyme/Clock/Internal.hs b/src/Data/Thyme/Clock/Internal.hs index 4670760..64a8c2a 100644 --- a/src/Data/Thyme/Clock/Internal.hs +++ b/src/Data/Thyme/Clock/Internal.hs @@ -328,11 +328,9 @@ data UTCView = UTCView -- | 'Lens'' for the calendar 'Day' component of a 'UTCView'. makeLensesFor [("utcvDay","_utcvDay")] ''UTCView -{-# INLINE _utcvDay #-} -- | 'Lens'' for the time-of-day 'DiffTime' component of a 'UTCView'. makeLensesFor [("utcvDayTime","_utcvDayTime")] ''UTCView -{-# INLINE _utcvDayTime #-} derivingUnbox "UTCView" [t| UTCView -> (Day, DiffTime) |] [| \ UTCView {..} -> (utcvDay, utcvDayTime) |] diff --git a/src/Data/Thyme/Format.hs b/src/Data/Thyme/Format.hs index 24f2e5a..62bdab7 100644 --- a/src/Data/Thyme/Format.hs +++ b/src/Data/Thyme/Format.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} @@ -499,20 +500,6 @@ makeLensesFor [ ("tpCentury","_tpCentury") , ("tpSecFrac","_tpSecFrac") , ("tpPOSIXTime","_tpPOSIXTime") , ("tpTimeZone","_tpTimeZone")] ''TimeParse -{-# INLINE _tpCentury #-} -{-# INLINE _tpCenturyYear #-} -{-# INLINE _tpMonth #-} -{-# INLINE _tpWeekOfYear #-} -{-# INLINE _tpDayOfMonth #-} -{-# INLINE _tpDayOfWeek #-} -{-# INLINE _tpDayOfYear #-} -{-# INLINE _tpFlags #-} -{-# INLINE _tpHour #-} -{-# INLINE _tpMinute #-} -{-# INLINE _tpSecond #-} -{-# INLINE _tpSecFrac #-} -{-# INLINE _tpPOSIXTime #-} -{-# INLINE _tpTimeZone #-} {-# INLINE flag #-} flag :: TimeFlag -> Lens' TimeParse Bool diff --git a/src/Data/Thyme/Format/Human.hs b/src/Data/Thyme/Format/Human.hs index 706c062..c50109a 100644 --- a/src/Data/Thyme/Format/Human.hs +++ b/src/Data/Thyme/Format/Human.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RecordWildCards #-} @@ -36,7 +37,6 @@ data Unit = Unit , plural :: ShowS } makeLensesFor [("plural","_plural")] ''Unit -{-# INLINE _plural #-} -- | Display 'DiffTime' or 'NominalDiffTime' in a human-readable form. {-# INLINE humanTimeDiff #-} diff --git a/src/Data/Thyme/LocalTime.hs b/src/Data/Thyme/LocalTime.hs index 36510c8..ce0fdaa 100644 --- a/src/Data/Thyme/LocalTime.hs +++ b/src/Data/Thyme/LocalTime.hs @@ -73,9 +73,6 @@ data TimeZone = TimeZone } deriving (Eq, Ord, Data, Typeable, Generic) makeLensesFor [("timeZoneMinutes","_timeZoneMinutes"),("timeZoneSummerOnly","_timeZoneSummerOnly"),("timeZoneName","_timeZoneName")] ''TimeZone -{-# INLINE _timeZoneMinutes #-} -{-# INLINE _timeZoneSummerOnly #-} -{-# INLINE _timeZoneName #-} instance Hashable TimeZone instance NFData TimeZone @@ -187,9 +184,6 @@ data TimeOfDay = TimeOfDay } deriving (Eq, Ord, Data, Typeable, Generic) makeLensesFor [("todHour","_todHour"),("todMin","_todMin"),("todSec","_todSec")] ''TimeOfDay -{-# INLINE _todHour #-} -{-# INLINE _todMin #-} -{-# INLINE _todSec #-} derivingUnbox "TimeOfDay" [t| TimeOfDay -> Int64 |] [| \ TimeOfDay {..} -> fromIntegral (todHour .|. shiftL todMin 8) @@ -357,8 +351,6 @@ data LocalTime = LocalTime } deriving (Eq, Ord, Data, Typeable, Generic) makeLensesFor [("localDay","_localDay"),("localTimeOfDay","_localTimeOfDay")] ''LocalTime -{-# INLINE _localDay #-} -{-# INLINE _localTimeOfDay #-} derivingUnbox "LocalTime" [t| LocalTime -> (Day, TimeOfDay) |] [| \ LocalTime {..} -> (localDay, localTimeOfDay) |] @@ -466,8 +458,6 @@ data ZonedTime = ZonedTime } deriving (Eq, Ord, Data, Typeable, Generic) makeLensesFor [("zonedTimeToLocalTime","_zonedTimeToLocalTime"),("zonedTimeZone","_zonedTimeZone")] ''ZonedTime -{-# INLINE _zonedTimeToLocalTime #-} -{-# INLINE _zonedTimeZone #-} instance Hashable ZonedTime instance NFData ZonedTime where diff --git a/stack.yaml b/stack.yaml index 27a0166..40c6d39 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,18 +1,6 @@ -resolver: lts-6.19 - -compiler: ghcjs-0.2.0.9006019_ghc-7.10.3 -compiler-check: match-exact -allow-different-user: true - -setup-info: - ghcjs: - source: - ghcjs-0.2.0.9006019_ghc-7.10.3: - url: http://ghcjs.tolysz.org/lts-6.19-9006019.tar.gz - sha1: ef4264d5a93b269ee4ec8f9d5139da030331d65a - flags: {} extra-package-dbs: [] packages: - '.' extra-deps: [] +resolver: lts-5.11 diff --git a/thyme.cabal b/thyme.cabal index bbc7899..420876b 100644 --- a/thyme.cabal +++ b/thyme.cabal @@ -41,11 +41,6 @@ flag HLint default: False manual: True -flag lens - description: use the full lens package - default: False - manual: True - flag show-internal description: instance Show of internal representation default: False @@ -54,8 +49,6 @@ flag show-internal library default-language: Haskell2010 hs-source-dirs: src - if !(flag(lens) || flag(docs)) - hs-source-dirs: lens exposed-modules: Data.Thyme Data.Thyme.Docs @@ -78,8 +71,6 @@ library Data.Thyme.Calendar.Internal Data.Thyme.Clock.Internal Data.Thyme.Format.Internal - if !(flag(lens) || flag(docs)) - other-modules: Control.Lens build-depends: QuickCheck >= 2.4, attoparsec >= 0.10, @@ -97,16 +88,10 @@ library true-name >= 0.1.0.1, vector >= 0.9, vector-th-unbox >= 0.2.1.0, - vector-space >= 0.8 + vector-space >= 0.8, + lens >= 3.9 if os(windows) build-depends: Win32 - if os(darwin) - build-tools: cpphs - ghc-options: -pgmP cpphs -optP--cpp - if flag(lens) || flag(docs) - build-depends: lens >= 3.9 - else - build-depends: profunctors >= 3.1.2 if flag(docs) build-depends: integer-gmp, ghc-prim ghc-options: -Wall @@ -119,12 +104,8 @@ test-suite sanity default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: tests - if !flag(lens) - hs-source-dirs: lens main-is: sanity.hs other-modules: Common - if !flag(lens) - other-modules: Control.Lens build-depends: QuickCheck, attoparsec, @@ -134,11 +115,8 @@ test-suite sanity text, thyme, time, - vector-space - if flag(lens) - build-depends: lens - else - build-depends: profunctors, mtl + vector-space, + lens ghc-options: -Wall test-suite rewrite @@ -168,12 +146,8 @@ benchmark bench default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: tests - if !flag(lens) - hs-source-dirs: lens main-is: bench.hs other-modules: Common - if !flag(lens) - other-modules: Control.Lens build-depends: QuickCheck, base, @@ -184,11 +158,8 @@ benchmark bench thyme, time, vector, - vector-space - if flag(lens) - build-depends: lens - else - build-depends: profunctors + vector-space, + lens ghc-options: -Wall -- vim: et sw=4 ts=4 sts=4: From 4b8ba6c1b9561720e2d0ccf829dae4a846997dee Mon Sep 17 00:00:00 2001 From: buckie Date: Fri, 21 Oct 2016 21:45:02 -0400 Subject: [PATCH 7/8] version bump as master moved from 0.3.5.5 Signed-off-by: buckie --- thyme.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thyme.cabal b/thyme.cabal index 420876b..170b0eb 100644 --- a/thyme.cabal +++ b/thyme.cabal @@ -1,5 +1,5 @@ name: thyme -version: 0.3.5.5 +version: 0.3.5.6 synopsis: A faster time library description: @thyme@ is a performance-optimized rewrite of the excellent From 142fbf375ff232820c69e8de124253b88afad2cb Mon Sep 17 00:00:00 2001 From: buckie Date: Sun, 23 Oct 2016 13:56:16 -0400 Subject: [PATCH 8/8] updated mempty build error; updated cabal file to remove depricated flens flag Signed-off-by: buckie --- .gitignore | 1 + src/Data/Thyme/Clock/TAI.hs | 4 +++- src/Data/Thyme/Format.hs | 3 +++ thyme.cabal | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 15e62b1..d454c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /dist/ +dump/ .stack-work/ diff --git a/src/Data/Thyme/Clock/TAI.hs b/src/Data/Thyme/Clock/TAI.hs index 5867c37..8af6c3d 100644 --- a/src/Data/Thyme/Clock/TAI.hs +++ b/src/Data/Thyme/Clock/TAI.hs @@ -41,6 +41,9 @@ import Prelude #if !MIN_VERSION_base(4,8,0) import Control.Applicative #endif +#if __GLASGOW_HASKELL__ < 710 +import Data.Monoid (mempty) +#endif import Control.DeepSeq import Control.Lens import Control.Monad @@ -354,4 +357,3 @@ utcToTAITime = view . absoluteTime {-# INLINE taiToUTCTime #-} taiToUTCTime :: TAIUTCMap -> AbsoluteTime -> UTCTime taiToUTCTime = review . absoluteTime - diff --git a/src/Data/Thyme/Format.hs b/src/Data/Thyme/Format.hs index 62bdab7..431f43e 100644 --- a/src/Data/Thyme/Format.hs +++ b/src/Data/Thyme/Format.hs @@ -30,6 +30,9 @@ import Control.Applicative #if SHOW_INTERNAL import Control.Arrow #endif +#if __GLASGOW_HASKELL__ < 710 +import Data.Monoid (mempty) +#endif import Control.Lens import Control.Monad.Trans import Control.Monad.State.Strict diff --git a/thyme.cabal b/thyme.cabal index 170b0eb..1999b86 100644 --- a/thyme.cabal +++ b/thyme.cabal @@ -32,7 +32,7 @@ flag bug-for-bug manual: True flag docs - description: include extra packages for Data.Thyme.Docs; implies -flens + description: include extra packages for Data.Thyme.Docs default: False manual: True