-
Notifications
You must be signed in to change notification settings - Fork 0
/
Countries.mint
375 lines (367 loc) ยท 13.8 KB
/
Countries.mint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/* Representation of a country */
record Countries.Country {
flag : String,
code : String,
name : String
}
/* Representation of a country's state */
record Countries.State {
code : String,
name : String
}
module Countries {
/* Array(Tuple(flag, code, name)) */
const COUNTRIES =
[
{"๐ฆ๐ช", "AE", "United Arab Emirates"},
{"๐ฆ๐ซ", "AF", "Afghanistan"},
{"๐ฆ๐ฌ", "AG", "Antigua and Barbuda"},
{"๐ฆ๐ฎ", "AI", "Anguilla"},
{"๐ฆ๐ฑ", "AL", "Albania"},
{"๐ฆ๐ฒ", "AM", "Armenia"},
{"๐ฆ๐ด", "AO", "Angola"},
{"๐ฆ๐ถ", "AQ", "Antarctica"},
{"๐ฆ๐ท", "AR", "Argentina"},
{"๐ฆ๐ธ", "AS", "American Samoa"},
{"๐ฆ๐น", "AT", "Austria"},
{"๐ฆ๐บ", "AU", "Australia"},
{"๐ฆ๐ผ", "AW", "Aruba"},
{"๐ฆ๐ฝ", "AX", "ร
land Islands"},
{"๐ฆ๐ฟ", "AZ", "Azerbaijan"},
{"๐ง๐ฆ", "BA", "Bosnia and Herzegovina"},
{"๐ง๐ง", "BB", "Barbados"},
{"๐ง๐ฉ", "BD", "Bangladesh"},
{"๐ง๐ช", "BE", "Belgium"},
{"๐ง๐ซ", "BF", "Burkina Faso"},
{"๐ง๐ฌ", "BG", "Bulgaria"},
{"๐ง๐ญ", "BH", "Bahrain"},
{"๐ง๐ฎ", "BI", "Burundi"},
{"๐ง๐ฏ", "BJ", "Benin"},
{"๐ง๐ฑ", "BL", "Saint Barthรฉlemy"},
{"๐ง๐ฒ", "BM", "Bermuda"},
{"๐ง๐ณ", "BN", "Brunei Darussalam"},
{"๐ง๐ด", "BO", "Bolivia (Plurinational State of)"},
{"๐ง๐ถ", "BQ", "Bonaire, Sint Eustatius and Saba"},
{"๐ง๐ท", "BR", "Brazil"},
{"๐ง๐ธ", "BS", "Bahamas"},
{"๐ง๐น", "BT", "Bhutan"},
{"๐ง๐ป", "BV", "Bouvet Island"},
{"๐ง๐ผ", "BW", "Botswana"},
{"๐ง๐พ", "BY", "Belarus"},
{"๐ง๐ฟ", "BZ", "Belize"},
{"๐จ๐ฆ", "CA", "Canada"},
{"๐จ๐จ", "CC", "Cocos (Keeling) Islands"},
{"๐จ๐ฉ", "CD", "Congo, Democratic Republic of the"},
{"๐จ๐ซ", "CF", "Central African Republic"},
{"๐จ๐ฌ", "CG", "Congo"},
{"๐จ๐ญ", "CH", "Switzerland"},
{"๐จ๐ฎ", "CI", "Cรดte d'Ivoire"},
{"๐จ๐ฐ", "CK", "Cook Islands"},
{"๐จ๐ฑ", "CL", "Chile"},
{"๐จ๐ฒ", "CM", "Cameroon"},
{"๐จ๐ณ", "CN", "China"},
{"๐จ๐ด", "CO", "Colombia"},
{"๐จ๐ท", "CR", "Costa Rica"},
{"๐จ๐บ", "CU", "Cuba"},
{"๐จ๐ป", "CV", "Cabo Verde"},
{"๐จ๐ผ", "CW", "Curaรงao"},
{"๐จ๐ฝ", "CX", "Christmas Island"},
{"๐จ๐พ", "CY", "Cyprus"},
{"๐จ๐ฟ", "CZ", "Czechia"},
{"๐ฉ๐ช", "DE", "Germany"},
{"๐ฉ๐ฏ", "DJ", "Djibouti"},
{"๐ฉ๐ฐ", "DK", "Denmark"},
{"๐ฉ๐ฒ", "DM", "Dominica"},
{"๐ฉ๐ด", "DO", "Dominican Republic"},
{"๐ฉ๐ฟ", "DZ", "Algeria"},
{"๐ช๐จ", "EC", "Ecuador"},
{"๐ช๐ช", "EE", "Estonia"},
{"๐ช๐ฌ", "EG", "Egypt"},
{"๐ช๐ญ", "EH", "Western Sahara"},
{"๐ช๐ท", "ER", "Eritrea"},
{"๐ช๐ธ", "ES", "Spain"},
{"๐ช๐น", "ET", "Ethiopia"},
{"๐ซ๐ฎ", "FI", "Finland"},
{"๐ซ๐ฏ", "FJ", "Fiji"},
{"๐ซ๐ฐ", "FK", "Falkland Islands (Malvinas)"},
{"๐ซ๐ฒ", "FM", "Micronesia (Federated States of)"},
{"๐ซ๐ด", "FO", "Faroe Islands"},
{"๐ซ๐ท", "FR", "France"},
{"๐ฌ๐ฆ", "GA", "Gabon"},
{"๐ฌ๐ง", "GB", "United Kingdom of Great Britain and Northern Ireland"},
{"๐ฌ๐ฉ", "GD", "Grenada"},
{"๐ฌ๐ช", "GE", "Georgia"},
{"๐ฌ๐ซ", "GF", "French Guiana"},
{"๐ฌ๐ฌ", "GG", "Guernsey"},
{"๐ฌ๐ญ", "GH", "Ghana"},
{"๐ฌ๐ฎ", "GI", "Gibraltar"},
{"๐ฌ๐ฑ", "GL", "Greenland"},
{"๐ฌ๐ฒ", "GM", "Gambia"},
{"๐ฌ๐ณ", "GN", "Guinea"},
{"๐ฌ๐ต", "GP", "Guadeloupe"},
{"๐ฌ๐ถ", "GQ", "Equatorial Guinea"},
{"๐ฌ๐ท", "GR", "Greece"},
{"๐ฌ๐ธ", "GS", "South Georgia and the South Sandwich Islands"},
{"๐ฌ๐น", "GT", "Guatemala"},
{"๐ฌ๐บ", "GU", "Guam"},
{"๐ฌ๐ผ", "GW", "Guinea-Bissau"},
{"๐ฌ๐พ", "GY", "Guyana"},
{"๐ญ๐ฐ", "HK", "Hong Kong"},
{"๐ญ๐ฒ", "HM", "Heard Island and McDonald Islands"},
{"๐ญ๐ณ", "HN", "Honduras"},
{"๐ญ๐ท", "HR", "Croatia"},
{"๐ญ๐น", "HT", "Haiti"},
{"๐ญ๐บ", "HU", "Hungary"},
{"๐ฎ๐ฉ", "ID", "Indonesia"},
{"๐ฎ๐ช", "IE", "Ireland"},
{"๐ฎ๐ฑ", "IL", "Israel"},
{"๐ฎ๐ฒ", "IM", "Isle of Man"},
{"๐ฎ๐ณ", "IN", "India"},
{"๐ฎ๐ด", "IO", "British Indian Ocean Territory"},
{"๐ฎ๐ถ", "IQ", "Iraq"},
{"๐ฎ๐ท", "IR", "Iran (Islamic Republic of)"},
{"๐ฎ๐ธ", "IS", "Iceland"},
{"๐ฎ๐น", "IT", "Italy"},
{"๐ฏ๐ช", "JE", "Jersey"},
{"๐ฏ๐ฒ", "JM", "Jamaica"},
{"๐ฏ๐ด", "JO", "Jordan"},
{"๐ฏ๐ต", "JP", "Japan"},
{"๐ฐ๐ช", "KE", "Kenya"},
{"๐ฐ๐ฌ", "KG", "Kyrgyzstan"},
{"๐ฐ๐ญ", "KH", "Cambodia"},
{"๐ฐ๐ฎ", "KI", "Kiribati"},
{"๐ฐ๐ฒ", "KM", "Comoros"},
{"๐ฐ๐ณ", "KN", "Saint Kitts and Nevis"},
{"๐ฐ๐ต", "KP", "Korea (Democratic People's Republic of)"},
{"๐ฐ๐ท", "KR", "Korea, Republic of"},
{"๐ฐ๐ผ", "KW", "Kuwait"},
{"๐ฐ๐พ", "KY", "Cayman Islands"},
{"๐ฐ๐ฟ", "KZ", "Kazakhstan"},
{"๐ฑ๐ฆ", "LA", "Lao People's Democratic Republic"},
{"๐ฑ๐ง", "LB", "Lebanon"},
{"๐ฑ๐จ", "LC", "Saint Lucia"},
{"๐ฑ๐ฎ", "LI", "Liechtenstein"},
{"๐ฑ๐ฐ", "LK", "Sri Lanka"},
{"๐ฑ๐ท", "LR", "Liberia"},
{"๐ฑ๐ธ", "LS", "Lesotho"},
{"๐ฑ๐น", "LT", "Lithuania"},
{"๐ฑ๐บ", "LU", "Luxembourg"},
{"๐ฑ๐ป", "LV", "Latvia"},
{"๐ฑ๐พ", "LY", "Libya"},
{"๐ฒ๐ฆ", "MA", "Morocco"},
{"๐ฒ๐จ", "MC", "Monaco"},
{"๐ฒ๐ฉ", "MD", "Moldova, Republic of"},
{"๐ฒ๐ช", "ME", "Montenegro"},
{"๐ฒ๐ซ", "MF", "Saint Martin (French part)"},
{"๐ฒ๐ฌ", "MG", "Madagascar"},
{"๐ฒ๐ญ", "MH", "Marshall Islands"},
{"๐ฒ๐ฐ", "MK", "North Macedonia"},
{"๐ฒ๐ฑ", "ML", "Mali"},
{"๐ฒ๐ฒ", "MM", "Myanmar"},
{"๐ฒ๐ณ", "MN", "Mongolia"},
{"๐ฒ๐ด", "MO", "Macao"},
{"๐ฒ๐ต", "MP", "Northern Mariana Islands"},
{"๐ฒ๐ถ", "MQ", "Martinique"},
{"๐ฒ๐ท", "MR", "Mauritania"},
{"๐ฒ๐ธ", "MS", "Montserrat"},
{"๐ฒ๐น", "MT", "Malta"},
{"๐ฒ๐บ", "MU", "Mauritius"},
{"๐ฒ๐ป", "MV", "Maldives"},
{"๐ฒ๐ผ", "MW", "Malawi"},
{"๐ฒ๐ฝ", "MX", "Mexico"},
{"๐ฒ๐พ", "MY", "Malaysia"},
{"๐ฒ๐ฟ", "MZ", "Mozambique"},
{"๐ณ๐ฆ", "NA", "Namibia"},
{"๐ณ๐จ", "NC", "New Caledonia"},
{"๐ณ๐ช", "NE", "Niger"},
{"๐ณ๐ซ", "NF", "Norfolk Island"},
{"๐ณ๐ฌ", "NG", "Nigeria"},
{"๐ณ๐ฎ", "NI", "Nicaragua"},
{"๐ณ๐ฑ", "NL", "Netherlands"},
{"๐ณ๐ด", "NO", "Norway"},
{"๐ณ๐ต", "NP", "Nepal"},
{"๐ณ๐ท", "NR", "Nauru"},
{"๐ณ๐บ", "NU", "Niue"},
{"๐ณ๐ฟ", "NZ", "New Zealand"},
{"๐ด๐ฒ", "OM", "Oman"},
{"๐ต๐ฆ", "PA", "Panama"},
{"๐ต๐ช", "PE", "Peru"},
{"๐ต๐ซ", "PF", "French Polynesia"},
{"๐ต๐ฌ", "PG", "Papua New Guinea"},
{"๐ต๐ญ", "PH", "Philippines"},
{"๐ต๐ฐ", "PK", "Pakistan"},
{"๐ต๐ฑ", "PL", "Poland"},
{"๐ต๐ฒ", "PM", "Saint Pierre and Miquelon"},
{"๐ต๐ณ", "PN", "Pitcairn"},
{"๐ต๐ท", "PR", "Puerto Rico"},
{"๐ต๐ธ", "PS", "Palestine, State of"},
{"๐ต๐น", "PT", "Portugal"},
{"๐ต๐ผ", "PW", "Palau"},
{"๐ต๐พ", "PY", "Paraguay"},
{"๐ถ๐ฆ", "QA", "Qatar"},
{"๐ท๐ช", "RE", "Rรฉunion"},
{"๐ท๐ด", "RO", "Romania"},
{"๐ท๐ธ", "RS", "Serbia"},
{"๐ท๐บ", "RU", "Russian Federation"},
{"๐ท๐ผ", "RW", "Rwanda"},
{"๐ธ๐ฆ", "SA", "Saudi Arabia"},
{"๐ธ๐ง", "SB", "Solomon Islands"},
{"๐ธ๐จ", "SC", "Seychelles"},
{"๐ธ๐ฉ", "SD", "Sudan"},
{"๐ธ๐ช", "SE", "Sweden"},
{"๐ธ๐ฌ", "SG", "Singapore"},
{"๐ธ๐ญ", "SH", "Saint Helena, Ascension and Tristan da Cunha"},
{"๐ธ๐ฎ", "SI", "Slovenia"},
{"๐ธ๐ฏ", "SJ", "Svalbard and Jan Mayen"},
{"๐ธ๐ฐ", "SK", "Slovakia"},
{"๐ธ๐ฑ", "SL", "Sierra Leone"},
{"๐ธ๐ฒ", "SM", "San Marino"},
{"๐ธ๐ณ", "SN", "Senegal"},
{"๐ธ๐ด", "SO", "Somalia"},
{"๐ธ๐ท", "SR", "Suriname"},
{"๐ธ๐ธ", "SS", "South Sudan"},
{"๐ธ๐น", "ST", "Sao Tome and Principe"},
{"๐ธ๐ป", "SV", "El Salvador"},
{"๐ธ๐ฝ", "SX", "Sint Maarten (Dutch part)"},
{"๐ธ๐พ", "SY", "Syrian Arab Republic"},
{"๐ธ๐ฟ", "SZ", "Eswatini"},
{"๐น๐จ", "TC", "Turks and Caicos Islands"},
{"๐น๐ฉ", "TD", "Chad"},
{"๐น๐ซ", "TF", "French Southern Territories"},
{"๐น๐ฌ", "TG", "Togo"},
{"๐น๐ญ", "TH", "Thailand"},
{"๐น๐ฏ", "TJ", "Tajikistan"},
{"๐น๐ฐ", "TK", "Tokelau"},
{"๐น๐ฑ", "TL", "Timor-Leste"},
{"๐น๐ฒ", "TM", "Turkmenistan"},
{"๐น๐ณ", "TN", "Tunisia"},
{"๐น๐ด", "TO", "Tonga"},
{"๐น๐ท", "TR", "Turkey"},
{"๐น๐น", "TT", "Trinidad and Tobago"},
{"๐น๐ป", "TV", "Tuvalu"},
{"๐น๐ผ", "TW", "Taiwan, Province of China"},
{"๐น๐ฟ", "TZ", "Tanzania, United Republic of"},
{"๐บ๐ฆ", "UA", "Ukraine"},
{"๐บ๐ฌ", "UG", "Uganda"},
{"๐บ๐ฒ", "UM", "United States Minor Outlying Islands"},
{"๐บ๐ธ", "US", "United States of America"},
{"๐บ๐พ", "UY", "Uruguay"},
{"๐บ๐ฟ", "UZ", "Uzbekistan"},
{"๐ป๐ฆ", "VA", "Holy See"},
{"๐ป๐จ", "VC", "Saint Vincent and the Grenadines"},
{"๐ป๐ช", "VE", "Venezuela (Bolivarian Republic of)"},
{"๐ป๐ฌ", "VG", "Virgin Islands (British)"},
{"๐ป๐ฎ", "VI", "Virgin Islands (U.S.)"},
{"๐ป๐ณ", "VN", "Viet Nam"},
{"๐ป๐บ", "VU", "Vanuatu"},
{"๐ผ๐ซ", "WF", "Wallis and Futuna"},
{"๐ผ๐ธ", "WS", "Samoa"},
{"๐พ๐ช", "YE", "Yemen"},
{"๐พ๐น", "YT", "Mayotte"},
{"๐ฟ๐ฆ", "ZA", "South Africa"},
{"๐ฟ๐ฒ", "ZM", "Zambia"},
{"๐ฟ๐ผ", "ZW", "Zimbabwe"}
]
/* Array(Tuple(country, code, name)) */
const STATES =
[
{"CA", "AB", "Alberta"},
{"CA", "BC", "British Columbia"},
{"CA", "MB", "Manitoba"},
{"CA", "NB", "New Brunswick"},
{"CA", "NL", "Newfoundland"},
{"CA", "NT", "Northwest Territories"},
{"CA", "NS", "Nova Scotia"},
{"CA", "NU", "Nunavut"},
{"CA", "ON", "Ontario"},
{"CA", "PE", "Prince Edward Island"},
{"CA", "QC", "Quebec"},
{"CA", "SK", "Saskatchewan"},
{"CA", "YT", "Yukon"},
{"US", "AL", "Alabama"},
{"US", "AK", "Alaska"},
{"US", "AS", "America Samoa"},
{"US", "AZ", "Arizona"},
{"US", "AR", "Arkansas"},
{"US", "AA", "Armed Forces Americas"},
{"US", "AE", "Armed Forces"},
{"US", "AP", "Armed Forces Pacific"},
{"US", "CA", "California"},
{"US", "CO", "Colorado"},
{"US", "CT", "Connecticut"},
{"US", "DE", "Delaware"},
{"US", "DC", "District of Columbia"},
{"US", "FM", "Federated States of Micronesia"},
{"US", "FL", "Florida"},
{"US", "GA", "Georgia"},
{"US", "GU", "Guam"},
{"US", "HI", "Hawaii"},
{"US", "ID", "Idaho"},
{"US", "IL", "Illinois"},
{"US", "IN", "Indiana"},
{"US", "IA", "Iowa"},
{"US", "KS", "Kansas"},
{"US", "KY", "Kentucky"},
{"US", "LA", "Louisiana"},
{"US", "ME", "Maine"},
{"US", "MH", "Marshall Islands"},
{"US", "MD", "Maryland"},
{"US", "MA", "Massachusetts"},
{"US", "MI", "Michigan"},
{"US", "MN", "Minnesota"},
{"US", "MS", "Mississippi"},
{"US", "MO", "Missouri"},
{"US", "MT", "Montana"},
{"US", "NE", "Nebraska"},
{"US", "NV", "Nevada"},
{"US", "NH", "New Hampshire"},
{"US", "NJ", "New Jersey"},
{"US", "NM", "New Mexico"},
{"US", "NY", "New York"},
{"US", "NC", "North Carolina"},
{"US", "ND", "North Dakota"},
{"US", "MP", "Northern Mariana Islands"},
{"US", "OH", "Ohio"},
{"US", "OK", "Oklahoma"},
{"US", "OR", "Oregon"},
{"US", "PA", "Pennsylvania"},
{"US", "PR", "Puerto Rico"},
{"US", "PW", "Palau"},
{"US", "RI", "Rhode Island"},
{"US", "SC", "South Carolina"},
{"US", "SD", "South Dakota"},
{"US", "TN", "Tennessee"},
{"US", "TX", "Texas"},
{"US", "UT", "Utah"},
{"US", "VA", "Virginia"},
{"US", "VI", "Virgin Islands"},
{"US", "VT", "Vermont"},
{"US", "WA", "Washington"},
{"US", "WI", "Wisconsin"},
{"US", "WV", "West Virginia"},
{"US", "WY", "Wyoming"}
]
/* Return all countries */
fun all : Array(Countries.Country) {
Array.map(
COUNTRIES,
(item : Tuple(String, String, String)) { Countries.Country(item[0], item[1], item[2]) })
}
/* Return country information from country code */
fun fromCode (code : String) : Maybe(Countries.Country) {
let country =
Array.find(COUNTRIES, (item : Tuple(String, String, String)) : Bool { code == item[1] })
case country {
Maybe::Just(item) =>
Maybe::Just(Countries.Country(item[0], item[1], item[2]))
Maybe::Nothing =>
Maybe::Nothing
}
}
/* Returns states filtered by country code */
fun states (code : String) : Array(Countries.State) {
STATES
|> Array.select((item : Tuple(String, String, String)) { code == item[0] })
|> Array.map((item : Tuple(String, String, String)) { Countries.State(item[1], item[2]) })
}
}