git.iko.soy/purescript-intl
on master help sign in
derive Eq instances
commit83de60bdce479429171b92a2e8bbe6c8253cb575 authorMarcin Szamotulski <mszamot@gmail.com> dateSun 25 Jun 2017, 23:33 (9 years ago) parent2431d46
2 files changed+31−2
src/Data/Intl/DateTimeFormat/Class.purs+3−1 src/Data/Intl/DateTimeFormat/Types.purs+28−1
src/Data/Intl/DateTimeFormat/Class.purs+3−1
@@ -2,7 +2,7 @@ module Data.Intl.DateTimeFormat.Class where
22
33import Data.Maybe (Maybe(..))
44import Data.Newtype (class Newtype)
5−import Prelude (Unit)
5+import Prelude (class Eq, Unit)
66
77newtype FormatComponentRecord = FormatComponentRecord
88 { era :: Maybe String
@@ -18,6 +18,8 @@ newtype FormatComponentRecord = FormatComponentRecord
1818
1919derive instance newtypeFormatComponentRecord :: Newtype FormatComponentRecord _
2020
21+derive instance eqFormatComponentRecord :: Eq FormatComponentRecord
22+
2123defaultComponentRecord :: FormatComponentRecord
2224defaultComponentRecord = FormatComponentRecord
2325 { era: Nothing
src/Data/Intl/DateTimeFormat/Types.purs+28−1
@@ -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
@@ -112,6 +125,8 @@ newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecon
112125
113126derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
114127
128+derive instance eqWeekdayYearMonthDayHourMinuteSecond :: Eq WeekdayYearMonthDayHourMinuteSecond
129+
115130instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
116131 formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
117132 (\r -> r { weekday = Just (show weekday)
@@ -133,6 +148,8 @@ newtype WeekdayYearMonthDay = WeekdayYearMonthDay
133148
134149derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
135150
151+derive instance eqWeekdayYearMonthDay :: Eq WeekdayYearMonthDay
152+
136153instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
137154 formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
138155 (\r -> r { weekday = Just (show weekday)
@@ -151,6 +168,8 @@ newtype YearMonthDay = YearMonthDay
151168
152169derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
153170
171+derive instance eqYearMonthDay :: Eq YearMonthDay
172+
154173instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
155174 formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
156175 (\r -> r { year = Just (show year)
@@ -167,6 +186,8 @@ newtype YearMonth = YearMonth
167186
168187derive instance newtypeYearMonth :: Newtype YearMonth _
169188
189+derive instance eqYearMonth :: Eq YearMonth
190+
170191instance formatComponentYearMonth :: FormatComponent YearMonth where
171192 formatComponent (YearMonth { year, month }) = over FormatComponentRecord
172193 (\r -> r { year = Just (show year)
@@ -181,6 +202,8 @@ newtype MonthDay = MonthDay
181202
182203derive instance newtypeMonthDay :: Newtype MonthDay _
183204
205+derive instance eqMonthDay :: Eq MonthDay
206+
184207instance formatComponentMonthDay :: FormatComponent MonthDay where
185208 formatComponent (MonthDay { month, day }) = over FormatComponentRecord
186209 (\r -> r { month = Just (show month)
@@ -196,6 +219,8 @@ newtype HourMinuteSecond = HourMinuteSecond
196219
197220derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
198221
222+derive instance eqHourMinuteSecond :: Eq HourMinuteSecond
223+
199224instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
200225 formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
201226 (\r -> r { hour = Just (show hour)
@@ -211,6 +236,8 @@ newtype HourMinute = HourMinute
211236
212237derive instance newtypeHourMinute :: Newtype HourMinute _
213238
239+derive instance eqHourMinute :: Eq HourMinute
240+
214241instance formatComponentHourMinute :: FormatComponent HourMinute where
215242 formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
216243 (\r -> r { hour = Just (show hour)