country-0.2.3.1: Country data type and functions
Safe HaskellSafe-Inferred
LanguageHaskell2010

Country

Description

Country type and helpers.

Synopsis

Documentation

data Country Source #

A country recognized by ISO 3166.

Instances

Instances details
FromJSON Country Source # 
Instance details

Defined in Country.Unexposed.Names

ToJSON Country Source # 
Instance details

Defined in Country.Unexposed.Names

Data Country Source # 
Instance details

Defined in Country.Unexposed.Names

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Country -> c Country #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Country #

toConstr :: Country -> Constr #

dataTypeOf :: Country -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Country) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Country) #

gmapT :: (forall b. Data b => b -> b) -> Country -> Country #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Country -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Country -> r #

gmapQ :: (forall d. Data d => d -> u) -> Country -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Country -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Country -> m Country #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Country -> m Country #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Country -> m Country #

Storable Country Source # 
Instance details

Defined in Country.Unexposed.Names

Bounded Country Source # 
Instance details

Defined in Country.Unexposed.Names

Enum Country Source # 
Instance details

Defined in Country.Unexposed.Names

Generic Country Source # 
Instance details

Defined in Country.Unexposed.Names

Associated Types

type Rep Country :: Type -> Type #

Methods

from :: Country -> Rep Country x #

to :: Rep Country x -> Country #

Show Country Source # 
Instance details

Defined in Country.Unexposed.Names

NFData Country Source # 
Instance details

Defined in Country.Unexposed.Names

Methods

rnf :: Country -> () #

Eq Country Source # 
Instance details

Defined in Country.Unexposed.Names

Methods

(==) :: Country -> Country -> Bool #

(/=) :: Country -> Country -> Bool #

Ord Country Source # 
Instance details

Defined in Country.Unexposed.Names

Hashable Country Source # 
Instance details

Defined in Country.Unexposed.Names

Methods

hashWithSalt :: Int -> Country -> Int #

hash :: Country -> Int #

Prim Country Source # 
Instance details

Defined in Country.Unexposed.Names

type Rep Country Source # 
Instance details

Defined in Country.Unexposed.Names

type Rep Country = D1 ('MetaData "Country" "Country.Unexposed.Names" "country-0.2.3.1-6nZ7UbiucZ9C0Po2c1kw39" 'True) (C1 ('MetaCons "Country" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16)))

Three digit code

encodeNumeric :: Country -> Word16 Source #

Convert a country to its numeric code. This is a three-digit number and will consequently be less than 1000.

decodeNumeric :: Word16 -> Maybe Country Source #

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.

Name

encodeEnglish :: Country -> Text Source #

The name of a country given in English

encodeEnglishShort :: Country -> ShortText Source #

The name of a country given in English

decode :: Text -> Maybe Country Source #

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.

decodeUtf8 :: ByteString -> Maybe Country Source #

Decode a Country from a UTF-8-encoded ByteString.

parser :: Parser Country Source #

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.

Alpha-2 and Alpha-3

alphaTwoUpper :: Country -> Text Source #

The alpha-2 country code, uppercase

alphaTwoUpperUtf8Ptr :: Country -> Ptr Word8 Source #

The alpha-2 country code, uppercase. The resulting address always has two bytes at it.

alphaThreeUpper :: Country -> Text Source #

The alpha-3 country code, uppercase

alphaThreeLower :: Country -> Text Source #

The alpha-3 country code, lowercase

alphaTwoLower :: Country -> Text Source #

The alpha-2 country code, lowercase

decodeAlphaTwo :: Text -> Maybe Country Source #

Decode a Country using its alpha-2 country code.

decodeAlphaThree :: Text -> Maybe Country Source #

Decode a Country using its alpha-3 country code.

Hash Maps for Decoding