git.iko.soy/typeable/country-codes
on master help sign in
B2H-796: Add non standard codes
commitf41fa75ba9210b2727725a4753e482c84a0f3d7b authorVladislav <vlad.lagunoff@gmail.com> dateMon 19 Jul 2021, 14:56 (5 years ago) parent2014387
1 file changed+36−2
src/Data/CountryCodes/ISO31661.hs+36−2
src/Data/CountryCodes/ISO31661.hs+36−2
@@ -20,7 +20,7 @@ import qualified Data.Text as T
2020import Prelude (Show,Read,Eq,Ord,Bounded,Enum,error,($),(++),Maybe(..),(.),fail,seq)
2121import Text.Shakespeare.I18N
2222
23−data CountryCode =
23+data CountryCode =
2424 AD
2525 | AE
2626 | AF
@@ -270,6 +270,14 @@ data CountryCode =
270270 | ZA
271271 | ZM
272272 | ZW
273+ -- Added these non standard codes that occur in
274+ -- travolutionary database
275+ -- https://typeable.atlassian.net/browse/B2H-796
276+ | XA
277+ | AN
278+ | XK
279+ | XC
280+ | WE
273281 deriving (Show,Read,Eq,Ord,Bounded,Enum,Typeable)
274282
275283-- | Maybe get the CountryCode from the text code.
@@ -523,6 +531,11 @@ fromMText "YT" = Just YT
523531fromMText "ZA" = Just ZA
524532fromMText "ZM" = Just ZM
525533fromMText "ZW" = Just ZW
534+fromMText "XA" = Just XA
535+fromMText "AN" = Just AN
536+fromMText "XK" = Just XK
537+fromMText "XC" = Just XC
538+fromMText "WE" = Just WE
526539fromMText _ = Nothing
527540
528541-- | Get the CountryCode from the text code. Errors if the code is unknown
@@ -782,6 +795,11 @@ toText YT = "YT"
782795toText ZA = "ZA"
783796toText ZM = "ZM"
784797toText ZW = "ZW"
798+toText XA = "XA"
799+toText AN = "AN"
800+toText XK = "XK"
801+toText XC = "XC"
802+toText WE = "WE"
785803
786804-- | Maybe get the code from the user readable name.
787805fromMName :: T.Text -> Maybe CountryCode
@@ -1034,6 +1052,11 @@ fromMName "Mayotte" = Just YT
10341052fromMName "South Africa" = Just ZA
10351053fromMName "Zambia" = Just ZM
10361054fromMName "Zimbabwe" = Just ZW
1055+fromMName "Canary Islands" = Just XA
1056+fromMName "Netherlands Antilles" = Just AN
1057+fromMName "Kosovo" = Just XK
1058+fromMName "Ceuta" = Just XC
1059+fromMName "West Bank" = Just WE
10371060fromMName _ = Nothing
10381061
10391062-- | Get the CountryCode from the user readable name. Errors if the name is unknown
@@ -1293,6 +1316,11 @@ toName YT = "Mayotte"
12931316toName ZA = "South Africa"
12941317toName ZM = "Zambia"
12951318toName ZW = "Zimbabwe"
1319+toName XA = "Canary Islands"
1320+toName AN = "Netherlands Antilles"
1321+toName XK = "Kosovo"
1322+toName XC = "Ceuta"
1323+toName WE = "West Bank"
12961324
12971325-- | list of names sorted by alphabetical order, with country code
12981326-- this is ready to be used in a yesod selectField, for example
@@ -1545,7 +1573,13 @@ countryList = [("Afghanistan",AF)
15451573 ,("Yemen",YE)
15461574 ,("Zambia",ZM)
15471575 ,("Zimbabwe",ZW)
1548− ,("Åland Islands",AX) ]
1576+ ,("Åland Islands",AX)
1577+ ,("Canary Islands", XA)
1578+ ,("Netherlands Antilles",AN)
1579+ ,("Kosovo",XK)
1580+ ,("Ceuta",XC)
1581+ ,("West Bank",WE)
1582+ ]
15491583
15501584-- | to json: as a simple string
15511585instance ToJSON CountryCode where