packages feed

country 0.2.4.1 → 0.2.4.2

raw patch · 17 files changed

+694/−628 lines, 17 filesdep −entropydep ~basedep ~byteslicedep ~bytestringsetup-changed

Dependencies removed: entropy

Dependency ranges changed: base, byteslice, bytestring, deepseq, primitive

Files

+ CHANGELOG.md view
@@ -0,0 +1,6 @@+# Revision history for country++## 0.2.4.2 -- 2024-02-15++* Update package metadata.+* Bumped `deepseq` upper bound to <1.6.
README.md view
@@ -1,1 +1,21 @@ # country++This is a mega-repo with two projects:++- `country`: A library for dealing with countries, country codes, etc.+- `country-code-generation`: An executable that generates some of the+  source code in `country`. It converts both `countries.csv` and+  `aliases.txt` into lists of tuples.++#### Build Instructions++Some of source code in the `country` library is generated. To generate+this code, the `country-code-generation` application reads the top-level+`aliases.txt` and `countries.csv` file and outputs source Haskell. If+neither of these two files have been modified, then it is not necessary+to run `country-code-generation`. A `cabal.project` file is used to+build two targets. From the project root, run:++    cabal build country-code-generation+    /home/jdoe/path/to/projects/country/.../country-code-generation+    cabal build country
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
bench/Main.hs view
@@ -1,28 +1,30 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE TypeApplications #-} -import Gauge.Main (defaultMain,bgroup,bench,whnf) import Data.Text (Text)+import Gauge.Main (bench, defaultMain, whnf) -import qualified Data.Bytes as Bytes+import qualified Country import qualified Data.List as List import qualified Data.Text as Text-import qualified Country  main :: IO ()-main = defaultMain-  [ bench "decode" (whnf decodeManyCountries ex1)-  ]+main =+  defaultMain+    [ bench "decode" (whnf decodeManyCountries ex1)+    ]  ex1 :: Text-{-# noinline ex1 #-}-ex1 = Text.intercalate-  (Text.singleton '\n')-  (List.map Country.encodeEnglish [minBound..maxBound])+{-# NOINLINE ex1 #-}+ex1 =+  Text.intercalate+    (Text.singleton '\n')+    (List.map Country.encodeEnglish [minBound .. maxBound])  decodeManyCountries :: Text -> Word-{-# noinline decodeManyCountries #-}-decodeManyCountries txt = List.foldl'-  (\acc t -> acc + maybe 0 (fromIntegral . Country.encodeNumeric) (Country.decode t))-  (0 :: Word)-  (Text.split (=='\n') txt)+{-# NOINLINE decodeManyCountries #-}+decodeManyCountries txt =+  List.foldl'+    (\acc t -> acc + maybe 0 (fromIntegral . Country.encodeNumeric) (Country.decode t))+    (0 :: Word)+    (Text.split (== '\n') txt)
bench/Size.hs view
@@ -1,13 +1,13 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE TypeApplications #-} -import Country (hashMapUtf8,hashMapUtf16)+import Country (hashMapUtf16, hashMapUtf8) import Data.Compact import Data.Foldable -import qualified Data.List as List import qualified Country import qualified Data.Bytes.HashMap.Word as Map+import qualified Data.List as List  main :: IO () main = do@@ -16,14 +16,17 @@   szUtf16 <- estimateHeapUse hashMapUtf16   putStrLn ("UTF-16 HashMap Size: " ++ show szUtf16)   putStrLn "UTF-8 HashMap Distribution:"-  forM_ (Map.distribution hashMapUtf8) $ \(bktSz,ct) ->+  forM_ (Map.distribution hashMapUtf8) $ \(bktSz, ct) ->     putStrLn (show bktSz ++ "," ++ show ct)   putStrLn ("UTF-8 HashMap Distinct Entropies: " ++ show (Map.distinctEntropies hashMapUtf8))  -- I think this rounds to the nearest 4KB. estimateHeapUse :: a -> IO Word-estimateHeapUse a = foldlM-  ( \lo i -> do-    w <- compactSized (i * 2000) True a >>= compactSize-    pure (min lo w)-  ) maxBound [1..50]+estimateHeapUse a =+  foldlM+    ( \lo i -> do+        w <- compactSized (i * 2000) True a >>= compactSize+        pure (min lo w)+    )+    maxBound+    [1 .. 50]
country.cabal view
@@ -1,7 +1,7 @@-cabal-version: 2.2-name: country-version: 0.2.4.1-synopsis: Country data type and functions+cabal-version:   3.0+name:            country+version:         0.2.4.2+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@@ -30,19 +30,29 @@   .   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: BSD-3-Clause-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-tested-with: GHC==8.10.1, GHC==8.8.3, GHC==8.6.5, GHC==8.4.4 +homepage:        https://github.com/byteverse/country+bug-reports:     https://github.com/byteverse/country/issues+license:         BSD-3-Clause+license-file:    LICENSE+author:          Andrew Martin+maintainer:      amartin@layer3com.com+copyright:       2017 Andrew Martin+category:        Web+build-type:      Simple+extra-doc-files:+  CHANGELOG.md+  README.md++tested-with:     GHC ==9.4.8 || ==9.6.3 || ==9.8.1++common build-settings+  default-language: Haskell2010+  ghc-options:      -Wall -Wunused-packages+ library-  hs-source-dirs: src+  import:          build-settings+  hs-source-dirs:  src   exposed-modules:     Continent     Continent.Unsafe@@ -50,6 +60,7 @@     Country.Identifier     Country.Subdivision     Country.Unsafe+   other-modules:     Country.Unexposed.Alias     Country.Unexposed.AlphaTwoPtr@@ -60,73 +71,71 @@     Country.Unexposed.Trie     Country.Unexposed.TrieByte     Country.Unexposed.Util+   build-depends:-    , aeson >=1.2 && <2.3-    , attoparsec >=0.13 && <0.15-    , base >=4.12 && <5-    , bytebuild >=0.3.4 && <0.4-    , bytehash >=0.1.1 && <0.2-    , byteslice >=0.2.3 && <0.3-    , bytestring >= 0.10 && <0.12-    , contiguous >=0.6.1-    , deepseq >= 1.3.0.2 && <1.5-    , entropy >=0.4.1.5 && <0.5-    , hashable >=1.2 && <1.5-    , primitive >= 0.6.4 && <0.10-    , primitive-unlifted >= 2.1-    , scientific >=0.3 && <0.4-    , text >= 2.0 && <2.2-    , text-short >=0.1.3-    , unordered-containers >=0.2 && <0.3-  default-language: Haskell2010-  ghc-options: -Wall -O2+    , aeson                 >=1.2     && <2.3+    , attoparsec            >=0.13    && <0.15+    , base                  >=4.9     && <5+    , bytebuild             >=0.3.4   && <0.4+    , bytehash              >=0.1.1   && <0.2+    , byteslice             >=0.2.3   && <0.3+    , bytestring            >=0.10+    , contiguous            >=0.6.1+    , deepseq               >=1.3.0.2 && <1.6+    , hashable              >=1.2     && <1.5+    , primitive             >=0.6.4   && <0.10+    , primitive-unlifted    >=2.1+    , scientific            >=0.3     && <0.4+    , text                  >=2.0     && <2.2+    , text-short            >=0.1.3+    , unordered-containers  >=0.2     && <0.3 +  ghc-options:     -O2+ test-suite test-  type: exitcode-stdio-1.0+  import:         build-settings+  type:           exitcode-stdio-1.0   hs-source-dirs: test-  main-is: Spec.hs+  main-is:        Spec.hs   build-depends:-    , QuickCheck     , base     , byteslice     , country     , primitive-    , quickcheck-classes >=0.6.4+    , QuickCheck+    , quickcheck-classes  >=0.6.4     , tasty     , tasty-quickcheck     , text     , text-short-  ghc-options: -O2-  default-language: Haskell2010  benchmark bench-  type: exitcode-stdio-1.0+  import:         build-settings+  type:           exitcode-stdio-1.0   build-depends:-    , country     , base-    , byteslice-    , bytestring+    , country     , gauge-    , primitive-    , text >=1.2-  ghc-options: -Wall -O2-  default-language: Haskell2010+    , text     >=1.2++  ghc-options:    -O2   hs-source-dirs: bench-  main-is: Main.hs+  main-is:        Main.hs  benchmark bench-size-  type: exitcode-stdio-1.0+  import:         build-settings+  type:           exitcode-stdio-1.0   build-depends:-    , country     , base+    , bytehash     , bytestring     , compact-    , bytehash-  ghc-options: -Wall -O2-  default-language: Haskell2010+    , country++  ghc-options:    -O2   hs-source-dirs: bench-  main-is: Size.hs+  main-is:        Size.hs  source-repository head   type:     git-  location: https://github.com/andrewthad/country+  location: git://github.com/byteverse/country.git
src/Continent.hs view
@@ -10,12 +10,15 @@   , pattern NorthAmerica   , pattern Oceania   , pattern SouthAmerica-  -- * Continent Mapping++    -- * Continent Mapping   , continent-  -- * Name++    -- * Name   , encodeEnglish   , decodeEnglish-  -- * Two-letter Codes++    -- * Two-letter Codes   , alphaUpper   , alphaLower   , decodeAlpha@@ -26,8 +29,8 @@ import Control.Monad (forM_) import Control.Monad.ST (runST) import Country.Unexposed.Continents (continentAList)-import Country.Unexposed.Util (mapTextArray,charToWord8,word16ToInt,timesTwo)-import Country.Unsafe (Country(Country))+import Country.Unexposed.Util (charToWord8, mapTextArray, timesTwo, word16ToInt)+import Country.Unsafe (Country (Country)) import Data.Char (toLower) import Data.Text (Text) import Data.Word (Word8)@@ -37,19 +40,17 @@ import qualified Data.Text.Array as TA import qualified Data.Text.Internal as TI - numberOfContinents :: Int numberOfContinents = length continentNameDb {-# NOINLINE numberOfContinents #-} - alphaUpper :: Continent -> Text alphaUpper (Continent n) = TI.text allAlphaUpper (timesTwo (fromIntegral n)) 2  allAlphaUpper :: TA.Array allAlphaUpper = TA.run $ do   m <- TA.new (timesTwo numberOfContinents)-  forM_ continentNameDb $ \(n,_,(a1,a2)) -> do+  forM_ continentNameDb $ \(n, _, (a1, a2)) -> do     let ix = timesTwo (fromIntegral n)     TA.unsafeWrite m ix (charToWord8 a1)     TA.unsafeWrite m (ix + 1) (charToWord8 a2)@@ -65,7 +66,8 @@  decodeAlpha :: Text -> Maybe Continent decodeAlpha = fmap Continent . flip lookup tbl . T.toUpper-  where tbl = flip map continentNameDb $ \(n,_,(a,b)) -> ((T.toUpper . T.pack) [a,b], n)+ where+  tbl = flip map continentNameDb $ \(n, _, (a, b)) -> ((T.toUpper . T.pack) [a, b], n)  encodeEnglish :: Continent -> Text encodeEnglish (Continent n) = Prim.indexArray englishContinentNamesText (fromIntegral n)@@ -73,13 +75,14 @@ englishContinentNamesText :: Prim.Array Text englishContinentNamesText = runST $ do   m <- Prim.newArray numberOfContinents unnamed-  mapM_ (\(ix,name,_) -> Prim.writeArray m (fromIntegral ix) name) continentNameDb+  mapM_ (\(ix, name, _) -> Prim.writeArray m (fromIntegral ix) name) continentNameDb   Prim.unsafeFreezeArray m {-# NOINLINE englishContinentNamesText #-}  decodeEnglish :: Text -> Maybe Continent decodeEnglish = fmap Continent . flip lookup tbl-  where tbl = flip map continentNameDb $ \(n,name,_) -> (name, n)+ where+  tbl = flip map continentNameDb $ \(n, name, _) -> (name, n)  continent :: Country -> Continent continent (Country n) = Continent $ Prim.indexArray allContinents (word16ToInt n)@@ -87,7 +90,7 @@ allContinents :: Prim.Array Word8 allContinents = runST $ do   m <- Prim.newArray numberOfPossibleCodes 255-  forM_ continentAList $ \(ix,Continent n) ->+  forM_ continentAList $ \(ix, Continent n) ->     Prim.writeArray m (word16ToInt ix) n   Prim.unsafeFreezeArray m {-# NOINLINE allContinents #-}
src/Continent/Unsafe.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE PatternSynonyms #-}  module Continent.Unsafe-  ( Continent(..)+  ( Continent (..)   , pattern Africa   , pattern Asia   , pattern Antarctica@@ -17,10 +17,8 @@ import Data.Text (Text) import Data.Word (Word8) - newtype Continent = Continent Word8-  deriving(Eq,Ord,Enum)-+  deriving (Eq, Ord, Enum)  {-# COMPLETE Africa, Asia, Antarctica, Europe, NorthAmerica, Oceania, SouthAmerica #-} pattern Africa, Asia, Antarctica, Europe, NorthAmerica, Oceania, SouthAmerica :: Continent@@ -32,8 +30,7 @@ pattern Oceania = Continent 5 pattern SouthAmerica = Continent 6 --continentNameDb :: [(Word8,Text,(Char,Char))]+continentNameDb :: [(Word8, Text, (Char, Char))] continentNameDb =   [ (0, "Africa", ('A', 'F'))   , (1, "Asia", ('A', 'N'))
src/Country.hs view
@@ -2,14 +2,14 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE MagicHash #-} -{-# OPTIONS_GHC -Wall #-}- -- | Country type and helpers. module Country   ( Country+     -- * Three digit code   , encodeNumeric   , decodeNumeric+     -- * Name   , encodeEnglish   , encodeEnglishShort@@ -18,6 +18,7 @@   , decodeUtf8Bytes   , parser   , parserUtf8+     -- * Alpha-2 and Alpha-3   , alphaTwoUpper   , alphaTwoUpperUtf8Ptr@@ -27,6 +28,7 @@   , alphaTwoLower   , decodeAlphaTwo   , decodeAlphaThree+     -- * Hash Maps for Decoding   , hashMapUtf8   , hashMapUtf16@@ -36,23 +38,21 @@ import Control.Monad.ST (runST) import Country.Unexposed.AlphaTwoPtr (alphaTwoPtr) import Country.Unexposed.Encode.English (countryNameQuads)-import Country.Unexposed.Names (hashMapUtf16,hashMapUtf8)-import Country.Unexposed.Names (numberOfPossibleCodes,alphaTwoHashMap,alphaThreeHashMap,decodeMap,decodeMapUtf8,decodeNumeric,encodeEnglish,encodeEnglishShort)-import Country.Unexposed.Trie (Trie,trieFromList,trieParser)-import Country.Unexposed.TrieByte (TrieByte,trieByteFromList,trieByteParser)-import Country.Unexposed.Util (newZeroedByteArray,mapTextArray,charToWord8,word16ToInt,timesTwo,timesThree)-import Country.Unsafe (Country(..))-import Data.Bytes.Types (Bytes(Bytes))+import Country.Unexposed.Names (alphaThreeHashMap, alphaTwoHashMap, decodeMap, decodeMapUtf8, decodeNumeric, encodeEnglish, encodeEnglishShort, hashMapUtf16, hashMapUtf8, numberOfPossibleCodes)+import Country.Unexposed.Trie (Trie, trieFromList, trieParser)+import Country.Unexposed.TrieByte (TrieByte, trieByteFromList, trieByteParser)+import Country.Unexposed.Util (charToWord8, mapTextArray, newZeroedByteArray, timesThree, timesTwo, word16ToInt)+import Country.Unsafe (Country (..)) import Data.ByteString (ByteString)+import Data.Bytes.Types (Bytes (Bytes)) import Data.Char (toLower) import Data.Coerce (coerce)-import Data.Primitive (writeByteArray,indexByteArray,unsafeFreezeByteArray)-import Data.Primitive.ByteArray (ByteArray(..))+import Data.Primitive (indexByteArray, unsafeFreezeByteArray, writeByteArray)+import Data.Primitive.ByteArray (ByteArray (..)) import Data.Primitive.Ptr (indexOffPtr) import Data.Text (Text)-import Data.Word (Word16)-import Data.Word (Word8)-import Foreign.Ptr (Ptr,plusPtr)+import Data.Word (Word16, Word8)+import Foreign.Ptr (Ptr, plusPtr)  import qualified Data.Attoparsec.ByteString as AB import qualified Data.Attoparsec.Text as AT@@ -63,8 +63,9 @@ import qualified Data.Text.Encoding as TE 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.+{- | 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 @@ -72,20 +73,22 @@ alphaTwoUpper :: Country -> Text alphaTwoUpper c = TI.text allAlphaTwoUpper (timesTwo (indexOfCountry c)) 2 --- | The alpha-2 country code, uppercase. The resulting address always--- has two bytes at it.+{- | The alpha-2 country code, uppercase. The resulting address always+has two bytes at it.+-} alphaTwoUpperUtf8Ptr :: Country -> Ptr Word8 alphaTwoUpperUtf8Ptr (Country c) =   plusPtr alphaTwoPtr (2 * fromIntegral c)  alphaTwoUpperUtf8BoundedBuilder :: Country -> BBU.Builder 2-alphaTwoUpperUtf8BoundedBuilder !c = BBU.construct-  (\arr ix -> do-    let ptr = alphaTwoUpperUtf8Ptr c-    writeByteArray arr ix (indexOffPtr ptr 0)-    writeByteArray arr (ix + 1) (indexOffPtr ptr 1)-    pure (ix + 2)-  )+alphaTwoUpperUtf8BoundedBuilder !c =+  BBU.construct+    ( \arr ix -> do+        let ptr = alphaTwoUpperUtf8Ptr c+        writeByteArray arr ix (indexOffPtr ptr 0)+        writeByteArray arr (ix + 1) (indexOffPtr ptr 1)+        pure (ix + 2)+    )  -- | The alpha-3 country code, uppercase alphaThreeUpper :: Country -> Text@@ -107,12 +110,12 @@ decodeAlphaThree :: Text -> Maybe Country decodeAlphaThree = flip HM.lookup alphaThreeHashMap ---- | 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 there are names that are missing.+{- | 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 there are names that are missing.+-} decode :: Text -> Maybe Country decode (TI.Text (TA.ByteArray arr) off8 len8) =   case (BytesHashMap.lookup (Bytes (ByteArray arr) off8 len8) hashMapUtf8) of@@ -128,11 +131,12 @@   Nothing -> Nothing   Just w -> Just (Country (fromIntegral w)) --- | Parse a country from its name using an attoparsec text parser. This---   function is language-agnostic and can handle any source language.---   In the case that one possible country name is a prefix of another---   possible name (for example, United States vs United States of America),---   the longest possible will be parsed.+{- | Parse a country from its name using an attoparsec text parser. This+  function is language-agnostic and can handle any source language.+  In the case that one possible country name is a prefix of another+  possible name (for example, United States vs United States of America),+  the longest possible will be parsed.+-} parser :: AT.Parser Country parser = coerce (trieParser decodeTrie) @@ -147,7 +151,7 @@ positions :: ByteArray positions = runST $ do   m <- newZeroedByteArray (timesTwo numberOfPossibleCodes)-  forM_ (zip (enumFrom (0 :: Word16)) countryNameQuads) $ \(ix,(n,_,_,_)) -> do+  forM_ (zip (enumFrom (0 :: Word16)) countryNameQuads) $ \(ix, (n, _, _, _)) -> do     writeByteArray m (word16ToInt n) ix   unsafeFreezeByteArray m {-# NOINLINE positions #-}@@ -162,7 +166,7 @@ allAlphaTwoUpper :: TA.Array allAlphaTwoUpper = TA.run $ do   m <- TA.new (timesTwo numberOfCountries)-  forM_ countryNameQuads $ \(n,_,(a1,a2),_) -> do+  forM_ countryNameQuads $ \(n, _, (a1, a2), _) -> do     let ix = timesTwo (indexOfCountry (Country n))     TA.unsafeWrite m ix (charToWord8 a1)     TA.unsafeWrite m (ix + 1) (charToWord8 a2)@@ -172,7 +176,7 @@ allAlphaThreeUpper :: TA.Array allAlphaThreeUpper = TA.run $ do   m <- TA.new (timesThree numberOfCountries)-  forM_ countryNameQuads $ \(n,_,_,(a1,a2,a3)) -> do+  forM_ countryNameQuads $ \(n, _, _, (a1, a2, a3)) -> do     let ix = timesThree (indexOfCountry (Country n))     TA.unsafeWrite m ix (charToWord8 a1)     TA.unsafeWrite m (ix + 1) (charToWord8 a2)@@ -189,9 +193,9 @@ {-# NOINLINE allAlphaTwoLower #-}  decodeTrie :: Trie-decodeTrie = trieFromList (map (\(a,Country x) -> (a,x)) (HM.toList decodeMap))+decodeTrie = trieFromList (map (\(a, Country x) -> (a, x)) (HM.toList decodeMap)) {-# NOINLINE decodeTrie #-}  decodeTrieUtf8 :: TrieByte-decodeTrieUtf8 = trieByteFromList (map (\(a,Country x) -> (TE.encodeUtf8 a,x)) (HM.toList decodeMap))+decodeTrieUtf8 = trieByteFromList (map (\(a, Country x) -> (TE.encodeUtf8 a, x)) (HM.toList decodeMap)) {-# NOINLINE decodeTrieUtf8 #-}
src/Country/Subdivision.hs view
@@ -6,53 +6,55 @@  module Country.Subdivision   ( Subdivision-  -- * Accessors++    -- * Accessors   , encodeAlpha   , encodeAlphaShort   , encodeEnglish   , encodeEnglishShort   , category-  -- * Decoding++    -- * Decoding   , decodeAlpha   , decodeEnglish   , decodeEnglishUtf8Bytes   ) where  import Data.Bytes (Bytes)-import Data.Hashable (Hashable) import Data.HashMap.Strict (HashMap)+import Data.Hashable (Hashable) import Data.Primitive.Contiguous (index) import Data.Primitive.Types (Prim) import Data.Text (Text)-import Data.Text.Short (ShortText) import Data.Text.Encoding (encodeUtf8)+import Data.Text.Short (ShortText) import Data.Word (Word16) import Foreign.Storable (Storable)  import qualified Country.Unexposed.Subdivision as Arrays-import qualified Data.Bytes.HashMap.Word as BytesHashMap import qualified Data.ByteString as ByteString+import qualified Data.Bytes.HashMap.Word as BytesHashMap import qualified Data.HashMap.Strict as HM import qualified Data.Primitive.Contiguous as Arr import qualified Data.Text as T import qualified GHC.Exts as Exts  newtype Subdivision = Subdivision Word16-  deriving (Eq,Ord,Prim,Hashable,Storable)+  deriving (Eq, Ord, Prim, Hashable, Storable)  instance Show Subdivision where   show = show . encodeAlpha  instance Enum Subdivision where   fromEnum (Subdivision w) = fromIntegral w-  toEnum number = if number >= 0 && number < Arrays.actualNumberOfSubdivisions-    then Subdivision (fromIntegral number)-    else error ("toEnum: cannot convert " ++ show number ++ " to Subdivision")+  toEnum number =+    if number >= 0 && number < Arrays.actualNumberOfSubdivisions+      then Subdivision (fromIntegral number)+      else error ("toEnum: cannot convert " ++ show number ++ " to Subdivision") instance Bounded Subdivision where   minBound = Subdivision 0   maxBound = Subdivision (fromIntegral $ Arrays.actualNumberOfSubdivisions - 1) - -- country :: Subdivision -> Country -- country (Subdivision i) = index Arrays.countryArray i @@ -71,43 +73,49 @@ category :: Subdivision -> Text category (Subdivision i) = index Arrays.categoryArray (fromIntegral @Word16 @Int i) - -- | Decode a 'Subdivision' using its ISO subdivision code. decodeAlpha :: Text -> Maybe Subdivision decodeAlpha = flip HM.lookup alphaHashMap  alphaHashMap :: HashMap Text Subdivision-alphaHashMap = Arr.ifoldl'-  (\hm i x ->-      HM.insert x (Subdivision $ fromIntegral i)-    $ hm-  )-  HM.empty Arrays.codeArray+alphaHashMap =+  Arr.ifoldl'+    ( \hm i x ->+        HM.insert x (Subdivision $ fromIntegral i) $+          hm+    )+    HM.empty+    Arrays.codeArray {-# NOINLINE alphaHashMap #-} --- | Decode a 'Subdivision' using its ISO subdivision English name--- It's not terribly forgiving, accepting only the official(?) names I found on wiki.+{- | Decode a 'Subdivision' using its ISO subdivision English name+It's not terribly forgiving, accepting only the official(?) names I found on wiki.+-} decodeEnglish :: Text -> Maybe Subdivision decodeEnglish = flip HM.lookup englishHashMap  englishHashMap :: HashMap Text Subdivision-englishHashMap = Arr.ifoldl'-  (\hm i x ->-    let place = Subdivision (fromIntegral i)-     in HM.insert x place-      $ HM.insert (T.toLower $ x) place-      $ hm-  )-  HM.empty Arrays.nameArray+englishHashMap =+  Arr.ifoldl'+    ( \hm i x ->+        let place = Subdivision (fromIntegral i)+         in HM.insert x place $+              HM.insert (T.toLower $ x) place $+                hm+    )+    HM.empty+    Arrays.nameArray {-# NOINLINE englishHashMap #-}  englishHashMapUtf8Bytes :: BytesHashMap.Map {-# NOINLINE englishHashMapUtf8Bytes #-}-englishHashMapUtf8Bytes = BytesHashMap.fromTrustedList-  ( imap-    (\i t -> (Exts.fromList (ByteString.unpack (encodeUtf8 t)),fromIntegral i)-    ) (Exts.toList Arrays.nameArray)-  )+englishHashMapUtf8Bytes =+  BytesHashMap.fromTrustedList+    ( imap+        ( \i t -> (Exts.fromList (ByteString.unpack (encodeUtf8 t)), fromIntegral i)+        )+        (Exts.toList Arrays.nameArray)+    )  decodeEnglishUtf8Bytes :: Bytes -> Maybe Subdivision decodeEnglishUtf8Bytes !bs = case BytesHashMap.lookup bs englishHashMapUtf8Bytes of@@ -116,6 +124,6 @@  imap :: (Int -> a -> b) -> [a] -> [b] imap f ls = go 0 ls-  where-    go !i (x:xs) = f i x : go (i + 1) xs-    go !_ []     = []+ where+  go !i (x : xs) = f i x : go (i + 1) xs+  go !_ [] = []
src/Country/Unexposed/Encode/English.hs view
@@ -4,262 +4,262 @@   ) where  import Data.Text (Text)-import Data.Word (Word16) import qualified Data.Text as T+import Data.Word (Word16) --- first value is country code, second is english name, +-- 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 :: [(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'))-  , (383, T.pack "Kosovo",('X','K'),('X','K','X'))+  [ (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'))+  , (383, T.pack "Kosovo", ('X', 'K'), ('X', 'K', 'X'))   ] {-# NOINLINE countryNameQuads #-}
src/Country/Unexposed/Names.hs view
@@ -1,12 +1,11 @@-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MagicHash #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE UnboxedTuples #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE TypeInType #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE DeriveDataTypeable #-}- {-# OPTIONS_HADDOCK not-home #-}  module Country.Unexposed.Names@@ -22,7 +21,7 @@   , decodeNumeric   , encodeEnglish   , encodeEnglishShort-  , Country(..)+  , Country (..)   ) where  import Control.Monad@@ -33,75 +32,69 @@ import Country.Unexposed.Alias (aliases) import Country.Unexposed.Encode.English (countryNameQuads) import Country.Unexposed.Util (newZeroedByteArray)-import Data.Bytes.Types (Bytes(Bytes)) import Data.ByteString (ByteString)-import Data.Char (toLower,isAlpha,toUpper)+import Data.Char (isAlpha, toLower, toUpper) import Data.Data-import Data.Hashable (Hashable) import Data.HashMap.Strict (HashMap)-import Data.Primitive (Array,indexArray,newArray,unsafeFreezeArray,writeArray)-import Data.Primitive (sizeOf)-import Data.Primitive (writeByteArray,indexByteArray,unsafeFreezeByteArray)-import Data.Primitive.ByteArray (ByteArray(..))+import Data.Hashable (Hashable)+import Data.Primitive (Array, indexArray, indexByteArray, newArray, sizeOf, unsafeFreezeArray, unsafeFreezeByteArray, writeArray, writeByteArray)+import Data.Primitive.ByteArray (ByteArray (..)) import Data.Primitive.Types (Prim) import Data.Text (Text)-import Data.Text.Encoding (encodeUtf8,encodeUtf16BE)+import Data.Text.Encoding (encodeUtf16BE, encodeUtf8) import Data.Text.Short (ShortText) import Foreign.Storable (Storable) import GHC.Generics (Generic)  import qualified Data.Aeson as AE import qualified Data.Aeson.Types as AET+import qualified Data.ByteString as ByteString import qualified Data.Bytes as Bytes import qualified Data.Bytes.HashMap.Word as BytesHashMap-import qualified Data.ByteString as ByteString import qualified Data.HashMap.Strict as HM import qualified Data.List as L import qualified Data.Primitive.Unlifted.Array as PM import qualified Data.Scientific as SCI import qualified Data.Text as T-import qualified Data.Text.Array as Text-import qualified Data.Text.Internal as Text import qualified Data.Text.Short as TS import qualified GHC.Exts as Exts  -- | The name of a country given in English encodeEnglish :: Country -> Text-{-# inline encodeEnglish #-}+{-# INLINE encodeEnglish #-} encodeEnglish (Country n) = indexArray englishCountryNamesText (word16ToInt n)  -- | The name of a country given in English encodeEnglishShort :: Country -> ShortText-{-# inline encodeEnglishShort #-}+{-# INLINE encodeEnglishShort #-} encodeEnglishShort (Country n) =   PM.indexUnliftedArray englishCountryNamesShortText (word16ToInt n)  englishCountryNamesShortText :: PM.UnliftedArray ShortText englishCountryNamesShortText = runST $ do   m <- PM.newUnliftedArray numberOfPossibleCodes unnamedShort-  mapM_ (\(ix,name,_,_) -> PM.writeUnliftedArray m (word16ToInt ix) (TS.fromText name)) countryNameQuads+  mapM_ (\(ix, name, _, _) -> PM.writeUnliftedArray m (word16ToInt ix) (TS.fromText name)) countryNameQuads   PM.unsafeFreezeUnliftedArray m {-# NOINLINE englishCountryNamesShortText #-}  englishCountryNamesText :: Array Text englishCountryNamesText = runST $ do   m <- newArray numberOfPossibleCodes unnamed-  mapM_ (\(ix,name,_,_) -> writeArray m (word16ToInt ix) name) countryNameQuads+  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+  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 . slowToTitle) t of   Nothing -> T.empty-  Just (b,bs) -> T.cons (toLower b) bs-+  Just (b, bs) -> T.cons (toLower b) bs  unnamed :: Text unnamed = T.pack "Invalid Country"@@ -119,38 +112,45 @@  decodeMap :: HashMap Text Country {-# NOINLINE decodeMap #-}-decodeMap = HM.fromList (map (\(a,b) -> (b,Country a)) countryPairs)+decodeMap = HM.fromList (map (\(a, b) -> (b, Country a)) countryPairs)  hashMapUtf8 :: BytesHashMap.Map-hashMapUtf8 = BytesHashMap.fromTrustedList-  ( map-    (\(a,t) -> (Exts.fromList (ByteString.unpack (encodeUtf8 t)),fromIntegral a)-    ) countryPairs-  )+hashMapUtf8 =+  BytesHashMap.fromTrustedList+    ( map+        ( \(a, t) -> (Exts.fromList (ByteString.unpack (encodeUtf8 t)), fromIntegral a)+        )+        countryPairs+    )  -- It is a hack to pull from a source of randomness in here, but whatever. -- Maybe I can get rid of this if GHC ever supports casing on values of -- type ByteArray# along with good codegen for it. hashMapUtf16 :: BytesHashMap.Map-hashMapUtf16 = BytesHashMap.fromTrustedList-  ( map-    (\(a, str) ->-      (Bytes.fromByteString $ encodeUtf16BE str, fromIntegral a)-    ) countryPairs-  )-countryPairs :: [(Word16,Text)]+hashMapUtf16 =+  BytesHashMap.fromTrustedList+    ( map+        ( \(a, str) ->+            (Bytes.fromByteString $ encodeUtf16BE str, fromIntegral a)+        )+        countryPairs+    )+countryPairs :: [(Word16, Text)] {-# NOINLINE countryPairs #-} countryPairs =-  let x = aliases ++ concatMap-        (\(num,name,(c2a,c2b),(c3a,c3b,c3c)) ->-          [ (num,name)-          , (num,T.pack [c2a,c2b])-          , (num,T.pack [c3a,c3b,c3c])-          , (num,T.pack [toLower c2a,toLower c2b])-          , (num,T.pack [toLower c3a,toLower c3b,toLower c3c])-          ]-        ) countryNameQuads-   in x ++ map (\(a,b) -> (a,slowToTitle b)) x+  let x =+        aliases+          ++ concatMap+            ( \(num, name, (c2a, c2b), (c3a, c3b, c3c)) ->+                [ (num, name)+                , (num, T.pack [c2a, c2b])+                , (num, T.pack [c3a, c3b, c3c])+                , (num, T.pack [toLower c2a, toLower c2b])+                , (num, T.pack [toLower c3a, toLower c3b, toLower c3c])+                ]+            )+            countryNameQuads+   in x ++ map (\(a, b) -> (a, slowToTitle b)) x  -- This is only needed to support the reflex-platform fork of text. Fortunately, -- in all the places this is needed, it is only called to build CAFs.@@ -160,7 +160,7 @@ upperFirst :: Text -> Text upperFirst t = case T.uncons t of   Nothing -> T.empty-  Just (c,cs) -> T.cons (toUpper c) cs+  Just (c, cs) -> T.cons (toUpper c) cs  decodeMapUtf8 :: HashMap ByteString Country decodeMapUtf8 = HM.foldlWithKey' (\hm k v -> HM.insert (encodeUtf8 k) v hm) HM.empty decodeMap@@ -168,27 +168,28 @@  -- | A country recognized by ISO 3166. newtype Country = Country Word16-  deriving (Eq,Ord,Prim,Hashable,Storable,NFData,Generic,Data,Typeable)+  deriving (Eq, Ord, Prim, Hashable, Storable, NFData, Generic, Data, Typeable)  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")+  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+orderedCountryCodes = L.sort $ map (\(a, _, _, _) -> a) countryNameQuads  countryCodeToSequentialMapping :: ByteArray countryCodeToSequentialMapping = runST $ do   numbers <- newZeroedByteArray (numberOfPossibleCodes * sizeOf (undefined :: Int))-  forM_ (zip [0 :: Int,1..] orderedCountryCodes) $ \(number,code) -> do+  forM_ (zip [0 :: Int, 1 ..] orderedCountryCodes) $ \(number, code) -> do     writeByteArray numbers (word16ToInt code) number   unsafeFreezeByteArray numbers {-# NOINLINE countryCodeToSequentialMapping #-}@@ -196,7 +197,7 @@ sequentialToCountryCodeMapping :: ByteArray sequentialToCountryCodeMapping = runST $ do   codes <- newZeroedByteArray (actualNumberOfCountries * sizeOf (undefined :: Word16))-  forM_ (zip [0 :: Int,1..] orderedCountryCodes) $ \(number,code) -> do+  forM_ (zip [0 :: Int, 1 ..] orderedCountryCodes) $ \(number, code) -> do     writeByteArray codes number (code :: Word16)   unsafeFreezeByteArray codes {-# NOINLINE sequentialToCountryCodeMapping #-}@@ -205,7 +206,6 @@ actualNumberOfCountries = length countryNameQuads {-# NOINLINE actualNumberOfCountries #-} - -- todo: add support for encoding directly to bytestring. -- Also, add suport for ToJSONKey and FromJSONKey once everything -- finally gets off of aeson-0.11 (looking at you, reflex-platform)@@ -222,42 +222,49 @@       Just w -> case decodeNumeric w of         Just c -> return c         Nothing -> fail errMsg-      where errMsg = fail $ "invalid country code " ++ show n+     where+      errMsg = fail $ "invalid country code " ++ show n     _ -> AET.typeMismatch "Country" x --- | 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.+{- | 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+decodeNumeric n =+  if n < 1000 && indexByteArray numericValidities (word16ToInt n) == (1 :: Word8)+    then Just (Country n)+    else Nothing  -- | The elements in this array are Word8 (basically boolean) numericValidities :: ByteArray numericValidities = runST $ do   m <- newZeroedByteArray numberOfPossibleCodes-  forM_ countryNameQuads $ \(n,_,_,_) -> do+  forM_ countryNameQuads $ \(n, _, _, _) -> do     writeByteArray m (word16ToInt n) (1 :: Word8)   unsafeFreezeByteArray m {-# NOINLINE numericValidities #-}  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+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+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 #-}
src/Country/Unexposed/Trie.hs view
@@ -4,22 +4,22 @@   , trieParser   ) where -import Data.HashMap.Strict (HashMap)-import Data.Word (Word16)-import Data.Text (Text)-import Data.Semigroup (Semigroup) import Control.Applicative ((<|>))-import qualified Data.Text as T-import qualified Data.HashMap.Strict as HM import qualified Data.Attoparsec.Text as AT+import Data.HashMap.Strict (HashMap)+import qualified Data.HashMap.Strict as HM import qualified Data.Semigroup as SG+import Data.Text (Text)+import qualified Data.Text as T+import Data.Word (Word16) --- | If the value is not the max Word16 (65535), there ---   is a match. This means that 65535 cannot be used, which ---   is fine for this since 65535 is not used as a country code.+{- | If the value is not the max Word16 (65535), there+  is a match. This means that 65535 cannot be used, which+  is fine for this since 65535 is not used as a country code.+-} data Trie = Trie-  { trieValue :: {-# UNPACK #-} !Word16-  , trieChildren :: !(HashMap Char Trie)+  { _trieValue :: {-# UNPACK #-} !Word16+  , _trieChildren :: !(HashMap Char Trie)   }  empty :: Trie@@ -32,10 +32,11 @@ placeholder = 0xFFFF  singleton :: Text -> Word16 -> Trie-singleton fullName code = go fullName where+singleton fullName code = go fullName+ where   go :: Text -> Trie   go name = case T.uncons name of-    Just (char,nameNext) -> Trie placeholder (HM.singleton char (go nameNext))+    Just (char, nameNext) -> Trie placeholder (HM.singleton char (go nameNext))     Nothing -> Trie code HM.empty  instance Semigroup Trie where@@ -45,7 +46,7 @@   mempty = empty   mappend = (SG.<>) -trieFromList :: [(Text,Word16)] -> Trie+trieFromList :: [(Text, Word16)] -> Trie trieFromList = foldMap (uncurry singleton)  -- it seems like attoparsec should have some kind of convenience@@ -53,7 +54,8 @@ -- input once your certain that it will be consumed, but I cannot -- find a way to use the api to do this. trieParser :: Trie -> AT.Parser Word16-trieParser = go where+trieParser = go+ where   go :: Trie -> AT.Parser Word16   go (Trie value children) = do     let keepGoing = do@@ -64,4 +66,3 @@     if value == placeholder       then keepGoing       else keepGoing <|> return value-
src/Country/Unexposed/TrieByte.hs view
@@ -4,22 +4,22 @@   , trieByteParser   ) where -import Data.HashMap.Strict (HashMap)-import Data.Word (Word16,Word8)-import Data.ByteString (ByteString)-import Data.Semigroup (Semigroup) import Control.Applicative ((<|>))+import qualified Data.Attoparsec.ByteString as AB+import Data.ByteString (ByteString) import qualified Data.ByteString as B+import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HM-import qualified Data.Attoparsec.ByteString as AB import qualified Data.Semigroup as SG+import Data.Word (Word16, Word8) --- | If the value is not the max Word16 (65535), there ---   is a match. This means that 65535 cannot be used, which ---   is fine for this since 65535 is not used as a country code.+{- | If the value is not the max Word16 (65535), there+  is a match. This means that 65535 cannot be used, which+  is fine for this since 65535 is not used as a country code.+-} data TrieByte = TrieByte-  { trieValue :: {-# UNPACK #-} !Word16-  , trieChildren :: !(HashMap Word8 TrieByte)+  { _trieValue :: {-# UNPACK #-} !Word16+  , _trieChildren :: !(HashMap Word8 TrieByte)   }  empty :: TrieByte@@ -32,10 +32,11 @@ placeholder = 0xFFFF  singleton :: ByteString -> Word16 -> TrieByte-singleton fullName code = go fullName where+singleton fullName code = go fullName+ where   go :: ByteString -> TrieByte   go name = case B.uncons name of-    Just (char,nameNext) -> TrieByte placeholder (HM.singleton char (go nameNext))+    Just (char, nameNext) -> TrieByte placeholder (HM.singleton char (go nameNext))     Nothing -> TrieByte code HM.empty  instance Semigroup TrieByte where@@ -45,7 +46,7 @@   mempty = empty   mappend = (SG.<>) -trieByteFromList :: [(ByteString,Word16)] -> TrieByte+trieByteFromList :: [(ByteString, Word16)] -> TrieByte trieByteFromList = foldMap (uncurry singleton)  -- it seems like attoparsec should have some kind of convenience@@ -53,7 +54,8 @@ -- input once your certain that it will be consumed, but I cannot -- find a way to use the api to do this. trieByteParser :: TrieByte -> AB.Parser Word16-trieByteParser = go where+trieByteParser = go+ where   go :: TrieByte -> AB.Parser Word16   go (TrieByte value children) = do     let keepGoing = do@@ -64,5 +66,3 @@     if value == placeholder       then keepGoing       else keepGoing <|> return value--
src/Country/Unexposed/Util.hs view
@@ -13,16 +13,16 @@   ) where  import Control.Monad.Primitive (PrimMonad, PrimState)-import Data.Bits (unsafeShiftL,unsafeShiftR)-import Data.Char (chr,ord)-import Data.Primitive.ByteArray (MutableByteArray,newByteArray,fillByteArray)-import Data.Word (Word8,Word16)+import Data.Bits (unsafeShiftL, unsafeShiftR)+import Data.Char (chr, ord)+import Data.Primitive.ByteArray (MutableByteArray, fillByteArray, newByteArray)+import Data.Word (Word16, Word8) import GHC.Exts (sizeofByteArray#)-import GHC.Int (Int(I#))+import GHC.Int (Int (I#))  import qualified Data.Text.Array as TA -newZeroedByteArray :: PrimMonad m => Int -> m (MutableByteArray (PrimState m))+newZeroedByteArray :: (PrimMonad m) => Int -> m (MutableByteArray (PrimState m)) newZeroedByteArray len = do   arr <- newByteArray len   let arrStart = 0@@ -36,11 +36,12 @@   let len = I# (sizeofByteArray# inner)   m <- TA.new len   TA.copyI len m 0 a 0-  let go !ix = if ix < len-        then do-          TA.unsafeWrite m ix (charToWord8 (f (word8ToChar (TA.unsafeIndex a ix))))-          go (ix + 1)-        else return ()+  let go !ix =+        if ix < len+          then do+            TA.unsafeWrite m ix (charToWord8 (f (word8ToChar (TA.unsafeIndex a ix))))+            go (ix + 1)+          else return ()   go 0   return m {-# INLINE mapTextArray #-}
src/Country/Unsafe.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_HADDOCK not-home #-} -{-| This module provides the data constructor for a 'Country'.+{- | 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@@ -11,8 +11,7 @@     in this library to segfault. -} module Country.Unsafe-  ( Country(..)+  ( Country (..)   ) where -import Country.Unexposed.Names (Country(..))-+import Country.Unexposed.Names (Country (..))
test/Spec.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeApplications #-}+{-# OPTIONS_GHC -Wno-orphans #-}  import Continent (Continent) import Country (Country)@@ -7,10 +8,10 @@ import Data.Char (ord) import Data.Maybe (fromJust) import Data.Primitive.Ptr (indexOffPtr)-import Data.Proxy (Proxy(..))+import Data.Proxy (Proxy (..)) import Data.Word (Word8)-import Test.Tasty (defaultMain,testGroup,TestTree)-import Test.Tasty.QuickCheck (testProperty,(===))+import Test.Tasty (TestTree, defaultMain, testGroup)+import Test.Tasty.QuickCheck (testProperty, (===))  import qualified Continent import qualified Country@@ -21,81 +22,88 @@ import qualified Data.Text.Short as TS import qualified Test.QuickCheck as QC import qualified Test.QuickCheck.Classes as QCC-import qualified Test.QuickCheck.Classes.IsList as QCCL import qualified Test.Tasty.QuickCheck as TQC  main :: IO ()-main = defaultMain $ testGroup "Country" $-  ( map lawsToTest-    $ map ($ proxy)-    $ [ QCC.boundedEnumLaws-      , QCC.eqLaws-      , QCC.ordLaws-      , QCC.primLaws-      , QCC.showLaws-      , QCC.storableLaws-      ]-  ) ++-  ( map lawsToTest-    $ map ($ Proxy @Continent)-    $ [ -- QCC.boundedEnumLaws-       QCC.eqLaws-      , QCC.ordLaws-      -- , QCC.primLaws-      -- , QCC.showLaws-      -- , QCC.storableLaws-      ]-  ) ++-  [ testProperty "encode-decode-english"-      (\x -> Just x === Country.decode (Country.encodeEnglish x))-  , testProperty "encode-decode-alpha-2-upper"-      (\x -> Just x === Country.decode (Country.alphaTwoUpper x))-  , testProperty "encode-decode-alpha-3-upper"-      (\x -> Just x === Country.decode (Country.alphaThreeUpper x))-  , testProperty "encode-decode-alpha-2-lower"-      (\x -> Just x === Country.decode (Country.alphaTwoLower x))-  , testProperty "encode-decode-alpha-3-lower"-      (\x -> Just x === Country.decode (Country.alphaThreeLower x))-  , testProperty "encode-alpha-two-upper"-      (\x ->-        let t = Country.alphaTwoUpper x-            ptr = Country.alphaTwoUpperUtf8Ptr x-        in-        (c2w (Text.index t 0), c2w (Text.index t 1))-        ===-        (indexOffPtr ptr 0 :: Word8, indexOffPtr ptr 1 :: Word8)+main =+  defaultMain $+    testGroup "Country" $+      ( map lawsToTest $+          map ($ proxy) $+            [ QCC.boundedEnumLaws+            , QCC.eqLaws+            , QCC.ordLaws+            , QCC.primLaws+            , QCC.showLaws+            , QCC.storableLaws+            ]       )-  , testProperty "encode-decode-numeric"-      (\x -> Just x === Country.decodeNumeric (Country.encodeNumeric x))-  , testGroup "Continent"-    [ testProperty "encode-decode-alpha-upper" $ \x ->-      Just x === Continent.decodeAlpha (Continent.alphaUpper x)-    , testProperty "encode-decode-english" $ \x ->-      Just x === Continent.decodeEnglish (Continent.encodeEnglish x)-    , testProperty "country-continent-smoke-usa" $-      Continent.continent (fromJust $ Country.decodeAlphaTwo "US") === Continent.NorthAmerica-    , testProperty "country-continent-smoke-china" $-      Continent.continent (fromJust $ Country.decodeAlphaTwo "CN") === Continent.Asia-    ]-  , testGroup "Subdivision" $-    ( map lawsToTest-      $ map ($ Proxy @Subdivision)-      $ [ QCC.boundedEnumLaws-        , QCC.eqLaws-        , QCC.ordLaws-        , QCC.primLaws-        , QCC.showLaws-        , QCC.storableLaws-        ]-    ) ++-    [ testProperty "encode-decode-alpha" $ \x ->-        Just x === Subdivision.decodeAlpha (Subdivision.encodeAlpha x)-    , testProperty "encode-short" $ \x ->-        Just x === Subdivision.decodeAlpha (TS.toText (Subdivision.encodeAlphaShort x))-    , testProperty "decode-utf8-bytes" $ \x ->-        Just x === Subdivision.decodeEnglishUtf8Bytes (Bytes.fromByteString (Text.encodeUtf8 (Subdivision.encodeEnglish x)))-    ]-  ]+        ++ ( map lawsToTest $+              map ($ Proxy @Continent) $+                [ -- QCC.boundedEnumLaws+                  QCC.eqLaws+                , QCC.ordLaws+                -- , QCC.primLaws+                -- , QCC.showLaws+                -- , QCC.storableLaws+                ]+           )+        ++ [ testProperty+              "encode-decode-english"+              (\x -> Just x === Country.decode (Country.encodeEnglish x))+           , testProperty+              "encode-decode-alpha-2-upper"+              (\x -> Just x === Country.decode (Country.alphaTwoUpper x))+           , testProperty+              "encode-decode-alpha-3-upper"+              (\x -> Just x === Country.decode (Country.alphaThreeUpper x))+           , testProperty+              "encode-decode-alpha-2-lower"+              (\x -> Just x === Country.decode (Country.alphaTwoLower x))+           , testProperty+              "encode-decode-alpha-3-lower"+              (\x -> Just x === Country.decode (Country.alphaThreeLower x))+           , testProperty+              "encode-alpha-two-upper"+              ( \x ->+                  let t = Country.alphaTwoUpper x+                      ptr = Country.alphaTwoUpperUtf8Ptr x+                   in (c2w (Text.index t 0), c2w (Text.index t 1))+                        === (indexOffPtr ptr 0 :: Word8, indexOffPtr ptr 1 :: Word8)+              )+           , testProperty+              "encode-decode-numeric"+              (\x -> Just x === Country.decodeNumeric (Country.encodeNumeric x))+           , testGroup+              "Continent"+              [ testProperty "encode-decode-alpha-upper" $ \x ->+                  Just x === Continent.decodeAlpha (Continent.alphaUpper x)+              , testProperty "encode-decode-english" $ \x ->+                  Just x === Continent.decodeEnglish (Continent.encodeEnglish x)+              , testProperty "country-continent-smoke-usa" $+                  Continent.continent (fromJust $ Country.decodeAlphaTwo "US") === Continent.NorthAmerica+              , testProperty "country-continent-smoke-china" $+                  Continent.continent (fromJust $ Country.decodeAlphaTwo "CN") === Continent.Asia+              ]+           , testGroup "Subdivision" $+              ( map lawsToTest $+                  map ($ Proxy @Subdivision) $+                    [ QCC.boundedEnumLaws+                    , QCC.eqLaws+                    , QCC.ordLaws+                    , QCC.primLaws+                    , QCC.showLaws+                    , QCC.storableLaws+                    ]+              )+                ++ [ testProperty "encode-decode-alpha" $ \x ->+                      Just x === Subdivision.decodeAlpha (Subdivision.encodeAlpha x)+                   , testProperty "encode-short" $ \x ->+                      Just x === Subdivision.decodeAlpha (TS.toText (Subdivision.encodeAlphaShort x))+                   , testProperty "decode-utf8-bytes" $ \x ->+                      Just x === Subdivision.decodeEnglishUtf8Bytes (Bytes.fromByteString (Text.encodeUtf8 (Subdivision.encodeEnglish x)))+                   ]+           ]  c2w :: Char -> Word8 c2w = fromIntegral . ord