packages feed

country 0.1.3 → 0.1.4

raw patch · 8 files changed

+591/−313 lines, 8 filesdep ~aesondep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, base

API changes (from Hackage documentation)

+ Country: decodeUtf8 :: ByteString -> Maybe Country
+ Country.Identifier: kosovo :: Country

Files

country.cabal view
@@ -1,5 +1,5 @@ name: country-version: 0.1.3+version: 0.1.4 synopsis: Country data type and functions description:   The `country` library provides a data type for dealing with@@ -35,13 +35,12 @@     Country.Unsafe   other-modules:     Country.Unexposed.Encode.English-    Country.Unexposed.Enumerate-    Country.Unexposed.ExtraNames     Country.Unexposed.Names     Country.Unexposed.Trie     Country.Unexposed.TrieByte+    Country.Unexposed.Alias   build-depends:-      base >= 4.7 && < 4.10+      base >= 4.7 && < 4.11     , text >= 1.2 && < 1.3     , bytestring >= 0.10 && < 0.11     , primitive >= 0.6.1 && < 0.7
src/Country.hs view
@@ -11,6 +11,7 @@     -- * Name   , encodeEnglish   , decode+  , decodeUtf8   , parser   , parserUtf8     -- * Alpha-2 and Alpha-3@@ -24,10 +25,11 @@  import Country.Unsafe (Country(..)) import Country.Unexposed.Encode.English (countryNameQuads)-import Country.Unexposed.Names (numberOfPossibleCodes,alphaTwoHashMap,alphaThreeHashMap,decodeMap,decodeNumeric,encodeEnglish)+import Country.Unexposed.Names (numberOfPossibleCodes,alphaTwoHashMap,alphaThreeHashMap,decodeMap,decodeMapUtf8,decodeNumeric,encodeEnglish) import Country.Unexposed.Trie (Trie,trieFromList,trieParser) import Country.Unexposed.TrieByte (TrieByte,trieByteFromList,trieByteParser) import Data.Text (Text)+import Data.ByteString (ByteString) import Data.Word (Word16) import Data.Primitive (indexArray,writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray) import Data.Primitive.Array (Array(..))@@ -84,10 +86,17 @@ timesThree x = x * 3  --- | Parse a country from its name. This function is language-agnostic.---   It can handle any source language.+-- | Parse a country from its name. This function is language-agnostic+--   and is very generous with what it accepts. It handles official+--   names, colloquial names, acroynms, and obsolete names for many+--   countries. It strives to handle any source language. Open an+--   issue on the issue tracker if their are names that are+--   missing. decode :: Text -> Maybe Country decode = flip HM.lookup decodeMap++decodeUtf8 :: ByteString -> Maybe Country+decodeUtf8 = flip HM.lookup decodeMapUtf8  -- | Parse a country from its name using an attoparsec text parser. This --   function is language-agnostic and can handle any source language.
src/Country/Identifier.hs view
@@ -751,3 +751,6 @@ zimbabwe :: Country zimbabwe = Country 716 +kosovo :: Country+kosovo = Country 383+
+ src/Country/Unexposed/Alias.hs view
@@ -0,0 +1,521 @@+-- This module is autogenerated. Do not edit it by hand.+module Country.Unexposed.Alias+  ( aliases+  ) where++import Data.Text (Text)+import Data.Word (Word16)+import qualified Data.Text as T++aliases :: [(Word16,Text)]+aliases =+  [ (4, T.pack "Afghanistan")+  , (248, T.pack "Åland Islands")+  , (248, T.pack "Aaland Islands")+  , (248, T.pack "Aland Islands")+  , (8, T.pack "Albania")+  , (8, T.pack "Arbanon")+  , (8, T.pack "Republic of Albania")+  , (8, T.pack "Republika e Shqipërisë")+  , (12, T.pack "Algeria")+  , (12, T.pack "Algérie")+  , (12, T.pack "Dzayer")+  , (12, T.pack "People's Democratic Republic of Algeria")+  , (12, T.pack "al Jumhuriyya al Jazaa'iriyya ad-Dīmuqrāţiyya ash Sha'biyya")+  , (12, T.pack "al-Jazā'ir")+  , (12, T.pack "الجزائر")+  , (12, T.pack "ⴷⵣⴰⵢⴻⵔ")+  , (16, T.pack "American Samoa")+  , (20, T.pack "Andorra")+  , (24, T.pack "Angola")+  , (660, T.pack "Anguilla")+  , (10, T.pack "Antarctica")+  , (28, T.pack "Antigua and Barbuda")+  , (32, T.pack "Argentina")+  , (32, T.pack "Argentine Confederation")+  , (32, T.pack "Argentine Nation")+  , (32, T.pack "Argentine Republic")+  , (32, T.pack "La Argentina")+  , (32, T.pack "The Argentine")+  , (32, T.pack "United Provinces of the Río de la Plata")+  , (32, T.pack "la Argentina")+  , (32, T.pack "the Argentine")+  , (51, T.pack "Armenia")+  , (533, T.pack "Aruba")+  , (36, T.pack "Australia")+  , (36, T.pack "Commonwealth of Australia")+  , (36, T.pack "New Holland")+  , (40, T.pack "Austria")+  , (40, T.pack "Republic of Austria")+  , (40, T.pack "Republik Österreich")+  , (40, T.pack "Österreich")+  , (31, T.pack "Azerbaijan")+  , (44, T.pack "Bahamas")+  , (48, T.pack "Bahrain")+  , (50, T.pack "Bangladesh")+  , (52, T.pack "Barbados")+  , (112, T.pack "Belarus")+  , (56, T.pack "Belgium")+  , (84, T.pack "Belize")+  , (204, T.pack "Benin")+  , (60, T.pack "Bermuda")+  , (64, T.pack "Bhutan")+  , (68, T.pack "Bolivia (Plurinational State of)")+  , (535, T.pack "Bonaire, Sint Eustatius and Saba")+  , (70, T.pack "Bosnia and Herzegovina")+  , (72, T.pack "Botswana")+  , (74, T.pack "Bouvet Island")+  , (76, T.pack "Brazil")+  , (76, T.pack "Empire of Brazil")+  , (76, T.pack "Federative Republic of Brazil")+  , (76, T.pack "Ilha de Vera Cruz")+  , (76, T.pack "Pindorama")+  , (76, T.pack "República Federativa do Brasil")+  , (76, T.pack "Terra de Santa Cruz")+  , (76, T.pack "Terra di Papaga")+  , (76, T.pack "United States of Brazil")+  , (86, T.pack "British Indian Ocean Territory")+  , (96, T.pack "Brunei Darussalam")+  , (100, T.pack "Bulgaria")+  , (854, T.pack "Burkina Faso")+  , (108, T.pack "Burundi")+  , (116, T.pack "Cambodia")+  , (116, T.pack "Democratic Kampuchea")+  , (116, T.pack "Kingdom of Cambodia")+  , (116, T.pack "Royaume du Cambodge")+  , (120, T.pack "Cameroon")+  , (124, T.pack "Canada")+  , (132, T.pack "Cabo Verde")+  , (132, T.pack "Cape Verde")+  , (136, T.pack "Cayman Islands")+  , (140, T.pack "Central African Republic")+  , (148, T.pack "Chad")+  , (152, T.pack "Chile")+  , (152, T.pack "Capitania general de Chile")+  , (152, T.pack "Chili")+  , (152, T.pack "Chilli")+  , (152, T.pack "Republic of Chile")+  , (152, T.pack "Reyno de Chile")+  , (156, T.pack "China")+  , (162, T.pack "Christmas Island")+  , (166, T.pack "Cocos (Keeling) Islands")+  , (170, T.pack "Colombia")+  , (174, T.pack "Comoros")+  , (178, T.pack "Congo")+  , (180, T.pack "Congo (Democratic Republic of the)")+  , (184, T.pack "Cook Islands")+  , (188, T.pack "Costa Rica")+  , (384, T.pack "Côte d'Ivoire")+  , (384, T.pack "Ivory Coast")+  , (384, T.pack "Republic of Côte d'Ivoire")+  , (191, T.pack "Croatia")+  , (192, T.pack "Cuba")+  , (531, T.pack "Curaçao")+  , (196, T.pack "Cyprus")+  , (203, T.pack "Czech Republic")+  , (208, T.pack "Denmark")+  , (208, T.pack "Danmark")+  , (208, T.pack "Kingdom of Denmark")+  , (208, T.pack "Kongeriget Danmark")+  , (262, T.pack "Djibouti")+  , (262, T.pack "Côte française des Somalis, Territoire d'Obock")+  , (262, T.pack "French Somaliland")+  , (262, T.pack "French Territory of the Afars and the Issas")+  , (262, T.pack "Obock Territory")+  , (262, T.pack "Republic of Djibouti")+  , (262, T.pack "République de Djibouti")+  , (262, T.pack "Territoire français des Afars et des Issas")+  , (212, T.pack "Dominica")+  , (214, T.pack "Dominican Republic")+  , (218, T.pack "Ecuador")+  , (818, T.pack "Egypt")+  , (818, T.pack "Aegyptus")+  , (818, T.pack "Meṣr")+  , (222, T.pack "El Salvador")+  , (226, T.pack "Equatorial Guinea")+  , (232, T.pack "Eritrea")+  , (233, T.pack "Estonia")+  , (231, T.pack "Ethiopia")+  , (238, T.pack "Falkland Islands (Malvinas)")+  , (234, T.pack "Faroe Islands")+  , (242, T.pack "Fiji")+  , (246, T.pack "Finland")+  , (250, T.pack "France")+  , (250, T.pack "Farança")+  , (250, T.pack "French Republic")+  , (250, T.pack "La France")+  , (250, T.pack "République Française")+  , (254, T.pack "French Guiana")+  , (258, T.pack "French Polynesia")+  , (260, T.pack "French Southern Territories")+  , (266, T.pack "Gabon")+  , (270, T.pack "Gambia")+  , (268, T.pack "Georgia")+  , (276, T.pack "Germany")+  , (276, T.pack "BRD")+  , (276, T.pack "Bundesrepublik Deutschland")+  , (276, T.pack "Deutschland")+  , (276, T.pack "FRG")+  , (276, T.pack "Federal Republic of Germany")+  , (288, T.pack "Ghana")+  , (292, T.pack "Gibraltar")+  , (300, T.pack "Greece")+  , (304, T.pack "Greenland")+  , (308, T.pack "Grenada")+  , (312, T.pack "Guadeloupe")+  , (316, T.pack "Guam")+  , (320, T.pack "Guatemala")+  , (831, T.pack "Guernsey")+  , (324, T.pack "Guinea")+  , (624, T.pack "Guinea-Bissau")+  , (328, T.pack "Guyana")+  , (332, T.pack "Haiti")+  , (334, T.pack "Heard Island and McDonald Islands")+  , (336, T.pack "Holy See")+  , (340, T.pack "Honduras")+  , (344, T.pack "Hong Kong")+  , (348, T.pack "Hungary")+  , (352, T.pack "Iceland")+  , (352, T.pack "Lýðveldið Ísland")+  , (352, T.pack "Republic of Iceland")+  , (352, T.pack "Ísafold")+  , (352, T.pack "Ísland")+  , (356, T.pack "India")+  , (356, T.pack "Al-Hind")+  , (356, T.pack "Aryavarta")+  , (356, T.pack "Bharatham")+  , (356, T.pack "Bhārat")+  , (356, T.pack "Bhārat Gaṇarājya")+  , (356, T.pack "Bhārat Prajatantra")+  , (356, T.pack "Bhāratadēśaṁ")+  , (356, T.pack "Bhāratavarṣa")+  , (356, T.pack "Hind")+  , (356, T.pack "Hindustan")+  , (356, T.pack "Republic of India")+  , (356, T.pack "Union of India")+  , (356, T.pack "ഇന്ത്യ")+  , (360, T.pack "Indonesia")+  , (364, T.pack "Iran (Islamic Republic of)")+  , (368, T.pack "Iraq")+  , (368, T.pack "Assyria")+  , (368, T.pack "Babylon")+  , (368, T.pack "Mesopotamia")+  , (372, T.pack "Ireland")+  , (372, T.pack "Irish Free State")+  , (372, T.pack "Republic of Ireland")+  , (372, T.pack "Saorstát Éireann")+  , (372, T.pack "Éire")+  , (833, T.pack "Isle of Man")+  , (376, T.pack "Israel")+  , (376, T.pack "Dawlat Isra'il")+  , (376, T.pack "Hebrew State")+  , (376, T.pack "Jewish State")+  , (376, T.pack "Medinat Yisra'el")+  , (376, T.pack "State of Israel")+  , (376, T.pack "The Hebrew State")+  , (376, T.pack "The Jewish State")+  , (376, T.pack "מדינת ישראל")+  , (376, T.pack "دَوْلَة إِسْرَائِيل")+  , (380, T.pack "Italy")+  , (380, T.pack "Repubblica Italiana")+  , (388, T.pack "Jamaica")+  , (388, T.pack "Xamayca")+  , (392, T.pack "Japan")+  , (832, T.pack "Jersey")+  , (400, T.pack "Jordan")+  , (400, T.pack "Hashemite Kingdom of Jordan")+  , (398, T.pack "Kazakhstan")+  , (398, T.pack "Kazakh Soviet Socialist Republic")+  , (398, T.pack "Qazaq Keñestik Socïalïstik Respwblïkası")+  , (398, T.pack "Qazaqstan")+  , (398, T.pack "Republic of Kazakhstan")+  , (398, T.pack "Қазақ Кеңестік Социалистік Республикасы")+  , (398, T.pack "Қазақстан")+  , (398, T.pack "Қазақстан Республикасы")+  , (404, T.pack "Kenya")+  , (404, T.pack "Jamhuri ya Kenya")+  , (404, T.pack "Republic of Kenya")+  , (296, T.pack "Kiribati")+  , (408, T.pack "Korea (Democratic People's Republic of)")+  , (410, T.pack "Korea (Republic of)")+  , (414, T.pack "Kuwait")+  , (417, T.pack "Kyrgyzstan")+  , (418, T.pack "Lao People's Democratic Republic")+  , (428, T.pack "Latvia")+  , (428, T.pack "Latvija")+  , (428, T.pack "Letland")+  , (428, T.pack "Letonija")+  , (428, T.pack "Letonnie")+  , (428, T.pack "Lettland")+  , (422, T.pack "Lebanon")+  , (426, T.pack "Lesotho")+  , (426, T.pack "Basutoland")+  , (426, T.pack "Kingdom of Lesotho")+  , (430, T.pack "Liberia")+  , (434, T.pack "Libya")+  , (438, T.pack "Liechtenstein")+  , (440, T.pack "Lithuania")+  , (440, T.pack "Lietuva")+  , (440, T.pack "Литва")+  , (442, T.pack "Luxembourg")+  , (442, T.pack "Grand Duchy of Luxembourg")+  , (442, T.pack "Grand-Duché de Luxembourg")+  , (442, T.pack "Groussherzogdem Lëtzebuerg")+  , (442, T.pack "Großherzogtum Luxemburg")+  , (442, T.pack "Lussemburgo")+  , (442, T.pack "Luxemburg")+  , (442, T.pack "Luxemburgo")+  , (446, T.pack "Macao")+  , (807, T.pack "Macedonia (the former Yugoslav Republic of)")+  , (450, T.pack "Madagascar")+  , (454, T.pack "Malawi")+  , (454, T.pack "Nyasaland")+  , (454, T.pack "Republic of Malawi")+  , (458, T.pack "Malaysia")+  , (458, T.pack "Federation of Malaysia")+  , (458, T.pack "Mǎláixīyà")+  , (458, T.pack "Persekutuan Malaysia")+  , (458, T.pack "马来西亚")+  , (462, T.pack "Maldives")+  , (462, T.pack "Dhibat-al-Mahal")+  , (462, T.pack "Dhivehi Raajje")+  , (462, T.pack "Mahal Dvipa")+  , (462, T.pack "Maléldvipa")+  , (462, T.pack "Republic of the Maldives")+  , (462, T.pack "The Maldive Islands")+  , (462, T.pack "ދިވެހިރާއްޖެ")+  , (466, T.pack "Mali")+  , (470, T.pack "Malta")+  , (584, T.pack "Marshall Islands")+  , (474, T.pack "Martinique")+  , (478, T.pack "Mauritania")+  , (478, T.pack "Islamic Republic of Mauritania")+  , (478, T.pack "République Islamique de Mauritanie")+  , (480, T.pack "Mauritius")+  , (175, T.pack "Mayotte")+  , (484, T.pack "Mexico")+  , (484, T.pack "Aztlán")+  , (484, T.pack "Aztlān")+  , (484, T.pack "Estados Unidos Mexicanos")+  , (484, T.pack "MX")+  , (484, T.pack "Mejico")+  , (484, T.pack "Méjico")+  , (484, T.pack "México")+  , (484, T.pack "República Mexicana")+  , (484, T.pack "United Mexican States")+  , (583, T.pack "Micronesia (Federated States of)")+  , (498, T.pack "Moldova (Republic of)")+  , (492, T.pack "Monaco")+  , (496, T.pack "Mongolia")+  , (499, T.pack "Montenegro")+  , (499, T.pack "Republic of Singapore")+  , (499, T.pack "Singapore")+  , (499, T.pack "Singapura")+  , (499, T.pack "Yugoslavia")+  , (500, T.pack "Montserrat")+  , (504, T.pack "Morocco")+  , (508, T.pack "Mozambique")+  , (104, T.pack "Myanmar")+  , (516, T.pack "Namibia")+  , (520, T.pack "Nauru")+  , (524, T.pack "Nepal")+  , (528, T.pack "Netherlands")+  , (540, T.pack "New Caledonia")+  , (554, T.pack "New Zealand")+  , (558, T.pack "Nicaragua")+  , (562, T.pack "Niger")+  , (566, T.pack "Nigeria")+  , (570, T.pack "Niue")+  , (574, T.pack "Norfolk Island")+  , (580, T.pack "Northern Mariana Islands")+  , (578, T.pack "Norway")+  , (512, T.pack "Oman")+  , (586, T.pack "Pakistan")+  , (585, T.pack "Palau")+  , (275, T.pack "Palestine, State of")+  , (591, T.pack "Panama")+  , (598, T.pack "Papua New Guinea")+  , (600, T.pack "Paraguay")+  , (604, T.pack "Peru")+  , (608, T.pack "Philippines")+  , (612, T.pack "Pitcairn")+  , (616, T.pack "Poland")+  , (620, T.pack "Portugal")+  , (630, T.pack "Puerto Rico")+  , (634, T.pack "Qatar")+  , (638, T.pack "Réunion")+  , (642, T.pack "Romania")+  , (642, T.pack "Kingdom of Romania")+  , (642, T.pack "Regatul României")+  , (642, T.pack "Republica Populară Romînă")+  , (642, T.pack "Republica Socialistă România")+  , (642, T.pack "Romanian People's Republic")+  , (642, T.pack "România")+  , (642, T.pack "Roumania")+  , (642, T.pack "Rumania")+  , (642, T.pack "Socialist Republic of Romania")+  , (643, T.pack "Russian Federation")+  , (643, T.pack "Great Russia")+  , (643, T.pack "R.F.")+  , (643, T.pack "RF")+  , (643, T.pack "RSFSR")+  , (643, T.pack "Rossiya")+  , (643, T.pack "Rus")+  , (643, T.pack "Russia")+  , (643, T.pack "Russian Socialist Federative Soviet Republic")+  , (643, T.pack "Russian Soviet Federative Socialist Republic")+  , (643, T.pack "Russland")+  , (643, T.pack "SSSR")+  , (643, T.pack "SU")+  , (643, T.pack "Sovetskiy Soyuz")+  , (643, T.pack "Soviet Union")+  , (643, T.pack "Soyuz Sovetskikh Sotsialisticheskikh Respublik")+  , (643, T.pack "USSR")+  , (643, T.pack "Union of Soviet Socialist Republics")+  , (643, T.pack "Российская Федерация")+  , (643, T.pack "Россия")+  , (643, T.pack "СССР")+  , (643, T.pack "Сове́тский Сою́з")+  , (643, T.pack "Союз Советских Социалистических Республик")+  , (646, T.pack "Rwanda")+  , (646, T.pack "Republic of Rwanda")+  , (646, T.pack "Repubulika y'u Rwanda")+  , (646, T.pack "Ruanda")+  , (646, T.pack "Rwandese Republic")+  , (646, T.pack "République du Rwanda")+  , (652, T.pack "Saint Barthélemy")+  , (654, T.pack "Saint Helena, Ascension and Tristan da Cunha")+  , (659, T.pack "Saint Kitts and Nevis")+  , (659, T.pack "Federation of Saint Kitts and Nevis")+  , (659, T.pack "Saint Kitts-Nevis-Anguilla")+  , (662, T.pack "Saint Lucia")+  , (663, T.pack "Saint Martin (French part)")+  , (666, T.pack "Saint Pierre and Miquelon")+  , (670, T.pack "Saint Vincent and the Grenadines")+  , (882, T.pack "Samoa")+  , (674, T.pack "San Marino")+  , (678, T.pack "Sao Tome and Principe")+  , (682, T.pack "Saudi Arabia")+  , (686, T.pack "Senegal")+  , (688, T.pack "Serbia")+  , (690, T.pack "Seychelles")+  , (694, T.pack "Sierra Leone")+  , (702, T.pack "Singapore")+  , (702, T.pack "Montenegro")+  , (702, T.pack "Republic of Singapore")+  , (702, T.pack "Singapura")+  , (702, T.pack "Yugoslavia")+  , (534, T.pack "Sint Maarten (Dutch part)")+  , (703, T.pack "Slovakia")+  , (705, T.pack "Slovenia")+  , (90, T.pack "Solomon Islands")+  , (706, T.pack "Somalia")+  , (710, T.pack "South Africa")+  , (239, T.pack "South Georgia and the South Sandwich Islands")+  , (728, T.pack "South Sudan")+  , (724, T.pack "Spain")+  , (724, T.pack "Espainia")+  , (724, T.pack "Espanya")+  , (724, T.pack "España")+  , (724, T.pack "Hispania")+  , (724, T.pack "Iberia")+  , (724, T.pack "Reino de España")+  , (724, T.pack "Spanish State")+  , (144, T.pack "Sri Lanka")+  , (729, T.pack "Sudan")+  , (729, T.pack "Nubia")+  , (729, T.pack "Republic of the Sudan")+  , (729, T.pack "The Sudan")+  , (740, T.pack "Suriname")+  , (740, T.pack "Dutch Guiana")+  , (740, T.pack "Netherlands Guiana")+  , (740, T.pack "Republic of Suriname")+  , (740, T.pack "Republiek Suriname")+  , (740, T.pack "Surinam")+  , (744, T.pack "Svalbard and Jan Mayen")+  , (748, T.pack "Swaziland")+  , (752, T.pack "Sweden")+  , (752, T.pack "Kingdom of Sweden")+  , (752, T.pack "Konungariket Sverige")+  , (752, T.pack "Svea Rike")+  , (752, T.pack "Sverige")+  , (752, T.pack "Svitjod")+  , (756, T.pack "Switzerland")+  , (756, T.pack "CH")+  , (756, T.pack "Confederazione Svizzera")+  , (756, T.pack "Confederaziun Svizra")+  , (756, T.pack "Confoederatio Helvetica")+  , (756, T.pack "Confédération suisse")+  , (756, T.pack "Helvetia")+  , (756, T.pack "Schweiz")+  , (756, T.pack "Schweizerische Eidgenossenschaft")+  , (756, T.pack "Suisse")+  , (756, T.pack "Svizra")+  , (756, T.pack "Svizzera")+  , (756, T.pack "Swiss Confederation")+  , (760, T.pack "Syrian Arab Republic")+  , (158, T.pack "Taiwan, Province of China")+  , (158, T.pack "Chinese Taipei")+  , (158, T.pack "Republic of China")+  , (158, T.pack "Separate Customs Territory of Taiwan, Penghu, Kinmen and Matsu")+  , (158, T.pack "Taiwan")+  , (158, T.pack "Zhonggua Taipei")+  , (158, T.pack "中華台北")+  , (762, T.pack "Tajikistan")+  , (834, T.pack "Tanzania, United Republic of")+  , (764, T.pack "Thailand")+  , (626, T.pack "Timor-Leste")+  , (768, T.pack "Togo")+  , (772, T.pack "Tokelau")+  , (776, T.pack "Tonga")+  , (780, T.pack "Trinidad and Tobago")+  , (780, T.pack "Republic of Trinidad and Tobago")+  , (780, T.pack "Trinbago")+  , (788, T.pack "Tunisia")+  , (792, T.pack "Turkey")+  , (792, T.pack "Ottoman Empire")+  , (792, T.pack "Republic of Turkey")+  , (792, T.pack "Turkish Empire")+  , (792, T.pack "Türkiye Cumhuriyeti")+  , (795, T.pack "Turkmenistan")+  , (796, T.pack "Turks and Caicos Islands")+  , (798, T.pack "Tuvalu")+  , (800, T.pack "Uganda")+  , (804, T.pack "Ukraine")+  , (804, T.pack "UA")+  , (804, T.pack "UKR")+  , (804, T.pack "Ukraїna")+  , (784, T.pack "United Arab Emirates")+  , (784, T.pack "Al Emirat al Arabbiya al Muttahida")+  , (784, T.pack "U.A.E.")+  , (784, T.pack "UAE")+  , (826, T.pack "United Kingdom of Great Britain and Northern Ireland")+  , (840, T.pack "United States of America")+  , (840, T.pack "Estados Unidos de América")+  , (840, T.pack "The United States")+  , (840, T.pack "U.S.")+  , (840, T.pack "U.S.A.")+  , (840, T.pack "USA")+  , (840, T.pack "United States")+  , (840, T.pack "Usa")+  , (840, T.pack "Usono")+  , (581, T.pack "United States Minor Outlying Islands")+  , (858, T.pack "Uruguay")+  , (860, T.pack "Uzbekistan")+  , (548, T.pack "Vanuatu")+  , (548, T.pack "Ripablik blong Vanuatu")+  , (548, T.pack "République de Vanuatu")+  , (862, T.pack "Venezuela (Bolivarian Republic of)")+  , (704, T.pack "Viet Nam")+  , (92, T.pack "Virgin Islands (British)")+  , (850, T.pack "Virgin Islands (U.S.)")+  , (876, T.pack "Wallis and Futuna")+  , (732, T.pack "Western Sahara")+  , (887, T.pack "Yemen")+  , (894, T.pack "Zambia")+  , (894, T.pack "Republic of Zambia")+  , (716, T.pack "Zimbabwe")+  , (716, T.pack "Republic of Zimbabwe")+  , (383, T.pack "Kosovo")+  ]+{-# NOINLINE aliases #-}
src/Country/Unexposed/Encode/English.hs view
@@ -260,5 +260,6 @@   , (887, T.pack "Yemen",('Y','E'),('Y','E','M'))   , (894, T.pack "Zambia",('Z','M'),('Z','M','B'))   , (716, T.pack "Zimbabwe",('Z','W'),('Z','W','E'))+  , (383, T.pack "Kosovo",('X','K'),('X','K','X'))   ] {-# NOINLINE countryNameQuads #-}
− src/Country/Unexposed/Enumerate.hs
@@ -1,258 +0,0 @@-module Country.Unexposed.Enumerate where---- This module is autogenerated. Do not edit it by hand.--import Data.Word (Word16)--enumeratedCountries :: [Word16]-enumeratedCountries =-  [ 4-  , 248-  , 8-  , 12-  , 16-  , 20-  , 24-  , 660-  , 10-  , 28-  , 32-  , 51-  , 533-  , 36-  , 40-  , 31-  , 44-  , 48-  , 50-  , 52-  , 112-  , 56-  , 84-  , 204-  , 60-  , 64-  , 68-  , 535-  , 70-  , 72-  , 74-  , 76-  , 86-  , 96-  , 100-  , 854-  , 108-  , 116-  , 120-  , 124-  , 132-  , 136-  , 140-  , 148-  , 152-  , 156-  , 162-  , 166-  , 170-  , 174-  , 178-  , 180-  , 184-  , 188-  , 384-  , 191-  , 192-  , 531-  , 196-  , 203-  , 208-  , 262-  , 212-  , 214-  , 218-  , 818-  , 222-  , 226-  , 232-  , 233-  , 231-  , 238-  , 234-  , 242-  , 246-  , 250-  , 254-  , 258-  , 260-  , 266-  , 270-  , 268-  , 276-  , 288-  , 292-  , 300-  , 304-  , 308-  , 312-  , 316-  , 320-  , 831-  , 324-  , 624-  , 328-  , 332-  , 334-  , 336-  , 340-  , 344-  , 348-  , 352-  , 356-  , 360-  , 364-  , 368-  , 372-  , 833-  , 376-  , 380-  , 388-  , 392-  , 832-  , 400-  , 398-  , 404-  , 296-  , 408-  , 410-  , 414-  , 417-  , 418-  , 428-  , 422-  , 426-  , 430-  , 434-  , 438-  , 440-  , 442-  , 446-  , 807-  , 450-  , 454-  , 458-  , 462-  , 466-  , 470-  , 584-  , 474-  , 478-  , 480-  , 175-  , 484-  , 583-  , 498-  , 492-  , 496-  , 499-  , 500-  , 504-  , 508-  , 104-  , 516-  , 520-  , 524-  , 528-  , 540-  , 554-  , 558-  , 562-  , 566-  , 570-  , 574-  , 580-  , 578-  , 512-  , 586-  , 585-  , 275-  , 591-  , 598-  , 600-  , 604-  , 608-  , 612-  , 616-  , 620-  , 630-  , 634-  , 638-  , 642-  , 643-  , 646-  , 652-  , 654-  , 659-  , 662-  , 663-  , 666-  , 670-  , 882-  , 674-  , 678-  , 682-  , 686-  , 688-  , 690-  , 694-  , 702-  , 534-  , 703-  , 705-  , 90-  , 706-  , 710-  , 239-  , 728-  , 724-  , 144-  , 729-  , 740-  , 744-  , 748-  , 752-  , 756-  , 760-  , 158-  , 762-  , 834-  , 764-  , 626-  , 768-  , 772-  , 776-  , 780-  , 788-  , 792-  , 795-  , 796-  , 798-  , 800-  , 804-  , 784-  , 826-  , 840-  , 581-  , 858-  , 860-  , 548-  , 862-  , 704-  , 92-  , 850-  , 876-  , 732-  , 887-  , 894-  , 716-  ]
− src/Country/Unexposed/ExtraNames.hs
@@ -1,11 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}--module Country.Unexposed.ExtraNames-  ( ) where--import Country.Unsafe (Country)-import Country.Identifier-import Data.Text (Text)-import Data.Primitive (indexArray,newArray,unsafeFreezeArray,writeArray,-  writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray)-
src/Country/Unexposed/Names.hs view
@@ -11,6 +11,7 @@   , englishIdentifierNamesText   , numberOfPossibleCodes   , decodeMap+  , decodeMapUtf8   , alphaTwoHashMap   , alphaThreeHashMap   , decodeNumeric@@ -22,22 +23,26 @@ import Data.Hashable (Hashable) import Data.Primitive.Types (Prim) import Data.HashMap.Strict (HashMap)+import Data.ByteString (ByteString) import Data.Primitive (indexArray) import Data.Primitive.Array (Array(..)) import Data.Primitive.ByteArray (ByteArray(..)) import Control.Monad+import Data.Text.Encoding (encodeUtf8)+import Country.Unexposed.Alias (aliases) import qualified Data.Text as T import qualified Data.Aeson as AE import qualified Data.Aeson.Types as AET import qualified Data.HashMap.Strict as HM import qualified Data.List as L import Control.Monad.ST+import Foreign.Storable (Storable) import Data.Text (Text) import Data.Word import Data.Char (toLower,isAlpha) import Country.Unexposed.Encode.English (countryNameQuads) import Data.Primitive (Array,indexArray,newArray,unsafeFreezeArray,writeArray,-  writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray)+  writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray,sizeOf) import qualified Data.Text as T import qualified Data.Scientific as SCI @@ -45,39 +50,6 @@ encodeEnglish :: Country -> Text encodeEnglish (Country n) = indexArray englishCountryNamesText (word16ToInt n) -mexico :: Country-mexico = Country 484--unitedStatesOfAmerica :: Country-unitedStatesOfAmerica = Country 840--ålandIslands :: Country-ålandIslands = Country 248--venezuelaBolivarianRepublicOf :: Country-venezuelaBolivarianRepublicOf = Country 862--boliviaPlurinationalStateOf :: Country-boliviaPlurinationalStateOf = Country 68--extraNames :: [(Country,Text)]-extraNames =-  [ (unitedStatesOfAmerica,"United States")-  , (unitedStatesOfAmerica,"The United States")-  , (unitedStatesOfAmerica,"USA")-  , (unitedStatesOfAmerica,"U.S.A.")-  , (unitedStatesOfAmerica,"Estados Unidos de América")-  , (mexico,"Estados Unidos Mexicanos")-  , (mexico,"México")-  , (mexico,"Méjico")-  , (ålandIslands,"Aland Islands")-  , (ålandIslands,"Aaland Islands")-  , (venezuelaBolivarianRepublicOf,"Venezuela")-  , (venezuelaBolivarianRepublicOf,"Bolivarian Republic of Venezuela")-  , (boliviaPlurinationalStateOf,"Bolivia")-  , (boliviaPlurinationalStateOf,"Plurinational State of Bolivia")-  ]- englishCountryNamesText :: Array Text englishCountryNamesText = runST $ do   m <- newArray numberOfPossibleCodes unnamed@@ -111,17 +83,59 @@ decodeMap :: HashMap Text Country decodeMap =    let baseMap = HM.union alphaTwoHashMap alphaThreeHashMap-      hm1 = L.foldl' (\hm (country,name) -> HM.insert name country hm) baseMap extraNames+      hm1 = L.foldl' (\hm (countryNum,name) -> HM.insert name (Country countryNum) hm) baseMap aliases       hm2 = L.foldl' (\hm (countryNum,name,_,_) -> HM.insert name (Country countryNum) hm) hm1 countryNameQuads-   in hm2+      hm3 = HM.foldlWithKey' (\hm name cty -> HM.insert (T.toLower name) cty $ HM.insert (T.toTitle name) cty $ hm) hm2 hm2+   in hm3 {-# NOINLINE decodeMap #-} +decodeMapUtf8 :: HashMap ByteString Country+decodeMapUtf8 = HM.foldlWithKey' (\hm k v -> HM.insert (encodeUtf8 k) v hm) HM.empty decodeMap+{-# NOINLINE decodeMapUtf8 #-}+ -- | A country recognized by ISO 3166. newtype Country = Country Word16-  deriving (Eq,Ord,Prim,Hashable)+  deriving (Eq,Ord,Prim,Hashable,Storable)  instance Show Country where   show (Country n) = T.unpack (indexArray englishIdentifierNamesText (word16ToInt n))++instance Enum Country where+  fromEnum (Country w) = indexByteArray countryCodeToSequentialMapping (fromIntegral w)+  toEnum number = if number >= 0 && number < actualNumberOfCountries+    then Country (indexByteArray sequentialToCountryCodeMapping number)+    else error ("toEnum: cannot convert " ++ show number ++ " to Country")++instance Bounded Country where+  minBound = Country (indexByteArray sequentialToCountryCodeMapping 0)+  maxBound = Country (indexByteArray sequentialToCountryCodeMapping (actualNumberOfCountries - 1))++orderedCountryCodes :: [Word16]+orderedCountryCodes = L.sort $ map (\(a,_,_,_) -> a) countryNameQuads++countryCodeToSequentialMapping :: ByteArray+countryCodeToSequentialMapping = runST $ do+  numbers <- newByteArray (numberOfPossibleCodes * sizeOf (undefined :: Int))+  forM_ (zip [0 :: Int,1..] orderedCountryCodes) $ \(number,code) -> do+    writeByteArray numbers (word16ToInt code) number+  unsafeFreezeByteArray numbers+{-# NOINLINE countryCodeToSequentialMapping #-}++sequentialToCountryCodeMapping :: ByteArray+sequentialToCountryCodeMapping = runST $ do+  codes <- newByteArray (actualNumberOfCountries * sizeOf (undefined :: Word16))+  forM_ (zip [0 :: Int,1..] orderedCountryCodes) $ \(number,code) -> do+    writeByteArray codes number (code :: Word16)+  unsafeFreezeByteArray codes+{-# NOINLINE sequentialToCountryCodeMapping #-}++actualNumberOfCountries :: Int+actualNumberOfCountries = length countryNameQuads+{-# NOINLINE actualNumberOfCountries #-}+  ++codeToEnum :: Word16 -> Int+codeToEnum w = indexByteArray countryCodeToSequentialMapping (word16ToInt w)  -- todo: add support for encoding directly to bytestring. -- Also, add suport for ToJSONKey and FromJSONKey once everything