@@ -22,13 +22,16 @@ import Data.Foreign.Index ((!))
22import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..), defaultComponentRecord)
22import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..), defaultComponentRecord)
23import Data.Maybe (Maybe(..))
23import Data.Maybe (Maybe(..))
24import Data.Newtype (class Newtype, over)
24import Data.Newtype (class Newtype, over)
25−import Prelude (class Show, bind, pure, show, ($), (<>), (>>=))
25+import Prelude (class Eq, class Show, bind, pure, show, ($), (<>), (>>=))
27foreign import data Undefined :: Type
27foreign import data Undefined :: Type
28foreign import undefined :: Undefined
29foreign import undefined :: Undefined
30data StringRep = Narrow | Short | Long
31data StringRep = Narrow | Short | Long
33+derive instance eqStringRep :: Eq StringRep
32instance showStringRep :: Show StringRep where
35instance showStringRep :: Show StringRep where
33 show Narrow = "narrow"
36 show Narrow = "narrow"
34 show Short = "short"
37 show Short = "short"
@@ -36,12 +39,16 @@ instance showStringRep :: Show StringRep where
37data NumericRep = Numeric | TwoDigit
40data NumericRep = Numeric | TwoDigit
42+derive instance eqNumericRep :: Eq NumericRep
39instance showNumericRep :: Show NumericRep where
44instance showNumericRep :: Show NumericRep where
40 show Numeric = "numeric"
45 show Numeric = "numeric"
41 show TwoDigit = "2-digit"
46 show TwoDigit = "2-digit"
43data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
48data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
50+derive instance eqMonthRep :: Eq MonthRep
45instance showMonthRep :: Show MonthRep where
52instance showMonthRep :: Show MonthRep where
46 show MonthNumeric = "numeric"
53 show MonthNumeric = "numeric"
47 show MonthTwoDigit = "2-digit"
54 show MonthTwoDigit = "2-digit"
@@ -51,6 +58,8 @@ instance showMonthRep :: Show MonthRep where
52data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
59data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
61+derive instance eqTimeZoneNameRep :: Eq TimeZoneNameRep
54instance showTimeZoneRep :: Show TimeZoneNameRep where
63instance showTimeZoneRep :: Show TimeZoneNameRep where
55 show TimeZoneNameShort = "short"
64 show TimeZoneNameShort = "short"
56 show TimeZoneNameLong = "long"
65 show TimeZoneNameLong = "long"
@@ -66,6 +75,8 @@ data FormatParts
66 | DayPeriod String
75 | DayPeriod String
67 | Literal String
76 | Literal String
78+derive instance eqFormatParts :: Eq FormatParts
69readFormatParts :: Foreign -> F FormatParts
80readFormatParts :: Foreign -> F FormatParts
70readFormatParts val = do
81readFormatParts val = do
71 type_ <- val ! "type" >>= readString
82 type_ <- val ! "type" >>= readString
@@ -100,6 +111,8 @@ newtype ResolvedOptions = ResolvedOptions
101derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
112derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
114+derive instance eqResolvedOptions :: Eq ResolvedOptions
103newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
116newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
104 { weekday :: StringRep
117 { weekday :: StringRep
105 , year :: NumericRep
118 , year :: NumericRep
@@ -112,6 +125,8 @@ newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecon
113derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
126derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
128+derive instance eqWeekdayYearMonthDayHourMinuteSecond :: Eq WeekdayYearMonthDayHourMinuteSecond
115instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
130instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
116 formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
131 formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
117 (\r -> r { weekday = Just (show weekday)
132 (\r -> r { weekday = Just (show weekday)
@@ -133,6 +148,8 @@ newtype WeekdayYearMonthDay = WeekdayYearMonthDay
134derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
149derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
151+derive instance eqWeekdayYearMonthDay :: Eq WeekdayYearMonthDay
136instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
153instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
137 formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
154 formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
138 (\r -> r { weekday = Just (show weekday)
155 (\r -> r { weekday = Just (show weekday)
@@ -151,6 +168,8 @@ newtype YearMonthDay = YearMonthDay
152derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
169derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
171+derive instance eqYearMonthDay :: Eq YearMonthDay
154instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
173instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
155 formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
174 formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
156 (\r -> r { year = Just (show year)
175 (\r -> r { year = Just (show year)
@@ -167,6 +186,8 @@ newtype YearMonth = YearMonth
168derive instance newtypeYearMonth :: Newtype YearMonth _
187derive instance newtypeYearMonth :: Newtype YearMonth _
189+derive instance eqYearMonth :: Eq YearMonth
170instance formatComponentYearMonth :: FormatComponent YearMonth where
191instance formatComponentYearMonth :: FormatComponent YearMonth where
171 formatComponent (YearMonth { year, month }) = over FormatComponentRecord
192 formatComponent (YearMonth { year, month }) = over FormatComponentRecord
172 (\r -> r { year = Just (show year)
193 (\r -> r { year = Just (show year)
@@ -181,6 +202,8 @@ newtype MonthDay = MonthDay
182derive instance newtypeMonthDay :: Newtype MonthDay _
203derive instance newtypeMonthDay :: Newtype MonthDay _
205+derive instance eqMonthDay :: Eq MonthDay
184instance formatComponentMonthDay :: FormatComponent MonthDay where
207instance formatComponentMonthDay :: FormatComponent MonthDay where
185 formatComponent (MonthDay { month, day }) = over FormatComponentRecord
208 formatComponent (MonthDay { month, day }) = over FormatComponentRecord
186 (\r -> r { month = Just (show month)
209 (\r -> r { month = Just (show month)
@@ -196,6 +219,8 @@ newtype HourMinuteSecond = HourMinuteSecond
197derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
220derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
222+derive instance eqHourMinuteSecond :: Eq HourMinuteSecond
199instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
224instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
200 formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
225 formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
201 (\r -> r { hour = Just (show hour)
226 (\r -> r { hour = Just (show hour)
@@ -211,6 +236,8 @@ newtype HourMinute = HourMinute
212derive instance newtypeHourMinute :: Newtype HourMinute _
237derive instance newtypeHourMinute :: Newtype HourMinute _
239+derive instance eqHourMinute :: Eq HourMinute
214instance formatComponentHourMinute :: FormatComponent HourMinute where
241instance formatComponentHourMinute :: FormatComponent HourMinute where
215 formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
242 formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
216 (\r -> r { hour = Just (show hour)
243 (\r -> r { hour = Just (show hour)