@@ -22,13 +22,16 @@ import Data.Foreign.Index ((!))
2222import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..), defaultComponentRecord)
2323import Data.Maybe (Maybe(..))
2424import Data.Newtype (class Newtype, over)
25−import Prelude (class Show, bind, pure, show, ($), (<>), (>>=))
25+import Prelude (class Eq, class Show, bind, pure, show, ($), (<>), (>>=))
2626
2727foreign import data Undefined :: Type
28+
2829foreign import undefined :: Undefined
2930
3031data StringRep = Narrow | Short | Long
3132
33+derive instance eqStringRep :: Eq StringRep
34+
3235instance showStringRep :: Show StringRep where
3336 show Narrow = "narrow"
3437 show Short = "short"
@@ -36,12 +39,16 @@ instance showStringRep :: Show StringRep where
3639
3740data NumericRep = Numeric | TwoDigit
3841
42+derive instance eqNumericRep :: Eq NumericRep
43+
3944instance showNumericRep :: Show NumericRep where
4045 show Numeric = "numeric"
4146 show TwoDigit = "2-digit"
4247
4348data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
4449
50+derive instance eqMonthRep :: Eq MonthRep
51+
4552instance showMonthRep :: Show MonthRep where
4653 show MonthNumeric = "numeric"
4754 show MonthTwoDigit = "2-digit"
@@ -51,6 +58,8 @@ instance showMonthRep :: Show MonthRep where
5158
5259data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
5360
61+derive instance eqTimeZoneNameRep :: Eq TimeZoneNameRep
62+
5463instance showTimeZoneRep :: Show TimeZoneNameRep where
5564 show TimeZoneNameShort = "short"
5665 show TimeZoneNameLong = "long"
@@ -66,6 +75,8 @@ data FormatParts
6675 | DayPeriod String
6776 | Literal String
6877
78+derive instance eqFormatParts :: Eq FormatParts
79+
6980readFormatParts :: Foreign -> F FormatParts
7081readFormatParts val = do
7182 type_ <- val ! "type" >>= readString
@@ -100,6 +111,8 @@ newtype ResolvedOptions = ResolvedOptions
100111
101112derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
102113
114+derive instance eqResolvedOptions :: Eq ResolvedOptions
115+
103116newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
104117 { weekday :: StringRep
105118 , year :: NumericRep
@@ -110,6 +123,10 @@ newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecon
110123 , second :: NumericRep
111124 }
112125
126+derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
127+
128+derive instance eqWeekdayYearMonthDayHourMinuteSecond :: Eq WeekdayYearMonthDayHourMinuteSecond
129+
113130instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
114131 formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
115132 (\r -> r { weekday = Just (show weekday)
@@ -129,6 +146,10 @@ newtype WeekdayYearMonthDay = WeekdayYearMonthDay
129146 , day :: NumericRep
130147 }
131148
149+derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
150+
151+derive instance eqWeekdayYearMonthDay :: Eq WeekdayYearMonthDay
152+
132153instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
133154 formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
134155 (\r -> r { weekday = Just (show weekday)
@@ -145,6 +166,10 @@ newtype YearMonthDay = YearMonthDay
145166 , day :: NumericRep
146167 }
147168
169+derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
170+
171+derive instance eqYearMonthDay :: Eq YearMonthDay
172+
148173instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
149174 formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
150175 (\r -> r { year = Just (show year)
@@ -159,6 +184,10 @@ newtype YearMonth = YearMonth
159184 , month :: MonthRep
160185 }
161186
187+derive instance newtypeYearMonth :: Newtype YearMonth _
188+
189+derive instance eqYearMonth :: Eq YearMonth
190+
162191instance formatComponentYearMonth :: FormatComponent YearMonth where
163192 formatComponent (YearMonth { year, month }) = over FormatComponentRecord
164193 (\r -> r { year = Just (show year)
@@ -171,6 +200,10 @@ newtype MonthDay = MonthDay
171200 , day :: NumericRep
172201 }
173202
203+derive instance newtypeMonthDay :: Newtype MonthDay _
204+
205+derive instance eqMonthDay :: Eq MonthDay
206+
174207instance formatComponentMonthDay :: FormatComponent MonthDay where
175208 formatComponent (MonthDay { month, day }) = over FormatComponentRecord
176209 (\r -> r { month = Just (show month)
@@ -184,6 +217,10 @@ newtype HourMinuteSecond = HourMinuteSecond
184217 , second :: NumericRep
185218 }
186219
220+derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
221+
222+derive instance eqHourMinuteSecond :: Eq HourMinuteSecond
223+
187224instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
188225 formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
189226 (\r -> r { hour = Just (show hour)
@@ -197,6 +234,10 @@ newtype HourMinute = HourMinute
197234 , minute :: NumericRep
198235 }
199236
237+derive instance newtypeHourMinute :: Newtype HourMinute _
238+
239+derive instance eqHourMinute :: Eq HourMinute
240+
200241instance formatComponentHourMinute :: FormatComponent HourMinute where
201242 formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
202243 (\r -> r { hour = Just (show hour)