bcp47-0.3.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

Instances details
FromJSON Country 
Instance details

Defined in Country.Unexposed.Names

ToJSON Country 
Instance details

Defined in Country.Unexposed.Names

Data Country 
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 
Instance details

Defined in Country.Unexposed.Names

Bounded Country 
Instance details

Defined in Country.Unexposed.Names

Enum Country 
Instance details

Defined in Country.Unexposed.Names

Generic Country 
Instance details

Defined in Country.Unexposed.Names

Associated Types

type Rep Country 
Instance details

Defined in Country.Unexposed.Names

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

Methods

from :: Country -> Rep Country x #

to :: Rep Country x -> Country #

Show Country 
Instance details

Defined in Country.Unexposed.Names

NFData Country 
Instance details

Defined in Country.Unexposed.Names

Methods

rnf :: Country -> () #

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

Hashable Country 
Instance details

Defined in Country.Unexposed.Names

Methods

hashWithSalt :: Int -> Country -> Int #

hash :: Country -> Int #

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.2.5.0-1713GcafU1U9pn4EkeY1T1" '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 "ZW"
Right zimbabwe
>>> regionFromText $ pack "Zw"
Right zimbabwe
>>> regionFromText $ pack "zW"
Right zimbabwe
>>> regionFromText $ pack "012"
Right algeria
>>> regionFromText $ pack "asdf"
Left "regionFromText:1:3:\n  |\n1 | asdf\n  |   ^\nunexpected 'd'\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 @