git.iko.soy/purescript-intl
on master help sign in
Reshuffle modules

Cycle deps problem

commit986e20e6fb5a8cd53b02d11b9213ba05214a62cf authorMarcin Szamotulski <mszamot@gmail.com> dateSun 18 Jun 2017, 22:59 (9 years ago) parent3a7bbdc
5 files changed+136−128
src/Data/Intl/DateTimeFormat.purs−91 src/Data/Intl/DateTimeFormat/Class.purs+36 src/Data/Intl/DateTimeFormat/Generic.purs+3−37 src/Data/Intl/DateTimeFormat/Types.js+3 src/Data/Intl/DateTimeFormat/Types.purs+94
src/Data/Intl/DateTimeFormat.purs−91
@@ -3,15 +3,6 @@ module Data.Intl.DateTimeFormat
33 , LocaleMatcher(..)
44 , TimeZone(..)
55 , FormatMatcher(..)
6− , WeekdayYearMonthDayHourMinuteSecond(..)
7− , WeekdayYearMonthDay(..)
8− , YearMonthDay(..)
9− , YearMonth(..)
10− , MonthDay(..)
11− , HourMinuteSecond(..)
12− , HourMinute(..)
13− , Undefined
14− , undefined
156 , DateTimeFormatOptions(..)
167 , DateTimeFormatOptions'
178 , DateTimeComponents(..)
@@ -45,9 +36,6 @@ import Unsafe.Coerce (unsafeCoerce)
4536
4637foreign import data LocalesOption' :: Type
4738
48−foreign import data Undefined :: Type
49−foreign import undefined :: Undefined
50−
5139foreign import dateTimeFormatImpl :: LocalesOption' -> DateTimeFormatOptions_ -> DateTimeFormat
5240
5341newtype DateTimeFormatOptions_ = DateTimeFormatOptions_
@@ -99,85 +87,6 @@ instance showFormatMatcher :: Show FormatMatcher where
9987 show FMBasic = "basic"
10088 show FMBestFit = "best fit"
10189
102−newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
103− { weekday :: StringRep
104− , year :: NumericRep
105− , month :: MonthRep
106− , day :: NumericRep
107− , hour :: NumericRep
108− , minute :: NumericRep
109− , second :: NumericRep
110− }
111−
112−derive instance genericWeekdayYearMonthDayHourMinuteSecond :: Generic WeekdayYearMonthDayHourMinuteSecond _
113−
114−instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
115− formatComponent = genericFormatComponent
116−
117−newtype WeekdayYearMonthDay = WeekdayYearMonthDay
118− { weekday :: StringRep
119− , year :: NumericRep
120− , month :: MonthRep
121− , day :: NumericRep
122− }
123−
124−derive instance genericWeekdayYearMonthDay :: Generic WeekdayYearMonthDay _
125−
126−instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
127− formatComponent = genericFormatComponent
128−
129−newtype YearMonthDay = YearMonthDay
130− { year :: NumericRep
131− , month :: MonthRep
132− , day :: NumericRep
133− }
134−
135−derive instance genericYearMonthDay :: Generic YearMonthDay _
136−
137−instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
138− formatComponent = genericFormatComponent
139−
140−newtype YearMonth = YearMonth
141− { year :: NumericRep
142− , month :: MonthRep
143− }
144−
145−derive instance genericYearMonth :: Generic YearMonth _
146−
147−instance formatComponentYearMonth :: FormatComponent YearMonth where
148− formatComponent = genericFormatComponent
149−
150−newtype MonthDay = MonthDay
151− { month :: MonthRep
152− , day :: NumericRep
153− }
154−
155−derive instance genericMonthDay :: Generic MonthDay _
156−
157−instance formatComponentMonthDay :: FormatComponent MonthDay where
158− formatComponent = genericFormatComponent
159−
160−newtype HourMinuteSecond = HourMinuteSecond
161− { hour :: NumericRep
162− , minute :: NumericRep
163− , second :: NumericRep
164− }
165−
166−derive instance genericHourMinuteSecond :: Generic HourMinuteSecond _
167−
168−instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
169− formatComponent = genericFormatComponent
170−
171−newtype HourMinute = HourMinute
172− { hour :: NumericRep
173− , minute :: NumericRep
174− }
175−
176−derive instance genericHourMinute :: Generic HourMinute _
177−
178−instance formatComponentHourMinute :: FormatComponent HourMinute where
179− formatComponent = genericFormatComponent
180−
18190type DateTimeComponents a =
18291 Variant
18392 ( weekdayYearMonthDayHourMinuteSecond :: WeekdayYearMonthDayHourMinuteSecond
src/Data/Intl/DateTimeFormat/Class.pursnew file+36
@@ -0,0 +1,36 @@
1+module Data.Intl.DateTimeFormat.Class where
2+
3+import Data.Maybe (Maybe(..))
4+import Prelude (Unit)
5+
6+type FormatComponentRecord =
7+ { era :: Maybe String
8+ , weekday :: Maybe String
9+ , year :: Maybe String
10+ , month :: Maybe String
11+ , day :: Maybe String
12+ , hour :: Maybe String
13+ , minute :: Maybe String
14+ , second :: Maybe String
15+ , timeZoneName :: Maybe String
16+ }
17+
18+defaultComponentRecord :: FormatComponentRecord
19+defaultComponentRecord =
20+ { era: Nothing
21+ , weekday: Nothing
22+ , year: Nothing
23+ , month: Nothing
24+ , day: Nothing
25+ , hour: Nothing
26+ , minute: Nothing
27+ , second: Nothing
28+ , timeZoneName: Nothing
29+ }
30+
31+
32+class FormatComponent a where
33+ formatComponent :: a -> FormatComponentRecord
34+
35+instance unitFormatComponent :: FormatComponent Unit where
36+ formatComponent _ = defaultComponentRecord
src/Data/Intl/DateTimeFormat/Generic.purs+3−37
@@ -1,51 +1,17 @@
11module Data.Intl.DateTimeFormat.Generic
2− ( class FormatComponent
3− , formatComponent
4− , class GenericFormatComponent
2+ ( class GenericFormatComponent
53 , genericFormatComponent'
64 , genericFormatComponent
75 , class GenericFormatComponentFields
86 , genericFormatComponentFields
9− , defaultComponentRecord
10− , FormatComponentRecord
117 ) where
128
139import Data.Generic.Rep (class Generic, Constructor(Constructor), Field(..), NoConstructors, Product(..), Rec(..), from)
10+import Data.Intl.DateTimeFormat.Class (FormatComponentRecord)
1411import Data.Intl.DateTimeFormat.Types (MonthRep, NumericRep, TimeZoneNameRep, StringRep)
1512import Data.Maybe (Maybe(..))
1613import Data.StrMap (StrMap, lookup, singleton, union)
17−import Prelude (Unit, show)
18−
19−type FormatComponentRecord =
20− { era :: Maybe String
21− , weekday :: Maybe String
22− , year :: Maybe String
23− , month :: Maybe String
24− , day :: Maybe String
25− , hour :: Maybe String
26− , minute :: Maybe String
27− , second :: Maybe String
28− , timeZoneName :: Maybe String
29− }
30−
31−defaultComponentRecord :: FormatComponentRecord
32−defaultComponentRecord =
33− { era: Nothing
34− , weekday: Nothing
35− , year: Nothing
36− , month: Nothing
37− , day: Nothing
38− , hour: Nothing
39− , minute: Nothing
40− , second: Nothing
41− , timeZoneName: Nothing
42− }
43−
44−class FormatComponent a where
45− formatComponent :: a -> FormatComponentRecord
46−
47−instance unitFormatComponent :: FormatComponent Unit where
48− formatComponent _ = defaultComponentRecord
14+import Prelude (show)
4915
5016class GenericFormatComponent a where
5117 genericFormatComponent' :: a -> FormatComponentRecord
src/Data/Intl/DateTimeFormat/Types.jsnew file+3
@@ -0,0 +1,3 @@
1+"use strict";
2+
3+exports["undefined"] = undefined;
src/Data/Intl/DateTimeFormat/Types.purs+94
@@ -6,14 +6,29 @@ module Data.Intl.DateTimeFormat.Types
66 , FormatParts(..)
77 , readFormatParts
88 , ResolvedOptions(..)
9+ , WeekdayYearMonthDayHourMinuteSecond(..)
10+ , WeekdayYearMonthDay(..)
11+ , YearMonthDay(..)
12+ , YearMonth(..)
13+ , MonthDay(..)
14+ , HourMinuteSecond(..)
15+ , HourMinute(..)
16+ , Undefined
17+ , undefined
918 ) where
1019
1120import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
1221import Data.Foreign.Index ((!))
22+import Data.Generic (class Generic)
23+import Data.Intl.DateTimeFormat.Class (class FormatComponent)
24+import Data.Intl.DateTimeFormat.Generic (genericFormatComponent)
1325import Data.Maybe (Maybe)
1426import Data.Newtype (class Newtype)
1527import Prelude (class Show, bind, pure, ($), (<>), (>>=))
1628
29+foreign import data Undefined :: Type
30+foreign import undefined :: Undefined
31+
1732data StringRep = Narrow | Short | Long
1833
1934instance showStringRep :: Show StringRep where
@@ -86,3 +101,82 @@ newtype ResolvedOptions = ResolvedOptions
86101 }
87102
88103derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
104+
105+newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
106+ { weekday :: StringRep
107+ , year :: NumericRep
108+ , month :: MonthRep
109+ , day :: NumericRep
110+ , hour :: NumericRep
111+ , minute :: NumericRep
112+ , second :: NumericRep
113+ }
114+
115+derive instance genericWeekdayYearMonthDayHourMinuteSecond :: Generic WeekdayYearMonthDayHourMinuteSecond _
116+
117+instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
118+ formatComponent = genericFormatComponent
119+
120+newtype WeekdayYearMonthDay = WeekdayYearMonthDay
121+ { weekday :: StringRep
122+ , year :: NumericRep
123+ , month :: MonthRep
124+ , day :: NumericRep
125+ }
126+
127+derive instance genericWeekdayYearMonthDay :: Generic WeekdayYearMonthDay _
128+
129+instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
130+ formatComponent = genericFormatComponent
131+
132+newtype YearMonthDay = YearMonthDay
133+ { year :: NumericRep
134+ , month :: MonthRep
135+ , day :: NumericRep
136+ }
137+
138+derive instance genericYearMonthDay :: Generic YearMonthDay _
139+
140+instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
141+ formatComponent = genericFormatComponent
142+
143+newtype YearMonth = YearMonth
144+ { year :: NumericRep
145+ , month :: MonthRep
146+ }
147+
148+derive instance genericYearMonth :: Generic YearMonth _
149+
150+instance formatComponentYearMonth :: FormatComponent YearMonth where
151+ formatComponent = genericFormatComponent
152+
153+newtype MonthDay = MonthDay
154+ { month :: MonthRep
155+ , day :: NumericRep
156+ }
157+
158+derive instance genericMonthDay :: Generic MonthDay _
159+
160+instance formatComponentMonthDay :: FormatComponent MonthDay where
161+ formatComponent = genericFormatComponent
162+
163+newtype HourMinuteSecond = HourMinuteSecond
164+ { hour :: NumericRep
165+ , minute :: NumericRep
166+ , second :: NumericRep
167+ }
168+
169+derive instance genericHourMinuteSecond :: Generic HourMinuteSecond _
170+
171+instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
172+ formatComponent = genericFormatComponent
173+
174+newtype HourMinute = HourMinute
175+ { hour :: NumericRep
176+ , minute :: NumericRep
177+ }
178+
179+derive instance genericHourMinute :: Generic HourMinute _
180+
181+instance formatComponentHourMinute :: FormatComponent HourMinute where
182+ formatComponent = genericFormatComponent