#if __GLASGOW_HASKELL__ >= 701
#endif
module Data.ISO3166_CountryCodes
(CountryCode(..),
countryNameFromCode,
readableCountryName
) where
import qualified Prelude as P
import Prelude ((.),not,(==),otherwise,(&&),(==),(/=))
import Control.Monad
import Data.Char
import Data.List
#if __GLASGOW_HASKELL__ >= 701
import qualified GHC.Generics as G
#endif
readableCountryName :: CountryCode -> P.String
readableCountryName
= concat . intersperse " " . rearrange . fmap up1 . words .
fmap toUpper . countryNameFromCode
where up1 [] = []
up1 (c:rest) | not (isAlpha c) = c:up1 rest
up1 "OF" = "of"
up1 "THE" = "the"
up1 "AND" = "and"
up1 "U.S." = "US"
up1 ('M':'C':l) = "Mc"++up1 l
up1 ('D':'\'':l) = "d'"++up1 l
up1 (c:cs) = toUpper c: downup cs
downup [] = []
downup (c:cs) | c=='-' = c:up1 cs
| otherwise = toLower c:downup cs
rearrange [] = []
rearrange [c] = [c]
rearrange ll@(n:l)
| last l `elem` ["of", "the"] && last n == ','
= onhead up1 l++[[c|c<-n,c/=',']]
| otherwise = ll
onhead f [] = []
onhead f (h:r) = f h:r
data CountryCode =
AF
|
AX
|
AL
|
DZ
|
AS
|
AD
|
AO
|
AI
|
AQ
|
AG
|
AR
|
AM
|
AW
|
AU
|
AT
|
AZ
|
BS
|
BH
|
BD
|
BB
|
BY
|
BE
|
BZ
|
BJ
|
BM
|
BT
|
BO
|
BQ
|
BA
|
BW
|
BV
|
BR
|
IO
|
BN
|
BG
|
BF
|
BI
|
KH
|
CM
|
CA
|
CV
|
KY
|
CF
|
TD
|
CL
|
CN
|
CX
|
CC
|
CO
|
KM
|
CG
|
CD
|
CK
|
CR
|
CI
|
HR
|
CU
|
CW
|
CY
|
CZ
|
DK
|
DJ
|
DM
|
DO
|
EC
|
EG
|
SV
|
GQ
|
ER
|
EE
|
ET
|
FK
|
FO
|
FJ
|
FI
|
FR
|
GF
|
PF
|
TF
|
GA
|
GM
|
GE
|
DE
|
GH
|
GI
|
GR
|
GL
|
GD
|
GP
|
GU
|
GT
|
GG
|
GN
|
GW
|
GY
|
HT
|
HM
|
VA
|
HN
|
HK
|
HU
|
IS
|
IN
|
ID
|
IR
|
IQ
|
IE
|
IM
|
IL
|
IT
|
JM
|
JP
|
JE
|
JO
|
KZ
|
KE
|
KI
|
KP
|
KR
|
KW
|
KG
|
LA
|
LV
|
LB
|
LS
|
LR
|
LY
|
LI
|
LT
|
LU
|
MO
|
MK
|
MG
|
MW
|
MY
|
MV
|
ML
|
MT
|
MH
|
MQ
|
MR
|
MU
|
YT
|
MX
|
FM
|
MD
|
MC
|
MN
|
ME
|
MS
|
MA
|
MZ
|
MM
|
NA
|
NR
|
NP
|
NL
|
NC
|
NZ
|
NI
|
NE
|
NG
|
NU
|
NF
|
MP
|
NO
|
OM
|
PK
|
PW
|
PS
|
PA
|
PG
|
PY
|
PE
|
PH
|
PN
|
PL
|
PT
|
PR
|
QA
|
RE
|
RO
|
RU
|
RW
|
BL
|
SH
|
KN
|
LC
|
MF
|
PM
|
VC
|
WS
|
SM
|
ST
|
SA
|
SN
|
RS
|
SC
|
SL
|
SG
|
SX
|
SK
|
SI
|
SB
|
SO
|
ZA
|
GS
|
SS
|
ES
|
LK
|
SD
|
SR
|
SJ
|
SZ
|
SE
|
CH
|
SY
|
TW
|
TJ
|
TZ
|
TH
|
TL
|
TG
|
TK
|
TO
|
TT
|
TN
|
TR
|
TM
|
TC
|
TV
|
UG
|
UA
|
AE
|
GB
|
US
|
UM
|
UY
|
UZ
|
VU
|
VE
|
VN
|
VG
|
VI
|
WF
|
EH
|
YE
|
ZM
|
ZW
#if __GLASGOW_HASKELL__ >= 701
deriving (P.Eq,P.Read,P.Show,P.Enum,P.Bounded,P.Ord,G.Generic)
#else
deriving (P.Eq,P.Read,P.Show,P.Enum,P.Bounded,P.Ord)
#endif
countryNameFromCode:: CountryCode -> P.String
countryNameFromCode AF = "Afghanistan"
countryNameFromCode AX = "Åland Islands"
countryNameFromCode AL = "Albania"
countryNameFromCode DZ = "Algeria"
countryNameFromCode AS = "American Samoa"
countryNameFromCode AD = "Andorra"
countryNameFromCode AO = "Angola"
countryNameFromCode AI = "Anguilla"
countryNameFromCode AQ = "Antarctica"
countryNameFromCode AG = "Antigua and Barbuda"
countryNameFromCode AR = "Argentina"
countryNameFromCode AM = "Armenia"
countryNameFromCode AW = "Aruba"
countryNameFromCode AU = "Australia"
countryNameFromCode AT = "Austria"
countryNameFromCode AZ = "Azerbaijan"
countryNameFromCode BS = "Bahamas"
countryNameFromCode BH = "Bahrain"
countryNameFromCode BD = "Bangladesh"
countryNameFromCode BB = "Barbados"
countryNameFromCode BY = "Belarus"
countryNameFromCode BE = "Belgium"
countryNameFromCode BZ = "Belize"
countryNameFromCode BJ = "Benin"
countryNameFromCode BM = "Bermuda"
countryNameFromCode BT = "Bhutan"
countryNameFromCode BO = "Bolivia, Plurinational State of"
countryNameFromCode BQ = "Bonaire, Sint Eustatius and Saba"
countryNameFromCode BA = "Bosnia and Herzegovina"
countryNameFromCode BW = "Botswana"
countryNameFromCode BV = "Bouvet Island"
countryNameFromCode BR = "Brazil"
countryNameFromCode IO = "British Indian Ocean Territory"
countryNameFromCode BN = "Brunei Darussalam"
countryNameFromCode BG = "Bulgaria"
countryNameFromCode BF = "Burkina Faso"
countryNameFromCode BI = "Burundi"
countryNameFromCode KH = "Cambodia"
countryNameFromCode CM = "Cameroon"
countryNameFromCode CA = "Canada"
countryNameFromCode CV = "Cape Verde"
countryNameFromCode KY = "Cayman Islands"
countryNameFromCode CF = "Central African Republic"
countryNameFromCode TD = "Chad"
countryNameFromCode CL = "Chile"
countryNameFromCode CN = "China"
countryNameFromCode CX = "Christmas Island"
countryNameFromCode CC = "Cocos (Keeling) Islands"
countryNameFromCode CO = "Colombia"
countryNameFromCode KM = "Comoros"
countryNameFromCode CG = "Congo"
countryNameFromCode CD = "Congo, the Democratic Republic of the"
countryNameFromCode CK = "Cook Islands"
countryNameFromCode CR = "Costa Rica"
countryNameFromCode CI = "Côte d'Ivoire"
countryNameFromCode HR = "Croatia"
countryNameFromCode CU = "Cuba"
countryNameFromCode CW = "Curaçao"
countryNameFromCode CY = "Cyprus"
countryNameFromCode CZ = "Czech Republic"
countryNameFromCode DK = "Denmark"
countryNameFromCode DJ = "Djibouti"
countryNameFromCode DM = "Dominica"
countryNameFromCode DO = "Dominican Republic"
countryNameFromCode EC = "Ecuador"
countryNameFromCode EG = "Egypt"
countryNameFromCode SV = "El Salvador"
countryNameFromCode GQ = "Equatorial Guinea"
countryNameFromCode ER = "Eritrea"
countryNameFromCode EE = "Estonia"
countryNameFromCode ET = "Ethiopia"
countryNameFromCode FK = "Falkland Islands (Malvinas)"
countryNameFromCode FO = "Faroe Islands"
countryNameFromCode FJ = "Fiji"
countryNameFromCode FI = "Finland"
countryNameFromCode FR = "France"
countryNameFromCode GF = "French Guiana"
countryNameFromCode PF = "French Polynesia"
countryNameFromCode TF = "French Southern Territories"
countryNameFromCode GA = "Gabon"
countryNameFromCode GM = "Gambia"
countryNameFromCode GE = "Georgia"
countryNameFromCode DE = "Germany"
countryNameFromCode GH = "Ghana"
countryNameFromCode GI = "Gibraltar"
countryNameFromCode GR = "Greece"
countryNameFromCode GL = "Greenland"
countryNameFromCode GD = "Grenada"
countryNameFromCode GP = "Guadeloupe"
countryNameFromCode GU = "Guam"
countryNameFromCode GT = "Guatemala"
countryNameFromCode GG = "Guernsey"
countryNameFromCode GN = "Guinea"
countryNameFromCode GW = "Guinea-Bissau"
countryNameFromCode GY = "Guyana"
countryNameFromCode HT = "Haiti"
countryNameFromCode HM = "Heard Island and McDonald Mcdonald Islands"
countryNameFromCode VA = "Holy See (Vatican City State)"
countryNameFromCode HN = "Honduras"
countryNameFromCode HK = "Hong Kong"
countryNameFromCode HU = "Hungary"
countryNameFromCode IS = "Iceland"
countryNameFromCode IN = "India"
countryNameFromCode ID = "Indonesia"
countryNameFromCode IR = "Iran, Islamic Republic of"
countryNameFromCode IQ = "Iraq"
countryNameFromCode IE = "Ireland"
countryNameFromCode IM = "Isle of Man"
countryNameFromCode IL = "Israel"
countryNameFromCode IT = "Italy"
countryNameFromCode JM = "Jamaica"
countryNameFromCode JP = "Japan"
countryNameFromCode JE = "Jersey"
countryNameFromCode JO = "Jordan"
countryNameFromCode KZ = "Kazakhstan"
countryNameFromCode KE = "Kenya"
countryNameFromCode KI = "Kiribati"
countryNameFromCode KP = "Korea, Democratic People's Republic of"
countryNameFromCode KR = "Korea, Republic of"
countryNameFromCode KW = "Kuwait"
countryNameFromCode KG = "Kyrgyzstan"
countryNameFromCode LA = "Lao People's Democratic Republic"
countryNameFromCode LV = "Latvia"
countryNameFromCode LB = "Lebanon"
countryNameFromCode LS = "Lesotho"
countryNameFromCode LR = "Liberia"
countryNameFromCode LY = "Libya"
countryNameFromCode LI = "Liechtenstein"
countryNameFromCode LT = "Lithuania"
countryNameFromCode LU = "Luxembourg"
countryNameFromCode MO = "Macao"
countryNameFromCode MK = "Macedonia, the Former Yugoslav Republic of"
countryNameFromCode MG = "Madagascar"
countryNameFromCode MW = "Malawi"
countryNameFromCode MY = "Malaysia"
countryNameFromCode MV = "Maldives"
countryNameFromCode ML = "Mali"
countryNameFromCode MT = "Malta"
countryNameFromCode MH = "Marshall Islands"
countryNameFromCode MQ = "Martinique"
countryNameFromCode MR = "Mauritania"
countryNameFromCode MU = "Mauritius"
countryNameFromCode YT = "Mayotte"
countryNameFromCode MX = "Mexico"
countryNameFromCode FM = "Micronesia, Federated States of"
countryNameFromCode MD = "Moldova, Republic of"
countryNameFromCode MC = "Monaco"
countryNameFromCode MN = "Mongolia"
countryNameFromCode ME = "Montenegro"
countryNameFromCode MS = "Montserrat"
countryNameFromCode MA = "Morocco"
countryNameFromCode MZ = "Mozambique"
countryNameFromCode MM = "Myanmar"
countryNameFromCode NA = "Namibia"
countryNameFromCode NR = "Nauru"
countryNameFromCode NP = "Nepal"
countryNameFromCode NL = "Netherlands"
countryNameFromCode NC = "New Caledonia"
countryNameFromCode NZ = "New Zealand"
countryNameFromCode NI = "Nicaragua"
countryNameFromCode NE = "Niger"
countryNameFromCode NG = "Nigeria"
countryNameFromCode NU = "Niue"
countryNameFromCode NF = "Norfolk Island"
countryNameFromCode MP = "Northern Mariana Islands"
countryNameFromCode NO = "Norway"
countryNameFromCode OM = "Oman"
countryNameFromCode PK = "Pakistan"
countryNameFromCode PW = "Palau"
countryNameFromCode PS = "Palestine, State of"
countryNameFromCode PA = "Panama"
countryNameFromCode PG = "Papua New Guinea"
countryNameFromCode PY = "Paraguay"
countryNameFromCode PE = "Peru"
countryNameFromCode PH = "Philippines"
countryNameFromCode PN = "Pitcairn"
countryNameFromCode PL = "Poland"
countryNameFromCode PT = "Portugal"
countryNameFromCode PR = "Puerto Rico"
countryNameFromCode QA = "Qatar"
countryNameFromCode RE = "Réunion"
countryNameFromCode RO = "Romania"
countryNameFromCode RU = "Russian Federation"
countryNameFromCode RW = "Rwanda"
countryNameFromCode BL = "Saint Barthélemy"
countryNameFromCode SH = "Saint Helena, Ascension and Tristan da Cunha"
countryNameFromCode KN = "Saint Kitts and Nevis"
countryNameFromCode LC = "Saint Lucia"
countryNameFromCode MF = "Saint Martin (French part)"
countryNameFromCode PM = "Saint Pierre and Miquelon"
countryNameFromCode VC = "Saint Vincent and the Grenadines"
countryNameFromCode WS = "Samoa"
countryNameFromCode SM = "San Marino"
countryNameFromCode ST = "Sao Tome and Principe"
countryNameFromCode SA = "Saudi Arabia"
countryNameFromCode SN = "Senegal"
countryNameFromCode RS = "Serbia"
countryNameFromCode SC = "Seychelles"
countryNameFromCode SL = "Sierra Leone"
countryNameFromCode SG = "Singapore"
countryNameFromCode SX = "Sint Maarten (Dutch part)"
countryNameFromCode SK = "Slovakia"
countryNameFromCode SI = "Slovenia"
countryNameFromCode SB = "Solomon Islands"
countryNameFromCode SO = "Somalia"
countryNameFromCode ZA = "South Africa"
countryNameFromCode GS = "South Georgia and the South Sandwich Islands"
countryNameFromCode SS = "South Sudan"
countryNameFromCode ES = "Spain"
countryNameFromCode LK = "Sri Lanka"
countryNameFromCode SD = "Sudan"
countryNameFromCode SR = "Suriname"
countryNameFromCode SJ = "Svalbard and Jan Mayen"
countryNameFromCode SZ = "Swaziland"
countryNameFromCode SE = "Sweden"
countryNameFromCode CH = "Switzerland"
countryNameFromCode SY = "Syrian Arab Republic"
countryNameFromCode TW = "Taiwan, Province of China"
countryNameFromCode TJ = "Tajikistan"
countryNameFromCode TZ = "Tanzania, United Republic of"
countryNameFromCode TH = "Thailand"
countryNameFromCode TL = "Timor-Leste"
countryNameFromCode TG = "Togo"
countryNameFromCode TK = "Tokelau"
countryNameFromCode TO = "Tonga"
countryNameFromCode TT = "Trinidad and Tobago"
countryNameFromCode TN = "Tunisia"
countryNameFromCode TR = "Turkey"
countryNameFromCode TM = "Turkmenistan"
countryNameFromCode TC = "Turks and Caicos Islands"
countryNameFromCode TV = "Tuvalu"
countryNameFromCode UG = "Uganda"
countryNameFromCode UA = "Ukraine"
countryNameFromCode AE = "United Arab Emirates"
countryNameFromCode GB = "United Kingdom"
countryNameFromCode US = "United States"
countryNameFromCode UM = "United States Minor Outlying Islands"
countryNameFromCode UY = "Uruguay"
countryNameFromCode UZ = "Uzbekistan"
countryNameFromCode VU = "Vanuatu"
countryNameFromCode VE = "Venezuela, Bolivarian Republic of"
countryNameFromCode VN = "Viet Nam"
countryNameFromCode VG = "Virgin Islands, British"
countryNameFromCode VI = "Virgin Islands, U.S."
countryNameFromCode WF = "Wallis and Futuna"
countryNameFromCode EH = "Western Sahara"
countryNameFromCode YE = "Yemen"
countryNameFromCode ZM = "Zambia"
countryNameFromCode ZW = "Zimbabwe"