@@ -19,12 +19,10 @@ module Data.Intl.DateTimeFormat.Types
20import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
20import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
21import Data.Foreign.Index ((!))
21import Data.Foreign.Index ((!))
22−import Data.Generic (class Generic)
23−import Data.Intl.DateTimeFormat.Class (class FormatComponent)
22+import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..), defaultComponentRecord)
24−import Data.Intl.DateTimeFormat.Generic (genericFormatComponent)
25−import Data.Maybe (Maybe)
23+import Data.Maybe (Maybe(..))
26−import Data.Newtype (class Newtype)
24+import Data.Newtype (class Newtype, over)
27−import Prelude (class Show, bind, pure, ($), (<>), (>>=))
25+import Prelude (class Show, bind, pure, show, ($), (<>), (>>=))
29foreign import data Undefined :: Type
27foreign import data Undefined :: Type
30foreign import undefined :: Undefined
28foreign import undefined :: Undefined
@@ -112,10 +110,17 @@ newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecon
112 , second :: NumericRep
110 , second :: NumericRep
115−derive instance genericWeekdayYearMonthDayHourMinuteSecond :: Generic WeekdayYearMonthDayHourMinuteSecond _
117instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
113instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
118− formatComponent = genericFormatComponent
114+ formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
115+ (\r -> r { weekday = Just (show weekday)
116+ , year = Just (show year)
117+ , month = Just (show month)
118+ , day = Just (show day)
119+ , hour = Just (show hour)
120+ , minute = Just (show minute)
121+ , second = Just (show second)
123+ ) defaultComponentRecord
120newtype WeekdayYearMonthDay = WeekdayYearMonthDay
125newtype WeekdayYearMonthDay = WeekdayYearMonthDay
121 { weekday :: StringRep
126 { weekday :: StringRep
@@ -124,10 +129,15 @@ newtype WeekdayYearMonthDay = WeekdayYearMonthDay
124 , day :: NumericRep
129 , day :: NumericRep
127−derive instance genericWeekdayYearMonthDay :: Generic WeekdayYearMonthDay _
129instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
132instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
130− formatComponent = genericFormatComponent
133+ formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
134+ (\r -> r { weekday = Just (show weekday)
135+ , year = Just (show year)
136+ , month = Just (show month)
137+ , day = Just (show day)
139+ ) defaultComponentRecord
132newtype YearMonthDay = YearMonthDay
142newtype YearMonthDay = YearMonthDay
133 { year :: NumericRep
143 { year :: NumericRep
@@ -135,30 +145,38 @@ newtype YearMonthDay = YearMonthDay
135 , day :: NumericRep
145 , day :: NumericRep
138−derive instance genericYearMonthDay :: Generic YearMonthDay _
140instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
148instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
141− formatComponent = genericFormatComponent
149+ formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
150+ (\r -> r { year = Just (show year)
151+ , month = Just (show month)
152+ , day = Just (show day)
154+ ) defaultComponentRecord
143newtype YearMonth = YearMonth
157newtype YearMonth = YearMonth
144 { year :: NumericRep
158 { year :: NumericRep
145 , month :: MonthRep
159 , month :: MonthRep
148−derive instance genericYearMonth :: Generic YearMonth _
150instance formatComponentYearMonth :: FormatComponent YearMonth where
162instance formatComponentYearMonth :: FormatComponent YearMonth where
151− formatComponent = genericFormatComponent
163+ formatComponent (YearMonth { year, month }) = over FormatComponentRecord
164+ (\r -> r { year = Just (show year)
165+ , month = Just (show month)
167+ ) defaultComponentRecord
153newtype MonthDay = MonthDay
169newtype MonthDay = MonthDay
154 { month :: MonthRep
170 { month :: MonthRep
155 , day :: NumericRep
171 , day :: NumericRep
158−derive instance genericMonthDay :: Generic MonthDay _
160instance formatComponentMonthDay :: FormatComponent MonthDay where
174instance formatComponentMonthDay :: FormatComponent MonthDay where
161− formatComponent = genericFormatComponent
175+ formatComponent (MonthDay { month, day }) = over FormatComponentRecord
176+ (\r -> r { month = Just (show month)
177+ , day = Just (show day)
179+ ) defaultComponentRecord
163newtype HourMinuteSecond = HourMinuteSecond
181newtype HourMinuteSecond = HourMinuteSecond
164 { hour :: NumericRep
182 { hour :: NumericRep
@@ -166,17 +184,22 @@ newtype HourMinuteSecond = HourMinuteSecond
166 , second :: NumericRep
184 , second :: NumericRep
169−derive instance genericHourMinuteSecond :: Generic HourMinuteSecond _
171instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
187instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
172− formatComponent = genericFormatComponent
188+ formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
189+ (\r -> r { hour = Just (show hour)
190+ , minute = Just (show minute)
191+ , second = Just (show second)
193+ ) defaultComponentRecord
174newtype HourMinute = HourMinute
195newtype HourMinute = HourMinute
175 { hour :: NumericRep
196 { hour :: NumericRep
176 , minute :: NumericRep
197 , minute :: NumericRep
179−derive instance genericHourMinute :: Generic HourMinute _
181instance formatComponentHourMinute :: FormatComponent HourMinute where
200instance formatComponentHourMinute :: FormatComponent HourMinute where
182− formatComponent = genericFormatComponent
201+ formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
202+ (\r -> r { hour = Just (show hour)
203+ , minute = Just (show minute)
205+ ) defaultComponentRecord