packages feed

country (empty) → 0.1

raw patch · 12 files changed

+1698/−0 lines, 12 filesdep +basedep +bytestringdep +countrysetup-changed

Dependencies added: base, bytestring, country, ghc-prim, hashable, primitive, text, unordered-containers

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Andrew Martin (c) 2017++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Andrew Martin nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,1 @@+# country
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ country.cabal view
@@ -0,0 +1,63 @@+name: country+version: 0.1+synopsis: Country data type and functions+description:+  The `country` library provides a data type for dealing with+  the set of countries as defined by ISO 3166. The representation+  is compact and is well-suited to use with vectors and+  primitive arrays. Additionally, this library exports functions +  that provide the following encodings and decodings:+  .+  * ISO Alpha-2 (two-letter country code)+  .+  * ISO Alpha-3 (three-letter country code)+  .+  * ISO Numeric (three-digit country code)+  .+  Please open up an issue on github if there is anything+  you would like to see added.+homepage: https://github.com/andrewthad/country#readme+license: BSD3+license-file: LICENSE+author: Andrew Martin+maintainer: andrew.thaddeus@gmail.com+copyright: 2017 Andrew Martin+category: Web+build-type: Simple+extra-source-files: README.md+cabal-version: >=1.10++library+  hs-source-dirs: src+  exposed-modules:+    Country+    Country.Identifier+    Country.Unsafe+  other-modules:+    Country.Unexposed.Encode.English+    Country.Unexposed.Enumerate+    Country.Unexposed.ExtraNames+    Country.Unexposed.Names+  build-depends:+      base >= 4.7 && < 4.10+    , text >= 1.2 && < 1.3+    , bytestring >= 0.10 && < 0.11+    , primitive >= 0.6.1 && < 0.7+    , unordered-containers >= 0.2 && < 0.3+    , ghc-prim >= 0.5 && < 0.6+    , hashable >= 1.2 && < 1.3+  default-language: Haskell2010++test-suite test+  type: exitcode-stdio-1.0+  hs-source-dirs: test+  main-is: Spec.hs+  build-depends:+      base+    , country+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  default-language: Haskell2010++source-repository head+  type:     git+  location: https://github.com/andrewthad/country
+ src/Country.hs view
@@ -0,0 +1,225 @@+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE MagicHash #-}++module Country+  ( Country+    -- * Three digit code+  , encodeNumeric+  , decodeNumeric+    -- * Name+  , encodeEnglish+  , decode+    -- * Alpha-2 and Alpha-3+  , alphaTwoUpper+  , alphaThreeUpper+  , alphaThreeLower+  , alphaTwoLower+  , decodeAlphaTwo+  , decodeAlphaThree+  ) where++import Country.Unsafe (Country(..))+import Country.Unexposed.Encode.English (countryNameQuads)+import Country.Unexposed.ExtraNames (extraNames)+import Country.Unexposed.Names (englishCountryNamesText,numberOfPossibleCodes)+import Country.Unexposed.Enumerate (enumeratedCountries)+import Data.Text (Text)+import Data.ByteString (ByteString)+import Data.Word (Word16,Word8)+import Data.Primitive (indexArray,newArray,unsafeFreezeArray,writeArray,+  writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray)+import Data.HashMap.Strict (HashMap)+import Data.Primitive.Array (Array(..))+import Data.Primitive.ByteArray (ByteArray(..))+import GHC.Prim (sizeofByteArray#,sizeofArray#)+import GHC.Int (Int(..))+import Control.Monad.ST (runST)+import Control.Monad+import Data.Char (ord,chr,toLower)+import Data.Bits (unsafeShiftL,unsafeShiftR)+import qualified Data.List as L+import qualified Data.HashMap.Strict as HM+import qualified Data.Text as T+import qualified Data.Text.Array as TA+import qualified Data.Text.Internal as TI++-- | Convert a country to its numeric code. This is a+--   three-digit number and will consequently be less than 1000.+encodeNumeric :: Country -> Word16+encodeNumeric (Country n) = n++-- | Get a country from a numeric code. Any code greater than+--   999 will not have a country associated with it. Additionally,+--   many codes are unassigned.+decodeNumeric :: Word16 -> Maybe Country+decodeNumeric n = if n < 1000 && indexByteArray numericValidities (word16ToInt n) == (1 :: Word8)+  then Just (Country n)+  else Nothing++-- | The name of a country given in English+encodeEnglish :: Country -> Text+encodeEnglish (Country n) = indexArray englishCountryNamesText (word16ToInt n)++-- | The alpha-2 country code, uppercase+alphaTwoUpper :: Country -> Text+alphaTwoUpper c = TI.text allAlphaTwoUpper (timesTwo (indexOfCountry c)) 2++-- | The alpha-3 country code, uppercase+alphaThreeUpper :: Country -> Text+alphaThreeUpper c = TI.text allAlphaThreeUpper (timesThree (indexOfCountry c)) 3++-- | The alpha-2 country code, lowercase+alphaTwoLower :: Country -> Text+alphaTwoLower c = TI.text allAlphaTwoLower (timesTwo (indexOfCountry c)) 2++-- | The alpha-3 country code, lowercase+alphaThreeLower :: Country -> Text+alphaThreeLower c = TI.text allAlphaThreeLower (timesThree (indexOfCountry c)) 3++decodeAlphaTwo :: Text -> Maybe Country+decodeAlphaTwo = flip HM.lookup alphaTwoHashMap++decodeAlphaThree :: Text -> Maybe Country+decodeAlphaThree = flip HM.lookup alphaTwoHashMap++alphaTwoHashMap :: HashMap Text Country+alphaTwoHashMap = L.foldl'+  (\hm (countryNum,_,(c1,c2),_) ->+      HM.insert (T.pack [c1,c2]) (Country countryNum)+    $ HM.insert (T.pack [toLower c1, toLower c2]) (Country countryNum)+    $ hm+  )+  HM.empty countryNameQuads+{-# NOINLINE alphaTwoHashMap #-}++alphaThreeHashMap :: HashMap Text Country+alphaThreeHashMap = L.foldl'+  (\hm (countryNum,_,_,(c1,c2,c3)) -> +      HM.insert (T.pack [c1,c2,c3]) (Country countryNum)+    $ HM.insert (T.pack [toLower c1, toLower c2, toLower c3]) (Country countryNum)+    $ hm+  )+  HM.empty countryNameQuads+{-# NOINLINE alphaThreeHashMap #-}++half :: Int -> Int+half x = unsafeShiftR x 1++timesTwo :: Int -> Int+timesTwo x = unsafeShiftL x 1++timesThree :: Int -> Int+timesThree x = x * 3+++-- | Parse a country from its name. This function is language-agnostic.+--   It can handle any source language.+decode :: Text -> Maybe Country+decode = flip HM.lookup decodeMap++word16ToInt :: Word16 -> Int+word16ToInt = fromIntegral++intToWord16 :: Int -> Word16+intToWord16 = fromIntegral++charToWord16 :: Char -> Word16+charToWord16 = fromIntegral . ord++word16ToChar :: Word16 -> Char+word16ToChar = chr . fromIntegral+++decodeMap :: HashMap Text Country+decodeMap = +  let baseMap = HM.union alphaTwoHashMap alphaThreeHashMap+      hm1 = L.foldl' (\hm (country,name) -> HM.insert name country hm) baseMap extraNames+      hm2 = L.foldl' (\hm (countryNum,name,_,_) -> HM.insert name (Country countryNum) hm) hm1 countryNameQuads+   in hm2+{-# NOINLINE decodeMap #-}++arrayFoldl' :: (a -> b -> a) -> a -> Array b -> a+arrayFoldl' f z a = go 0 z+  where+  go i !acc | i < sizeofArray a = go (i+1) (f acc $ indexArray a i)+            | otherwise         = acc++sizeofArray :: Array a -> Int+sizeofArray (Array a) = I# (sizeofArray# a)+{-# INLINE sizeofArray #-}++numberOfCountries :: Int+numberOfCountries = length countryNameQuads++-- | The elements in this array are Word8 (basically boolean)+numericValidities :: ByteArray+numericValidities = runST $ do+  m <- newByteArray numberOfPossibleCodes+  let clear !ix = if ix < numberOfPossibleCodes+        then writeByteArray m ix (0 :: Word8)+        else return ()+  clear 0+  forM_ countryNameQuads $ \(n,_,_,_) -> do+    writeByteArray m (word16ToInt n) (1 :: Word8)+  unsafeFreezeByteArray m+{-# NOINLINE numericValidities #-}++-- | The elements in this array are Word16+positions :: ByteArray+positions = runST $ do+  m <- newByteArray (timesTwo numberOfPossibleCodes)+  forM_ (zip (enumFrom (0 :: Word16)) countryNameQuads) $ \(ix,(n,_,_,_)) -> do+    writeByteArray m (word16ToInt n) ix+  unsafeFreezeByteArray m+{-# NOINLINE positions #-}++-- get the index of the country. this refers not to the+-- country code but to the position it shows up in the+-- hard-coded list of all the countries.+indexOfCountry :: Country -> Int+indexOfCountry (Country n) =+  word16ToInt (indexByteArray positions (word16ToInt n))++allAlphaTwoUpper :: TA.Array+allAlphaTwoUpper = TA.run $ do+  m <- TA.new (timesTwo numberOfCountries)+  forM_ countryNameQuads $ \(n,_,(a1,a2),_) -> do+    let ix = timesTwo (indexOfCountry (Country n))+    TA.unsafeWrite m ix (charToWord16 a1)+    TA.unsafeWrite m (ix + 1) (charToWord16 a2)+  return m+{-# NOINLINE allAlphaTwoUpper #-}++allAlphaThreeUpper :: TA.Array+allAlphaThreeUpper = TA.run $ do+  m <- TA.new (timesThree numberOfCountries)+  forM_ countryNameQuads $ \(n,_,_,(a1,a2,a3)) -> do+    let ix = timesThree (indexOfCountry (Country n))+    TA.unsafeWrite m ix (charToWord16 a1)+    TA.unsafeWrite m (ix + 1) (charToWord16 a2)+    TA.unsafeWrite m (ix + 2) (charToWord16 a3)+  return m+{-# NOINLINE allAlphaThreeUpper #-}++allAlphaThreeLower :: TA.Array+allAlphaThreeLower = mapTextArray toLower allAlphaThreeUpper+{-# NOINLINE allAlphaThreeLower #-}++allAlphaTwoLower :: TA.Array+allAlphaTwoLower = mapTextArray toLower allAlphaTwoUpper+{-# NOINLINE allAlphaTwoLower #-}++mapTextArray :: (Char -> Char) -> TA.Array -> TA.Array+mapTextArray f a@(TA.Array inner) = TA.run $ do+  let len = half (I# (sizeofByteArray# inner))+  m <- TA.new len+  TA.copyI m 0 a 0 len+  let go !ix = if ix < len+        then do+          TA.unsafeWrite m ix (charToWord16 (f (word16ToChar (TA.unsafeIndex a ix))))+          go (ix + 1)+        else return ()+  go 0+  return m++
+ src/Country/Identifier.hs view
@@ -0,0 +1,753 @@+module Country.Identifier where++-- This module is autogenerated. Do not edit it by hand.++import Country.Unsafe (Country(..))++afghanistan :: Country+afghanistan = Country 4++ålandIslands :: Country+ålandIslands = Country 248++albania :: Country+albania = Country 8++algeria :: Country+algeria = Country 12++americanSamoa :: Country+americanSamoa = Country 16++andorra :: Country+andorra = Country 20++angola :: Country+angola = Country 24++anguilla :: Country+anguilla = Country 660++antarctica :: Country+antarctica = Country 10++antiguaAndBarbuda :: Country+antiguaAndBarbuda = Country 28++argentina :: Country+argentina = Country 32++armenia :: Country+armenia = Country 51++aruba :: Country+aruba = Country 533++australia :: Country+australia = Country 36++austria :: Country+austria = Country 40++azerbaijan :: Country+azerbaijan = Country 31++bahamas :: Country+bahamas = Country 44++bahrain :: Country+bahrain = Country 48++bangladesh :: Country+bangladesh = Country 50++barbados :: Country+barbados = Country 52++belarus :: Country+belarus = Country 112++belgium :: Country+belgium = Country 56++belize :: Country+belize = Country 84++benin :: Country+benin = Country 204++bermuda :: Country+bermuda = Country 60++bhutan :: Country+bhutan = Country 64++boliviaPlurinationalStateOf :: Country+boliviaPlurinationalStateOf = Country 68++bonaireSintEustatiusAndSaba :: Country+bonaireSintEustatiusAndSaba = Country 535++bosniaAndHerzegovina :: Country+bosniaAndHerzegovina = Country 70++botswana :: Country+botswana = Country 72++bouvetIsland :: Country+bouvetIsland = Country 74++brazil :: Country+brazil = Country 76++britishIndianOceanTerritory :: Country+britishIndianOceanTerritory = Country 86++bruneiDarussalam :: Country+bruneiDarussalam = Country 96++bulgaria :: Country+bulgaria = Country 100++burkinaFaso :: Country+burkinaFaso = Country 854++burundi :: Country+burundi = Country 108++cambodia :: Country+cambodia = Country 116++cameroon :: Country+cameroon = Country 120++canada :: Country+canada = Country 124++caboVerde :: Country+caboVerde = Country 132++caymanIslands :: Country+caymanIslands = Country 136++centralAfricanRepublic :: Country+centralAfricanRepublic = Country 140++chad :: Country+chad = Country 148++chile :: Country+chile = Country 152++china :: Country+china = Country 156++christmasIsland :: Country+christmasIsland = Country 162++cocosKeelingIslands :: Country+cocosKeelingIslands = Country 166++colombia :: Country+colombia = Country 170++comoros :: Country+comoros = Country 174++congo :: Country+congo = Country 178++congoDemocraticRepublicOfThe :: Country+congoDemocraticRepublicOfThe = Country 180++cookIslands :: Country+cookIslands = Country 184++costaRica :: Country+costaRica = Country 188++côteDIvoire :: Country+côteDIvoire = Country 384++croatia :: Country+croatia = Country 191++cuba :: Country+cuba = Country 192++curaçao :: Country+curaçao = Country 531++cyprus :: Country+cyprus = Country 196++czechRepublic :: Country+czechRepublic = Country 203++denmark :: Country+denmark = Country 208++djibouti :: Country+djibouti = Country 262++dominica :: Country+dominica = Country 212++dominicanRepublic :: Country+dominicanRepublic = Country 214++ecuador :: Country+ecuador = Country 218++egypt :: Country+egypt = Country 818++elSalvador :: Country+elSalvador = Country 222++equatorialGuinea :: Country+equatorialGuinea = Country 226++eritrea :: Country+eritrea = Country 232++estonia :: Country+estonia = Country 233++ethiopia :: Country+ethiopia = Country 231++falklandIslandsMalvinas :: Country+falklandIslandsMalvinas = Country 238++faroeIslands :: Country+faroeIslands = Country 234++fiji :: Country+fiji = Country 242++finland :: Country+finland = Country 246++france :: Country+france = Country 250++frenchGuiana :: Country+frenchGuiana = Country 254++frenchPolynesia :: Country+frenchPolynesia = Country 258++frenchSouthernTerritories :: Country+frenchSouthernTerritories = Country 260++gabon :: Country+gabon = Country 266++gambia :: Country+gambia = Country 270++georgia :: Country+georgia = Country 268++germany :: Country+germany = Country 276++ghana :: Country+ghana = Country 288++gibraltar :: Country+gibraltar = Country 292++greece :: Country+greece = Country 300++greenland :: Country+greenland = Country 304++grenada :: Country+grenada = Country 308++guadeloupe :: Country+guadeloupe = Country 312++guam :: Country+guam = Country 316++guatemala :: Country+guatemala = Country 320++guernsey :: Country+guernsey = Country 831++guinea :: Country+guinea = Country 324++guineaBissau :: Country+guineaBissau = Country 624++guyana :: Country+guyana = Country 328++haiti :: Country+haiti = Country 332++heardIslandAndMcdonaldIslands :: Country+heardIslandAndMcdonaldIslands = Country 334++holySee :: Country+holySee = Country 336++honduras :: Country+honduras = Country 340++hongKong :: Country+hongKong = Country 344++hungary :: Country+hungary = Country 348++iceland :: Country+iceland = Country 352++india :: Country+india = Country 356++indonesia :: Country+indonesia = Country 360++iranIslamicRepublicOf :: Country+iranIslamicRepublicOf = Country 364++iraq :: Country+iraq = Country 368++ireland :: Country+ireland = Country 372++isleOfMan :: Country+isleOfMan = Country 833++israel :: Country+israel = Country 376++italy :: Country+italy = Country 380++jamaica :: Country+jamaica = Country 388++japan :: Country+japan = Country 392++jersey :: Country+jersey = Country 832++jordan :: Country+jordan = Country 400++kazakhstan :: Country+kazakhstan = Country 398++kenya :: Country+kenya = Country 404++kiribati :: Country+kiribati = Country 296++koreaDemocraticPeopleSRepublicOf :: Country+koreaDemocraticPeopleSRepublicOf = Country 408++koreaRepublicOf :: Country+koreaRepublicOf = Country 410++kuwait :: Country+kuwait = Country 414++kyrgyzstan :: Country+kyrgyzstan = Country 417++laoPeopleSDemocraticRepublic :: Country+laoPeopleSDemocraticRepublic = Country 418++latvia :: Country+latvia = Country 428++lebanon :: Country+lebanon = Country 422++lesotho :: Country+lesotho = Country 426++liberia :: Country+liberia = Country 430++libya :: Country+libya = Country 434++liechtenstein :: Country+liechtenstein = Country 438++lithuania :: Country+lithuania = Country 440++luxembourg :: Country+luxembourg = Country 442++macao :: Country+macao = Country 446++macedoniaTheFormerYugoslavRepublicOf :: Country+macedoniaTheFormerYugoslavRepublicOf = Country 807++madagascar :: Country+madagascar = Country 450++malawi :: Country+malawi = Country 454++malaysia :: Country+malaysia = Country 458++maldives :: Country+maldives = Country 462++mali :: Country+mali = Country 466++malta :: Country+malta = Country 470++marshallIslands :: Country+marshallIslands = Country 584++martinique :: Country+martinique = Country 474++mauritania :: Country+mauritania = Country 478++mauritius :: Country+mauritius = Country 480++mayotte :: Country+mayotte = Country 175++mexico :: Country+mexico = Country 484++micronesiaFederatedStatesOf :: Country+micronesiaFederatedStatesOf = Country 583++moldovaRepublicOf :: Country+moldovaRepublicOf = Country 498++monaco :: Country+monaco = Country 492++mongolia :: Country+mongolia = Country 496++montenegro :: Country+montenegro = Country 499++montserrat :: Country+montserrat = Country 500++morocco :: Country+morocco = Country 504++mozambique :: Country+mozambique = Country 508++myanmar :: Country+myanmar = Country 104++namibia :: Country+namibia = Country 516++nauru :: Country+nauru = Country 520++nepal :: Country+nepal = Country 524++netherlands :: Country+netherlands = Country 528++newCaledonia :: Country+newCaledonia = Country 540++newZealand :: Country+newZealand = Country 554++nicaragua :: Country+nicaragua = Country 558++niger :: Country+niger = Country 562++nigeria :: Country+nigeria = Country 566++niue :: Country+niue = Country 570++norfolkIsland :: Country+norfolkIsland = Country 574++northernMarianaIslands :: Country+northernMarianaIslands = Country 580++norway :: Country+norway = Country 578++oman :: Country+oman = Country 512++pakistan :: Country+pakistan = Country 586++palau :: Country+palau = Country 585++palestineStateOf :: Country+palestineStateOf = Country 275++panama :: Country+panama = Country 591++papuaNewGuinea :: Country+papuaNewGuinea = Country 598++paraguay :: Country+paraguay = Country 600++peru :: Country+peru = Country 604++philippines :: Country+philippines = Country 608++pitcairn :: Country+pitcairn = Country 612++poland :: Country+poland = Country 616++portugal :: Country+portugal = Country 620++puertoRico :: Country+puertoRico = Country 630++qatar :: Country+qatar = Country 634++réunion :: Country+réunion = Country 638++romania :: Country+romania = Country 642++russianFederation :: Country+russianFederation = Country 643++rwanda :: Country+rwanda = Country 646++saintBarthélemy :: Country+saintBarthélemy = Country 652++saintHelenaAscensionAndTristanDaCunha :: Country+saintHelenaAscensionAndTristanDaCunha = Country 654++saintKittsAndNevis :: Country+saintKittsAndNevis = Country 659++saintLucia :: Country+saintLucia = Country 662++saintMartinFrenchPart :: Country+saintMartinFrenchPart = Country 663++saintPierreAndMiquelon :: Country+saintPierreAndMiquelon = Country 666++saintVincentAndTheGrenadines :: Country+saintVincentAndTheGrenadines = Country 670++samoa :: Country+samoa = Country 882++sanMarino :: Country+sanMarino = Country 674++saoTomeAndPrincipe :: Country+saoTomeAndPrincipe = Country 678++saudiArabia :: Country+saudiArabia = Country 682++senegal :: Country+senegal = Country 686++serbia :: Country+serbia = Country 688++seychelles :: Country+seychelles = Country 690++sierraLeone :: Country+sierraLeone = Country 694++singapore :: Country+singapore = Country 702++sintMaartenDutchPart :: Country+sintMaartenDutchPart = Country 534++slovakia :: Country+slovakia = Country 703++slovenia :: Country+slovenia = Country 705++solomonIslands :: Country+solomonIslands = Country 90++somalia :: Country+somalia = Country 706++southAfrica :: Country+southAfrica = Country 710++southGeorgiaAndTheSouthSandwichIslands :: Country+southGeorgiaAndTheSouthSandwichIslands = Country 239++southSudan :: Country+southSudan = Country 728++spain :: Country+spain = Country 724++sriLanka :: Country+sriLanka = Country 144++sudan :: Country+sudan = Country 729++suriname :: Country+suriname = Country 740++svalbardAndJanMayen :: Country+svalbardAndJanMayen = Country 744++swaziland :: Country+swaziland = Country 748++sweden :: Country+sweden = Country 752++switzerland :: Country+switzerland = Country 756++syrianArabRepublic :: Country+syrianArabRepublic = Country 760++taiwanProvinceOfChina :: Country+taiwanProvinceOfChina = Country 158++tajikistan :: Country+tajikistan = Country 762++tanzaniaUnitedRepublicOf :: Country+tanzaniaUnitedRepublicOf = Country 834++thailand :: Country+thailand = Country 764++timorLeste :: Country+timorLeste = Country 626++togo :: Country+togo = Country 768++tokelau :: Country+tokelau = Country 772++tonga :: Country+tonga = Country 776++trinidadAndTobago :: Country+trinidadAndTobago = Country 780++tunisia :: Country+tunisia = Country 788++turkey :: Country+turkey = Country 792++turkmenistan :: Country+turkmenistan = Country 795++turksAndCaicosIslands :: Country+turksAndCaicosIslands = Country 796++tuvalu :: Country+tuvalu = Country 798++uganda :: Country+uganda = Country 800++ukraine :: Country+ukraine = Country 804++unitedArabEmirates :: Country+unitedArabEmirates = Country 784++unitedKingdomOfGreatBritainAndNorthernIreland :: Country+unitedKingdomOfGreatBritainAndNorthernIreland = Country 826++unitedStatesOfAmerica :: Country+unitedStatesOfAmerica = Country 840++unitedStatesMinorOutlyingIslands :: Country+unitedStatesMinorOutlyingIslands = Country 581++uruguay :: Country+uruguay = Country 858++uzbekistan :: Country+uzbekistan = Country 860++vanuatu :: Country+vanuatu = Country 548++venezuelaBolivarianRepublicOf :: Country+venezuelaBolivarianRepublicOf = Country 862++vietNam :: Country+vietNam = Country 704++virginIslandsBritish :: Country+virginIslandsBritish = Country 92++virginIslandsUS :: Country+virginIslandsUS = Country 850++wallisAndFutuna :: Country+wallisAndFutuna = Country 876++westernSahara :: Country+westernSahara = Country 732++yemen :: Country+yemen = Country 887++zambia :: Country+zambia = Country 894++zimbabwe :: Country+zimbabwe = Country 716+
+ src/Country/Unexposed/Encode/English.hs view
@@ -0,0 +1,264 @@+-- This module is autogenerated. Do not edit it by hand.+module Country.Unexposed.Encode.English+  ( countryNameQuads+  ) where++import Data.Text (Text)+import Data.Word (Word16)+import qualified Data.Text as T++-- first value is country code, second is english name, +-- third is two char code, fourth is three char code.+countryNameQuads :: [(Word16,Text,(Char,Char),(Char,Char,Char))]+countryNameQuads =+  [ (4, T.pack "Afghanistan",('A','F'),('A','F','G'))+  , (248, T.pack "Åland Islands",('A','X'),('A','L','A'))+  , (8, T.pack "Albania",('A','L'),('A','L','B'))+  , (12, T.pack "Algeria",('D','Z'),('D','Z','A'))+  , (16, T.pack "American Samoa",('A','S'),('A','S','M'))+  , (20, T.pack "Andorra",('A','D'),('A','N','D'))+  , (24, T.pack "Angola",('A','O'),('A','G','O'))+  , (660, T.pack "Anguilla",('A','I'),('A','I','A'))+  , (10, T.pack "Antarctica",('A','Q'),('A','T','A'))+  , (28, T.pack "Antigua and Barbuda",('A','G'),('A','T','G'))+  , (32, T.pack "Argentina",('A','R'),('A','R','G'))+  , (51, T.pack "Armenia",('A','M'),('A','R','M'))+  , (533, T.pack "Aruba",('A','W'),('A','B','W'))+  , (36, T.pack "Australia",('A','U'),('A','U','S'))+  , (40, T.pack "Austria",('A','T'),('A','U','T'))+  , (31, T.pack "Azerbaijan",('A','Z'),('A','Z','E'))+  , (44, T.pack "Bahamas",('B','S'),('B','H','S'))+  , (48, T.pack "Bahrain",('B','H'),('B','H','R'))+  , (50, T.pack "Bangladesh",('B','D'),('B','G','D'))+  , (52, T.pack "Barbados",('B','B'),('B','R','B'))+  , (112, T.pack "Belarus",('B','Y'),('B','L','R'))+  , (56, T.pack "Belgium",('B','E'),('B','E','L'))+  , (84, T.pack "Belize",('B','Z'),('B','L','Z'))+  , (204, T.pack "Benin",('B','J'),('B','E','N'))+  , (60, T.pack "Bermuda",('B','M'),('B','M','U'))+  , (64, T.pack "Bhutan",('B','T'),('B','T','N'))+  , (68, T.pack "Bolivia (Plurinational State of)",('B','O'),('B','O','L'))+  , (535, T.pack "Bonaire, Sint Eustatius and Saba",('B','Q'),('B','E','S'))+  , (70, T.pack "Bosnia and Herzegovina",('B','A'),('B','I','H'))+  , (72, T.pack "Botswana",('B','W'),('B','W','A'))+  , (74, T.pack "Bouvet Island",('B','V'),('B','V','T'))+  , (76, T.pack "Brazil",('B','R'),('B','R','A'))+  , (86, T.pack "British Indian Ocean Territory",('I','O'),('I','O','T'))+  , (96, T.pack "Brunei Darussalam",('B','N'),('B','R','N'))+  , (100, T.pack "Bulgaria",('B','G'),('B','G','R'))+  , (854, T.pack "Burkina Faso",('B','F'),('B','F','A'))+  , (108, T.pack "Burundi",('B','I'),('B','D','I'))+  , (116, T.pack "Cambodia",('K','H'),('K','H','M'))+  , (120, T.pack "Cameroon",('C','M'),('C','M','R'))+  , (124, T.pack "Canada",('C','A'),('C','A','N'))+  , (132, T.pack "Cabo Verde",('C','V'),('C','P','V'))+  , (136, T.pack "Cayman Islands",('K','Y'),('C','Y','M'))+  , (140, T.pack "Central African Republic",('C','F'),('C','A','F'))+  , (148, T.pack "Chad",('T','D'),('T','C','D'))+  , (152, T.pack "Chile",('C','L'),('C','H','L'))+  , (156, T.pack "China",('C','N'),('C','H','N'))+  , (162, T.pack "Christmas Island",('C','X'),('C','X','R'))+  , (166, T.pack "Cocos (Keeling) Islands",('C','C'),('C','C','K'))+  , (170, T.pack "Colombia",('C','O'),('C','O','L'))+  , (174, T.pack "Comoros",('K','M'),('C','O','M'))+  , (178, T.pack "Congo",('C','G'),('C','O','G'))+  , (180, T.pack "Congo (Democratic Republic of the)",('C','D'),('C','O','D'))+  , (184, T.pack "Cook Islands",('C','K'),('C','O','K'))+  , (188, T.pack "Costa Rica",('C','R'),('C','R','I'))+  , (384, T.pack "Côte d'Ivoire",('C','I'),('C','I','V'))+  , (191, T.pack "Croatia",('H','R'),('H','R','V'))+  , (192, T.pack "Cuba",('C','U'),('C','U','B'))+  , (531, T.pack "Curaçao",('C','W'),('C','U','W'))+  , (196, T.pack "Cyprus",('C','Y'),('C','Y','P'))+  , (203, T.pack "Czech Republic",('C','Z'),('C','Z','E'))+  , (208, T.pack "Denmark",('D','K'),('D','N','K'))+  , (262, T.pack "Djibouti",('D','J'),('D','J','I'))+  , (212, T.pack "Dominica",('D','M'),('D','M','A'))+  , (214, T.pack "Dominican Republic",('D','O'),('D','O','M'))+  , (218, T.pack "Ecuador",('E','C'),('E','C','U'))+  , (818, T.pack "Egypt",('E','G'),('E','G','Y'))+  , (222, T.pack "El Salvador",('S','V'),('S','L','V'))+  , (226, T.pack "Equatorial Guinea",('G','Q'),('G','N','Q'))+  , (232, T.pack "Eritrea",('E','R'),('E','R','I'))+  , (233, T.pack "Estonia",('E','E'),('E','S','T'))+  , (231, T.pack "Ethiopia",('E','T'),('E','T','H'))+  , (238, T.pack "Falkland Islands (Malvinas)",('F','K'),('F','L','K'))+  , (234, T.pack "Faroe Islands",('F','O'),('F','R','O'))+  , (242, T.pack "Fiji",('F','J'),('F','J','I'))+  , (246, T.pack "Finland",('F','I'),('F','I','N'))+  , (250, T.pack "France",('F','R'),('F','R','A'))+  , (254, T.pack "French Guiana",('G','F'),('G','U','F'))+  , (258, T.pack "French Polynesia",('P','F'),('P','Y','F'))+  , (260, T.pack "French Southern Territories",('T','F'),('A','T','F'))+  , (266, T.pack "Gabon",('G','A'),('G','A','B'))+  , (270, T.pack "Gambia",('G','M'),('G','M','B'))+  , (268, T.pack "Georgia",('G','E'),('G','E','O'))+  , (276, T.pack "Germany",('D','E'),('D','E','U'))+  , (288, T.pack "Ghana",('G','H'),('G','H','A'))+  , (292, T.pack "Gibraltar",('G','I'),('G','I','B'))+  , (300, T.pack "Greece",('G','R'),('G','R','C'))+  , (304, T.pack "Greenland",('G','L'),('G','R','L'))+  , (308, T.pack "Grenada",('G','D'),('G','R','D'))+  , (312, T.pack "Guadeloupe",('G','P'),('G','L','P'))+  , (316, T.pack "Guam",('G','U'),('G','U','M'))+  , (320, T.pack "Guatemala",('G','T'),('G','T','M'))+  , (831, T.pack "Guernsey",('G','G'),('G','G','Y'))+  , (324, T.pack "Guinea",('G','N'),('G','I','N'))+  , (624, T.pack "Guinea-Bissau",('G','W'),('G','N','B'))+  , (328, T.pack "Guyana",('G','Y'),('G','U','Y'))+  , (332, T.pack "Haiti",('H','T'),('H','T','I'))+  , (334, T.pack "Heard Island and McDonald Islands",('H','M'),('H','M','D'))+  , (336, T.pack "Holy See",('V','A'),('V','A','T'))+  , (340, T.pack "Honduras",('H','N'),('H','N','D'))+  , (344, T.pack "Hong Kong",('H','K'),('H','K','G'))+  , (348, T.pack "Hungary",('H','U'),('H','U','N'))+  , (352, T.pack "Iceland",('I','S'),('I','S','L'))+  , (356, T.pack "India",('I','N'),('I','N','D'))+  , (360, T.pack "Indonesia",('I','D'),('I','D','N'))+  , (364, T.pack "Iran (Islamic Republic of)",('I','R'),('I','R','N'))+  , (368, T.pack "Iraq",('I','Q'),('I','R','Q'))+  , (372, T.pack "Ireland",('I','E'),('I','R','L'))+  , (833, T.pack "Isle of Man",('I','M'),('I','M','N'))+  , (376, T.pack "Israel",('I','L'),('I','S','R'))+  , (380, T.pack "Italy",('I','T'),('I','T','A'))+  , (388, T.pack "Jamaica",('J','M'),('J','A','M'))+  , (392, T.pack "Japan",('J','P'),('J','P','N'))+  , (832, T.pack "Jersey",('J','E'),('J','E','Y'))+  , (400, T.pack "Jordan",('J','O'),('J','O','R'))+  , (398, T.pack "Kazakhstan",('K','Z'),('K','A','Z'))+  , (404, T.pack "Kenya",('K','E'),('K','E','N'))+  , (296, T.pack "Kiribati",('K','I'),('K','I','R'))+  , (408, T.pack "Korea (Democratic People's Republic of)",('K','P'),('P','R','K'))+  , (410, T.pack "Korea (Republic of)",('K','R'),('K','O','R'))+  , (414, T.pack "Kuwait",('K','W'),('K','W','T'))+  , (417, T.pack "Kyrgyzstan",('K','G'),('K','G','Z'))+  , (418, T.pack "Lao People's Democratic Republic",('L','A'),('L','A','O'))+  , (428, T.pack "Latvia",('L','V'),('L','V','A'))+  , (422, T.pack "Lebanon",('L','B'),('L','B','N'))+  , (426, T.pack "Lesotho",('L','S'),('L','S','O'))+  , (430, T.pack "Liberia",('L','R'),('L','B','R'))+  , (434, T.pack "Libya",('L','Y'),('L','B','Y'))+  , (438, T.pack "Liechtenstein",('L','I'),('L','I','E'))+  , (440, T.pack "Lithuania",('L','T'),('L','T','U'))+  , (442, T.pack "Luxembourg",('L','U'),('L','U','X'))+  , (446, T.pack "Macao",('M','O'),('M','A','C'))+  , (807, T.pack "Macedonia (the former Yugoslav Republic of)",('M','K'),('M','K','D'))+  , (450, T.pack "Madagascar",('M','G'),('M','D','G'))+  , (454, T.pack "Malawi",('M','W'),('M','W','I'))+  , (458, T.pack "Malaysia",('M','Y'),('M','Y','S'))+  , (462, T.pack "Maldives",('M','V'),('M','D','V'))+  , (466, T.pack "Mali",('M','L'),('M','L','I'))+  , (470, T.pack "Malta",('M','T'),('M','L','T'))+  , (584, T.pack "Marshall Islands",('M','H'),('M','H','L'))+  , (474, T.pack "Martinique",('M','Q'),('M','T','Q'))+  , (478, T.pack "Mauritania",('M','R'),('M','R','T'))+  , (480, T.pack "Mauritius",('M','U'),('M','U','S'))+  , (175, T.pack "Mayotte",('Y','T'),('M','Y','T'))+  , (484, T.pack "Mexico",('M','X'),('M','E','X'))+  , (583, T.pack "Micronesia (Federated States of)",('F','M'),('F','S','M'))+  , (498, T.pack "Moldova (Republic of)",('M','D'),('M','D','A'))+  , (492, T.pack "Monaco",('M','C'),('M','C','O'))+  , (496, T.pack "Mongolia",('M','N'),('M','N','G'))+  , (499, T.pack "Montenegro",('M','E'),('M','N','E'))+  , (500, T.pack "Montserrat",('M','S'),('M','S','R'))+  , (504, T.pack "Morocco",('M','A'),('M','A','R'))+  , (508, T.pack "Mozambique",('M','Z'),('M','O','Z'))+  , (104, T.pack "Myanmar",('M','M'),('M','M','R'))+  , (516, T.pack "Namibia",('N','A'),('N','A','M'))+  , (520, T.pack "Nauru",('N','R'),('N','R','U'))+  , (524, T.pack "Nepal",('N','P'),('N','P','L'))+  , (528, T.pack "Netherlands",('N','L'),('N','L','D'))+  , (540, T.pack "New Caledonia",('N','C'),('N','C','L'))+  , (554, T.pack "New Zealand",('N','Z'),('N','Z','L'))+  , (558, T.pack "Nicaragua",('N','I'),('N','I','C'))+  , (562, T.pack "Niger",('N','E'),('N','E','R'))+  , (566, T.pack "Nigeria",('N','G'),('N','G','A'))+  , (570, T.pack "Niue",('N','U'),('N','I','U'))+  , (574, T.pack "Norfolk Island",('N','F'),('N','F','K'))+  , (580, T.pack "Northern Mariana Islands",('M','P'),('M','N','P'))+  , (578, T.pack "Norway",('N','O'),('N','O','R'))+  , (512, T.pack "Oman",('O','M'),('O','M','N'))+  , (586, T.pack "Pakistan",('P','K'),('P','A','K'))+  , (585, T.pack "Palau",('P','W'),('P','L','W'))+  , (275, T.pack "Palestine, State of",('P','S'),('P','S','E'))+  , (591, T.pack "Panama",('P','A'),('P','A','N'))+  , (598, T.pack "Papua New Guinea",('P','G'),('P','N','G'))+  , (600, T.pack "Paraguay",('P','Y'),('P','R','Y'))+  , (604, T.pack "Peru",('P','E'),('P','E','R'))+  , (608, T.pack "Philippines",('P','H'),('P','H','L'))+  , (612, T.pack "Pitcairn",('P','N'),('P','C','N'))+  , (616, T.pack "Poland",('P','L'),('P','O','L'))+  , (620, T.pack "Portugal",('P','T'),('P','R','T'))+  , (630, T.pack "Puerto Rico",('P','R'),('P','R','I'))+  , (634, T.pack "Qatar",('Q','A'),('Q','A','T'))+  , (638, T.pack "Réunion",('R','E'),('R','E','U'))+  , (642, T.pack "Romania",('R','O'),('R','O','U'))+  , (643, T.pack "Russian Federation",('R','U'),('R','U','S'))+  , (646, T.pack "Rwanda",('R','W'),('R','W','A'))+  , (652, T.pack "Saint Barthélemy",('B','L'),('B','L','M'))+  , (654, T.pack "Saint Helena, Ascension and Tristan da Cunha",('S','H'),('S','H','N'))+  , (659, T.pack "Saint Kitts and Nevis",('K','N'),('K','N','A'))+  , (662, T.pack "Saint Lucia",('L','C'),('L','C','A'))+  , (663, T.pack "Saint Martin (French part)",('M','F'),('M','A','F'))+  , (666, T.pack "Saint Pierre and Miquelon",('P','M'),('S','P','M'))+  , (670, T.pack "Saint Vincent and the Grenadines",('V','C'),('V','C','T'))+  , (882, T.pack "Samoa",('W','S'),('W','S','M'))+  , (674, T.pack "San Marino",('S','M'),('S','M','R'))+  , (678, T.pack "Sao Tome and Principe",('S','T'),('S','T','P'))+  , (682, T.pack "Saudi Arabia",('S','A'),('S','A','U'))+  , (686, T.pack "Senegal",('S','N'),('S','E','N'))+  , (688, T.pack "Serbia",('R','S'),('S','R','B'))+  , (690, T.pack "Seychelles",('S','C'),('S','Y','C'))+  , (694, T.pack "Sierra Leone",('S','L'),('S','L','E'))+  , (702, T.pack "Singapore",('S','G'),('S','G','P'))+  , (534, T.pack "Sint Maarten (Dutch part)",('S','X'),('S','X','M'))+  , (703, T.pack "Slovakia",('S','K'),('S','V','K'))+  , (705, T.pack "Slovenia",('S','I'),('S','V','N'))+  , (90, T.pack "Solomon Islands",('S','B'),('S','L','B'))+  , (706, T.pack "Somalia",('S','O'),('S','O','M'))+  , (710, T.pack "South Africa",('Z','A'),('Z','A','F'))+  , (239, T.pack "South Georgia and the South Sandwich Islands",('G','S'),('S','G','S'))+  , (728, T.pack "South Sudan",('S','S'),('S','S','D'))+  , (724, T.pack "Spain",('E','S'),('E','S','P'))+  , (144, T.pack "Sri Lanka",('L','K'),('L','K','A'))+  , (729, T.pack "Sudan",('S','D'),('S','D','N'))+  , (740, T.pack "Suriname",('S','R'),('S','U','R'))+  , (744, T.pack "Svalbard and Jan Mayen",('S','J'),('S','J','M'))+  , (748, T.pack "Swaziland",('S','Z'),('S','W','Z'))+  , (752, T.pack "Sweden",('S','E'),('S','W','E'))+  , (756, T.pack "Switzerland",('C','H'),('C','H','E'))+  , (760, T.pack "Syrian Arab Republic",('S','Y'),('S','Y','R'))+  , (158, T.pack "Taiwan, Province of China",('T','W'),('T','W','N'))+  , (762, T.pack "Tajikistan",('T','J'),('T','J','K'))+  , (834, T.pack "Tanzania, United Republic of",('T','Z'),('T','Z','A'))+  , (764, T.pack "Thailand",('T','H'),('T','H','A'))+  , (626, T.pack "Timor-Leste",('T','L'),('T','L','S'))+  , (768, T.pack "Togo",('T','G'),('T','G','O'))+  , (772, T.pack "Tokelau",('T','K'),('T','K','L'))+  , (776, T.pack "Tonga",('T','O'),('T','O','N'))+  , (780, T.pack "Trinidad and Tobago",('T','T'),('T','T','O'))+  , (788, T.pack "Tunisia",('T','N'),('T','U','N'))+  , (792, T.pack "Turkey",('T','R'),('T','U','R'))+  , (795, T.pack "Turkmenistan",('T','M'),('T','K','M'))+  , (796, T.pack "Turks and Caicos Islands",('T','C'),('T','C','A'))+  , (798, T.pack "Tuvalu",('T','V'),('T','U','V'))+  , (800, T.pack "Uganda",('U','G'),('U','G','A'))+  , (804, T.pack "Ukraine",('U','A'),('U','K','R'))+  , (784, T.pack "United Arab Emirates",('A','E'),('A','R','E'))+  , (826, T.pack "United Kingdom of Great Britain and Northern Ireland",('G','B'),('G','B','R'))+  , (840, T.pack "United States of America",('U','S'),('U','S','A'))+  , (581, T.pack "United States Minor Outlying Islands",('U','M'),('U','M','I'))+  , (858, T.pack "Uruguay",('U','Y'),('U','R','Y'))+  , (860, T.pack "Uzbekistan",('U','Z'),('U','Z','B'))+  , (548, T.pack "Vanuatu",('V','U'),('V','U','T'))+  , (862, T.pack "Venezuela (Bolivarian Republic of)",('V','E'),('V','E','N'))+  , (704, T.pack "Viet Nam",('V','N'),('V','N','M'))+  , (92, T.pack "Virgin Islands (British)",('V','G'),('V','G','B'))+  , (850, T.pack "Virgin Islands (U.S.)",('V','I'),('V','I','R'))+  , (876, T.pack "Wallis and Futuna",('W','F'),('W','L','F'))+  , (732, T.pack "Western Sahara",('E','H'),('E','S','H'))+  , (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'))+  ]+{-# NOINLINE countryNameQuads #-}
+ src/Country/Unexposed/Enumerate.hs view
@@ -0,0 +1,258 @@+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 view
@@ -0,0 +1,22 @@+{-# LANGUAGE OverloadedStrings #-}++module Country.Unexposed.ExtraNames+  ( extraNames+  ) where++import Country.Unsafe (Country)+import Country.Identifier+import Data.Text (Text)+import Data.Primitive (indexArray,newArray,unsafeFreezeArray,writeArray,+  writeByteArray,indexByteArray,unsafeFreezeByteArray,newByteArray)++extraNames :: [(Country,Text)]+extraNames =+  [ (unitedStatesOfAmerica,"United States")+  , (unitedStatesOfAmerica,"USA")+  , (unitedStatesOfAmerica,"U.S.A.")+  , (mexico,"Estados Unidos Mexicanos")+  , (mexico,"México")+  , (mexico,"Méjico")+  ]+
+ src/Country/Unexposed/Names.hs view
@@ -0,0 +1,45 @@+module Country.Unexposed.Names+  ( englishCountryNamesText+  , englishIdentifierNamesText+  , numberOfPossibleCodes+  ) where++import Control.Monad.ST+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)+import qualified Data.Text as T++englishCountryNamesText :: Array Text+englishCountryNamesText = runST $ do+  m <- newArray numberOfPossibleCodes unnamed+  mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) name) countryNameQuads+  unsafeFreezeArray m+{-# NOINLINE englishCountryNamesText #-}++englishIdentifierNamesText :: Array Text+englishIdentifierNamesText = runST $ do+  m <- newArray numberOfPossibleCodes unnamed+  mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) (toIdentifier name)) countryNameQuads+  unsafeFreezeArray m+{-# NOINLINE englishIdentifierNamesText #-}++toIdentifier :: Text -> Text+toIdentifier t = case (T.uncons . T.filter isAlpha . T.toTitle) t of+  Nothing -> T.empty+  Just (b,bs) -> T.cons (toLower b) bs+++unnamed :: Text+unnamed = T.pack "Invalid Country"+{-# NOINLINE unnamed #-}++numberOfPossibleCodes :: Int+numberOfPossibleCodes = 1000++word16ToInt :: Word16 -> Int+word16ToInt = fromIntegral+
+ src/Country/Unsafe.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE UnboxedTuples #-}+{-# OPTIONS_HADDOCK not-home #-}++{-| This module provides the data constructor for a 'Country'.+    While pattern matching on a country is perfectly safe,+    constructing one is not. There is an invariant the type+    system does not capture that the country number, as defined+    by ISO 3166-1, is between the inclusive bounds 0 and 999.+    Failure to maintain this invariant can cause other functions+    in this library to segfault.+-}+module Country.Unsafe+  ( Country(..)+  ) where++import Data.Word (Word16)+import Data.Hashable (Hashable)+import Data.Primitive.Types (Prim)+import Data.Primitive (indexArray)+import Country.Unexposed.Names (englishIdentifierNamesText)+import qualified Data.Text as T++-- | A country recognized by ISO 3166.+newtype Country = Country Word16+  deriving (Eq,Ord,Prim,Hashable)++instance Show Country where+  show (Country n) = T.unpack (indexArray englishIdentifierNamesText (word16ToInt n))++word16ToInt :: Word16 -> Int+word16ToInt = fromIntegral+
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"