Skip to content

Commit ed1b72f

Browse files
committed
TH.Lift instances for all types (#269)
1 parent 0bc18de commit ed1b72f

File tree

17 files changed

+23
-57
lines changed

17 files changed

+23
-57
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- MicroHs
99
- add instance ParseTime DayOfWeek
1010
- make use of %s specifiers in parsing various types
11+
- add Lift instances to all types (really this time)
1112

1213
## [1.14] - 2024-03-10
1314
- add Lift instances to all types

lib/Data/Time/Calendar/CalendarDiffDays.hs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,7 @@ data CalendarDiffDays = CalendarDiffDays
1414
{ cdMonths :: Integer
1515
, cdDays :: Integer
1616
}
17-
deriving
18-
( Eq
19-
, -- | @since 1.9.2
20-
Data
21-
, -- | @since 1.9.2
22-
Typeable
23-
, -- | @since 1.14
24-
TH.Lift
25-
, -- | @since 1.14
26-
Generic
27-
)
17+
deriving (Eq, Typeable, Data, Generic, TH.Lift)
2818

2919
instance NFData CalendarDiffDays where
3020
rnf (CalendarDiffDays m d) = rnf m `seq` rnf d `seq` ()

lib/Data/Time/Calendar/Days.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import qualified Language.Haskell.TH.Syntax as TH
2525
newtype Day = ModifiedJulianDay
2626
{ toModifiedJulianDay :: Integer
2727
}
28-
deriving (Eq, Ord, Data, Typeable, TH.Lift, Generic)
28+
deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)
2929

3030
instance NFData Day where
3131
rnf (ModifiedJulianDay a) = rnf a

lib/Data/Time/Calendar/Month.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Text.Read
2525

2626
-- | An absolute count of common calendar months.
2727
-- Number is equal to @(year * 12) + (monthOfYear - 1)@.
28-
newtype Month = MkMonth Integer deriving (Eq, Ord, Data, Typeable, TH.Lift, Generic)
28+
newtype Month = MkMonth Integer deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)
2929

3030
instance NFData Month where
3131
rnf (MkMonth m) = rnf m

lib/Data/Time/Calendar/Quarter.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Text.ParserCombinators.ReadP
2828
import Text.Read
2929

3030
-- | Quarters of each year. Each quarter corresponds to three months.
31-
data QuarterOfYear = Q1 | Q2 | Q3 | Q4 deriving (Eq, Ord, Data, Typeable, Read, Show, Ix, TH.Lift, Generic)
31+
data QuarterOfYear = Q1 | Q2 | Q3 | Q4 deriving (Eq, Ord, Read, Show, Ix, Typeable, Data, Generic, TH.Lift)
3232

3333
-- | maps Q1..Q4 to 1..4
3434
instance Enum QuarterOfYear where
@@ -55,7 +55,7 @@ instance NFData QuarterOfYear where
5555

5656
-- | An absolute count of year quarters.
5757
-- Number is equal to @(year * 4) + (quarterOfYear - 1)@.
58-
newtype Quarter = MkQuarter Integer deriving (Eq, Ord, Data, Typeable, Generic)
58+
newtype Quarter = MkQuarter Integer deriving (Eq, Ord, Typeable, Data, Generic, TH.Lift)
5959

6060
instance NFData Quarter where
6161
rnf (MkQuarter m) = rnf m

lib/Data/Time/Calendar/Week.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data DayOfWeek
2727
| Friday
2828
| Saturday
2929
| Sunday
30-
deriving (Eq, Show, Read, Data, Typeable, Ord, Ix, TH.Lift, Generic)
30+
deriving (Eq, Ord, Ix, Show, Read, Typeable, Data, Generic, TH.Lift)
3131

3232
instance NFData DayOfWeek where
3333
rnf Monday = ()

lib/Data/Time/Clock/Internal/AbsoluteTime.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import qualified Language.Haskell.TH.Syntax as TH
1919
-- | AbsoluteTime is TAI, time as measured by a clock.
2020
newtype AbsoluteTime
2121
= MkAbsoluteTime DiffTime
22-
deriving (Eq, Ord, Data, Typeable, TH.Lift)
22+
deriving (Eq, Ord, Typeable, Data, TH.Lift)
2323

2424
instance NFData AbsoluteTime where
2525
rnf (MkAbsoluteTime a) = rnf a

lib/Data/Time/Clock/Internal/DiffTime.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import Text.Read
2929
-- It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.
3030
newtype DiffTime
3131
= MkDiffTime Pico
32-
deriving (Eq, Ord, Data, Typeable)
32+
deriving (Eq, Ord, Typeable, Data, TH.Lift)
3333

3434
instance NFData DiffTime where
3535
rnf (MkDiffTime t) = rnf t
@@ -81,13 +81,6 @@ instance RealFrac DiffTime where
8181
ceiling (MkDiffTime a) = ceiling a
8282
floor (MkDiffTime a) = floor a
8383

84-
#ifdef __GLASGOW_HASKELL__
85-
-- Let GHC derive the instances when 'Fixed' has 'TH.Lift' instance.
86-
instance TH.Lift DiffTime where
87-
liftTyped :: TH.Quote m => DiffTime -> TH.Code m DiffTime
88-
liftTyped (MkDiffTime (MkFixed a)) = [||MkDiffTime (MkFixed $$(TH.liftTyped a))||]
89-
#endif
90-
9184
-- | Create a 'DiffTime' which represents an integral number of seconds.
9285
secondsToDiffTime :: Integer -> DiffTime
9386
secondsToDiffTime = fromInteger

lib/Data/Time/Clock/Internal/NominalDiffTime.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import Text.ParserCombinators.ReadPrec
3434
-- regardless of whether a leap-second intervened.
3535
newtype NominalDiffTime
3636
= MkNominalDiffTime Pico
37-
deriving (Eq, Ord, Data, Typeable)
37+
deriving (Eq, Ord, Typeable, Data, TH.Lift)
3838

3939
-- | Create a 'NominalDiffTime' from a number of seconds.
4040
--
@@ -48,13 +48,6 @@ secondsToNominalDiffTime = MkNominalDiffTime
4848
nominalDiffTimeToSeconds :: NominalDiffTime -> Pico
4949
nominalDiffTimeToSeconds (MkNominalDiffTime t) = t
5050

51-
#ifdef __GLASGOW_HASKELL__
52-
-- Let GHC derive the instances when 'Fixed' has 'TH.Lift' instance.
53-
instance TH.Lift NominalDiffTime where
54-
liftTyped :: TH.Quote m => NominalDiffTime -> TH.Code m NominalDiffTime
55-
liftTyped (MkNominalDiffTime (MkFixed a)) = [||MkNominalDiffTime (MkFixed $$(TH.liftTyped a))||]
56-
#endif
57-
5851
instance NFData NominalDiffTime where
5952
rnf (MkNominalDiffTime t) = rnf t
6053

lib/Data/Time/Clock/Internal/SystemTime.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ data SystemTime = MkSystemTime
4343
{ systemSeconds :: {-# UNPACK #-} !Int64
4444
, systemNanoseconds :: {-# UNPACK #-} !Word32
4545
}
46-
deriving (Eq, Ord, Show, Data, Typeable, TH.Lift, Generic)
46+
deriving (Eq, Ord, Show, Typeable, Data, Generic, TH.Lift)
4747

4848
instance NFData SystemTime where
4949
rnf a = a `seq` ()

0 commit comments

Comments
 (0)