bcp47-0.1.0.0: Language tags as specified by BCP 47

Safe HaskellNone
LanguageHaskell2010

Data.BCP47.Internal.Region

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 :: Type -> Type #

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-Ii4TkuGBe7OJhhbgT8y7Xv" True) (C1 (MetaCons "Country" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word16)))

regionFromText :: Text -> Either Text Country Source #

Parse a region subtag from Text

>>> regionFromText $ pack "ZW"
Right zimbabwe
>>> regionFromText $ pack "012"
Right algeria
>>> regionFromText $ pack "asdf"
Left "regionFromText:1:1:\n  |\n1 | asdf\n  | ^\nunexpected 'a'\nexpecting 2 or 3 character country code\n"

regionP :: Parsec Void Text Country Source #

BCP-47 region parser

@ region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code @