git.iko.soy/purescript-intl
on master help sign in
derive Eq instances
83de60bMarcin Szamotulski
src/Data/Intl/DateTimeFormat/Class.purs+3−1
@@ -2,7 +2,7 @@ module Data.Intl.DateTimeFormat.Class where
2
2
3import Data.Maybe (Maybe(..))
3import Data.Maybe (Maybe(..))
4import Data.Newtype (class Newtype)
4import Data.Newtype (class Newtype)
5−import Prelude (Unit)
5+import Prelude (class Eq, Unit)
6
6
7newtype FormatComponentRecord = FormatComponentRecord
7newtype FormatComponentRecord = FormatComponentRecord
8 { era :: Maybe String
8 { era :: Maybe String
@@ -18,6 +18,8 @@ newtype FormatComponentRecord = FormatComponentRecord
18
18
19derive instance newtypeFormatComponentRecord :: Newtype FormatComponentRecord _
19derive instance newtypeFormatComponentRecord :: Newtype FormatComponentRecord _
20
20
21+derive instance eqFormatComponentRecord :: Eq FormatComponentRecord
22+
21defaultComponentRecord :: FormatComponentRecord
23defaultComponentRecord :: FormatComponentRecord
22defaultComponentRecord = FormatComponentRecord
24defaultComponentRecord = FormatComponentRecord
23 { era: Nothing
25 { era: Nothing
src/Data/Intl/DateTimeFormat/Types.purs+28−1
@@ -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, ($), (<>), (>>=))
26
26
27foreign import data Undefined :: Type
27foreign import data Undefined :: Type
28+
28foreign import undefined :: Undefined
29foreign import undefined :: Undefined
29
30
30data StringRep = Narrow | Short | Long
31data StringRep = Narrow | Short | Long
31
32
33+derive instance eqStringRep :: Eq StringRep
34+
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
36
39
37data NumericRep = Numeric | TwoDigit
40data NumericRep = Numeric | TwoDigit
38
41
42+derive instance eqNumericRep :: Eq NumericRep
43+
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"
42
47
43data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
48data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
44
49
50+derive instance eqMonthRep :: Eq MonthRep
51+
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
51
58
52data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
59data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
53
60
61+derive instance eqTimeZoneNameRep :: Eq TimeZoneNameRep
62+
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
68
77
78+derive instance eqFormatParts :: Eq FormatParts
79+
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
100
111
101derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
112derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
102
113
114+derive instance eqResolvedOptions :: Eq ResolvedOptions
115+
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
112
125
113derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
126derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
114
127
128+derive instance eqWeekdayYearMonthDayHourMinuteSecond :: Eq WeekdayYearMonthDayHourMinuteSecond
129+
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
133
148
134derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
149derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
135
150
151+derive instance eqWeekdayYearMonthDay :: Eq WeekdayYearMonthDay
152+
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
151
168
152derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
169derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
153
170
171+derive instance eqYearMonthDay :: Eq YearMonthDay
172+
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
167
186
168derive instance newtypeYearMonth :: Newtype YearMonth _
187derive instance newtypeYearMonth :: Newtype YearMonth _
169
188
189+derive instance eqYearMonth :: Eq YearMonth
190+
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
181
202
182derive instance newtypeMonthDay :: Newtype MonthDay _
203derive instance newtypeMonthDay :: Newtype MonthDay _
183
204
205+derive instance eqMonthDay :: Eq MonthDay
206+
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
196
219
197derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
220derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
198
221
222+derive instance eqHourMinuteSecond :: Eq HourMinuteSecond
223+
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
211
236
212derive instance newtypeHourMinute :: Newtype HourMinute _
237derive instance newtypeHourMinute :: Newtype HourMinute _
213
238
239+derive instance eqHourMinute :: Eq HourMinute
240+
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)