country-0.1.6: Country data type and functions

Safe HaskellNone
LanguageHaskell2010

Country

Contents

Synopsis

Documentation

data Country #

A country recognized by ISO 3166.

Instances
Bounded Country # 
Instance details

Defined in Country.Unexposed.Names

Enum Country # 
Instance details

Defined in Country.Unexposed.Names

Eq Country # 
Instance details

Defined in Country.Unexposed.Names

Methods

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

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

Ord Country # 
Instance details

Defined in Country.Unexposed.Names

Show Country # 
Instance details

Defined in Country.Unexposed.Names

Generic Country # 
Instance details

Defined in Country.Unexposed.Names

Associated Types

type Rep Country :: * -> * #

Methods

from :: Country -> Rep Country x #

to :: Rep Country x -> Country #

Hashable Country # 
Instance details

Defined in Country.Unexposed.Names

Methods

hashWithSalt :: Int -> Country -> Int #

hash :: Country -> Int #

ToJSON Country # 
Instance details

Defined in Country.Unexposed.Names

FromJSON Country # 
Instance details

Defined in Country.Unexposed.Names

Storable Country # 
Instance details

Defined in Country.Unexposed.Names

NFData Country # 
Instance details

Defined in Country.Unexposed.Names

Methods

rnf :: Country -> () #

Prim Country # 
Instance details

Defined in Country.Unexposed.Names

type Rep Country # 
Instance details

Defined in Country.Unexposed.Names

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

Three digit code

encodeNumeric :: Country -> Word16 #

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

decodeNumeric :: Word16 -> Maybe Country #

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 #

The name of a country given in English

decode :: Text -> Maybe Country #

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 their are names that are missing.

parser :: Parser Country #

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 #

The alpha-2 country code, uppercase

alphaThreeUpper :: Country -> Text #

The alpha-3 country code, uppercase

alphaThreeLower :: Country -> Text #

The alpha-3 country code, lowercase

alphaTwoLower :: Country -> Text #

The alpha-2 country code, lowercase