{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Text.IDN.Types
(
IDNError(..)
, HyphenError(..)
, PunycodeError(..)
, Label(..)
, DomainName(..)
, mkLabel
, mkDomainName
, CodePointStatus(..)
, BidiClass(..)
, ContextRule(..)
, BidiRule(..)
, Script(..)
, PunycodeState(..)
, PunycodeParams(..)
, initialState
, punycodeParams
) where
import Data.Text (Text)
import qualified Data.Text as T
import Data.List.NonEmpty (NonEmpty)
import qualified Data.List.NonEmpty as NE
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
data IDNError
= EmptyLabel
| LabelTooLong
{ IDNError -> Int
actualLength :: Int
, IDNError -> Int
maxLength :: Int
}
| TotalDomainTooLong
{ actualLength :: Int
, maxLength :: Int
}
| InvalidHyphenPosition HyphenError
| StartsWithCombiningMark
{ IDNError -> Char
character :: Char
, IDNError -> Int
codepoint :: Int
}
| DisallowedCodePoint
{ character :: Char
, codepoint :: Int
}
| InvalidContext
{ character :: Char
, IDNError -> ContextRule
contextRule :: ContextRule
, IDNError -> Int
position :: Int
, IDNError -> Text
context :: Text
}
| BidiViolation
{ IDNError -> BidiRule
bidiRule :: BidiRule
, IDNError -> Text
label :: Text
}
| PunycodeDecodeError
{ IDNError -> Text
input :: Text
, IDNError -> Text
reason :: Text
}
deriving (Int -> IDNError -> ShowS
[IDNError] -> ShowS
IDNError -> String
(Int -> IDNError -> ShowS)
-> (IDNError -> String) -> ([IDNError] -> ShowS) -> Show IDNError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IDNError -> ShowS
showsPrec :: Int -> IDNError -> ShowS
$cshow :: IDNError -> String
show :: IDNError -> String
$cshowList :: [IDNError] -> ShowS
showList :: [IDNError] -> ShowS
Show, IDNError -> IDNError -> Bool
(IDNError -> IDNError -> Bool)
-> (IDNError -> IDNError -> Bool) -> Eq IDNError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IDNError -> IDNError -> Bool
== :: IDNError -> IDNError -> Bool
$c/= :: IDNError -> IDNError -> Bool
/= :: IDNError -> IDNError -> Bool
Eq, (forall x. IDNError -> Rep IDNError x)
-> (forall x. Rep IDNError x -> IDNError) -> Generic IDNError
forall x. Rep IDNError x -> IDNError
forall x. IDNError -> Rep IDNError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IDNError -> Rep IDNError x
from :: forall x. IDNError -> Rep IDNError x
$cto :: forall x. Rep IDNError x -> IDNError
to :: forall x. Rep IDNError x -> IDNError
Generic)
instance NFData IDNError
data HyphenError
= StartsWithHyphen
| EndsWithHyphen
| HyphensAt3And4NotPunycode
deriving (Int -> HyphenError -> ShowS
[HyphenError] -> ShowS
HyphenError -> String
(Int -> HyphenError -> ShowS)
-> (HyphenError -> String)
-> ([HyphenError] -> ShowS)
-> Show HyphenError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HyphenError -> ShowS
showsPrec :: Int -> HyphenError -> ShowS
$cshow :: HyphenError -> String
show :: HyphenError -> String
$cshowList :: [HyphenError] -> ShowS
showList :: [HyphenError] -> ShowS
Show, HyphenError -> HyphenError -> Bool
(HyphenError -> HyphenError -> Bool)
-> (HyphenError -> HyphenError -> Bool) -> Eq HyphenError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HyphenError -> HyphenError -> Bool
== :: HyphenError -> HyphenError -> Bool
$c/= :: HyphenError -> HyphenError -> Bool
/= :: HyphenError -> HyphenError -> Bool
Eq, (forall x. HyphenError -> Rep HyphenError x)
-> (forall x. Rep HyphenError x -> HyphenError)
-> Generic HyphenError
forall x. Rep HyphenError x -> HyphenError
forall x. HyphenError -> Rep HyphenError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HyphenError -> Rep HyphenError x
from :: forall x. HyphenError -> Rep HyphenError x
$cto :: forall x. Rep HyphenError x -> HyphenError
to :: forall x. Rep HyphenError x -> HyphenError
Generic)
instance NFData HyphenError
data PunycodeError
= InvalidPunycode Text
| Overflow
deriving (Int -> PunycodeError -> ShowS
[PunycodeError] -> ShowS
PunycodeError -> String
(Int -> PunycodeError -> ShowS)
-> (PunycodeError -> String)
-> ([PunycodeError] -> ShowS)
-> Show PunycodeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PunycodeError -> ShowS
showsPrec :: Int -> PunycodeError -> ShowS
$cshow :: PunycodeError -> String
show :: PunycodeError -> String
$cshowList :: [PunycodeError] -> ShowS
showList :: [PunycodeError] -> ShowS
Show, PunycodeError -> PunycodeError -> Bool
(PunycodeError -> PunycodeError -> Bool)
-> (PunycodeError -> PunycodeError -> Bool) -> Eq PunycodeError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PunycodeError -> PunycodeError -> Bool
== :: PunycodeError -> PunycodeError -> Bool
$c/= :: PunycodeError -> PunycodeError -> Bool
/= :: PunycodeError -> PunycodeError -> Bool
Eq, (forall x. PunycodeError -> Rep PunycodeError x)
-> (forall x. Rep PunycodeError x -> PunycodeError)
-> Generic PunycodeError
forall x. Rep PunycodeError x -> PunycodeError
forall x. PunycodeError -> Rep PunycodeError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PunycodeError -> Rep PunycodeError x
from :: forall x. PunycodeError -> Rep PunycodeError x
$cto :: forall x. Rep PunycodeError x -> PunycodeError
to :: forall x. Rep PunycodeError x -> PunycodeError
Generic)
instance NFData PunycodeError
data Label
= ULabel Text
| ALabel Text
deriving (Int -> Label -> ShowS
[Label] -> ShowS
Label -> String
(Int -> Label -> ShowS)
-> (Label -> String) -> ([Label] -> ShowS) -> Show Label
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Label -> ShowS
showsPrec :: Int -> Label -> ShowS
$cshow :: Label -> String
show :: Label -> String
$cshowList :: [Label] -> ShowS
showList :: [Label] -> ShowS
Show, Label -> Label -> Bool
(Label -> Label -> Bool) -> (Label -> Label -> Bool) -> Eq Label
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Label -> Label -> Bool
== :: Label -> Label -> Bool
$c/= :: Label -> Label -> Bool
/= :: Label -> Label -> Bool
Eq, (forall x. Label -> Rep Label x)
-> (forall x. Rep Label x -> Label) -> Generic Label
forall x. Rep Label x -> Label
forall x. Label -> Rep Label x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Label -> Rep Label x
from :: forall x. Label -> Rep Label x
$cto :: forall x. Rep Label x -> Label
to :: forall x. Rep Label x -> Label
Generic)
instance NFData Label
newtype DomainName = DomainName
{ DomainName -> NonEmpty Label
labels :: NonEmpty Label
}
deriving (Int -> DomainName -> ShowS
[DomainName] -> ShowS
DomainName -> String
(Int -> DomainName -> ShowS)
-> (DomainName -> String)
-> ([DomainName] -> ShowS)
-> Show DomainName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DomainName -> ShowS
showsPrec :: Int -> DomainName -> ShowS
$cshow :: DomainName -> String
show :: DomainName -> String
$cshowList :: [DomainName] -> ShowS
showList :: [DomainName] -> ShowS
Show, DomainName -> DomainName -> Bool
(DomainName -> DomainName -> Bool)
-> (DomainName -> DomainName -> Bool) -> Eq DomainName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DomainName -> DomainName -> Bool
== :: DomainName -> DomainName -> Bool
$c/= :: DomainName -> DomainName -> Bool
/= :: DomainName -> DomainName -> Bool
Eq, (forall x. DomainName -> Rep DomainName x)
-> (forall x. Rep DomainName x -> DomainName) -> Generic DomainName
forall x. Rep DomainName x -> DomainName
forall x. DomainName -> Rep DomainName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DomainName -> Rep DomainName x
from :: forall x. DomainName -> Rep DomainName x
$cto :: forall x. Rep DomainName x -> DomainName
to :: forall x. Rep DomainName x -> DomainName
Generic)
instance NFData DomainName
mkLabel :: Text -> Either IDNError Label
mkLabel :: Text -> Either IDNError Label
mkLabel Text
text
| Text -> Bool
T.null Text
text = IDNError -> Either IDNError Label
forall a b. a -> Either a b
Left IDNError
EmptyLabel
| Text -> Int
T.length Text
text Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
63 = IDNError -> Either IDNError Label
forall a b. a -> Either a b
Left (Int -> Int -> IDNError
LabelTooLong (Text -> Int
T.length Text
text) Int
63)
| Bool
otherwise =
let normalized :: Text
normalized = Text -> Text
T.toLower Text
text
in if Text
"xn--" Text -> Text -> Bool
`T.isPrefixOf` Text
normalized
then Label -> Either IDNError Label
forall a b. b -> Either a b
Right (Text -> Label
ALabel Text
normalized)
else Label -> Either IDNError Label
forall a b. b -> Either a b
Right (Text -> Label
ULabel Text
normalized)
mkDomainName :: Text -> Either IDNError DomainName
mkDomainName :: Text -> Either IDNError DomainName
mkDomainName Text
text = do
if Text -> Bool
T.null Text
text
then IDNError -> Either IDNError DomainName
forall a b. a -> Either a b
Left IDNError
EmptyLabel
else if Text -> Int
T.length Text
text Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
253
then IDNError -> Either IDNError DomainName
forall a b. a -> Either a b
Left (Int -> Int -> IDNError
TotalDomainTooLong (Text -> Int
T.length Text
text) Int
253)
else do
let normalized :: Text
normalized = (Char -> Char) -> Text -> Text
T.map Char -> Char
normalizeDot Text
text
labelTexts :: [Text]
labelTexts = HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
"." Text
normalized
[Label]
labelList <- (Text -> Either IDNError Label)
-> [Text] -> Either IDNError [Label]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse Text -> Either IDNError Label
mkLabel [Text]
labelTexts
case [Label] -> Maybe (NonEmpty Label)
forall a. [a] -> Maybe (NonEmpty a)
NE.nonEmpty [Label]
labelList of
Maybe (NonEmpty Label)
Nothing -> IDNError -> Either IDNError DomainName
forall a b. a -> Either a b
Left IDNError
EmptyLabel
Just NonEmpty Label
ne -> DomainName -> Either IDNError DomainName
forall a b. b -> Either a b
Right (NonEmpty Label -> DomainName
DomainName NonEmpty Label
ne)
where
normalizeDot :: Char -> Char
normalizeDot Char
'\x3002' = Char
'.'
normalizeDot Char
'\xFF0E' = Char
'.'
normalizeDot Char
'\xFF61' = Char
'.'
normalizeDot Char
c = Char
c
data CodePointStatus
= PVALID
| DISALLOWED
| CONTEXTJ
| CONTEXTO
| UNASSIGNED
deriving (Int -> CodePointStatus -> ShowS
[CodePointStatus] -> ShowS
CodePointStatus -> String
(Int -> CodePointStatus -> ShowS)
-> (CodePointStatus -> String)
-> ([CodePointStatus] -> ShowS)
-> Show CodePointStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CodePointStatus -> ShowS
showsPrec :: Int -> CodePointStatus -> ShowS
$cshow :: CodePointStatus -> String
show :: CodePointStatus -> String
$cshowList :: [CodePointStatus] -> ShowS
showList :: [CodePointStatus] -> ShowS
Show, CodePointStatus -> CodePointStatus -> Bool
(CodePointStatus -> CodePointStatus -> Bool)
-> (CodePointStatus -> CodePointStatus -> Bool)
-> Eq CodePointStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CodePointStatus -> CodePointStatus -> Bool
== :: CodePointStatus -> CodePointStatus -> Bool
$c/= :: CodePointStatus -> CodePointStatus -> Bool
/= :: CodePointStatus -> CodePointStatus -> Bool
Eq, Eq CodePointStatus
Eq CodePointStatus =>
(CodePointStatus -> CodePointStatus -> Ordering)
-> (CodePointStatus -> CodePointStatus -> Bool)
-> (CodePointStatus -> CodePointStatus -> Bool)
-> (CodePointStatus -> CodePointStatus -> Bool)
-> (CodePointStatus -> CodePointStatus -> Bool)
-> (CodePointStatus -> CodePointStatus -> CodePointStatus)
-> (CodePointStatus -> CodePointStatus -> CodePointStatus)
-> Ord CodePointStatus
CodePointStatus -> CodePointStatus -> Bool
CodePointStatus -> CodePointStatus -> Ordering
CodePointStatus -> CodePointStatus -> CodePointStatus
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: CodePointStatus -> CodePointStatus -> Ordering
compare :: CodePointStatus -> CodePointStatus -> Ordering
$c< :: CodePointStatus -> CodePointStatus -> Bool
< :: CodePointStatus -> CodePointStatus -> Bool
$c<= :: CodePointStatus -> CodePointStatus -> Bool
<= :: CodePointStatus -> CodePointStatus -> Bool
$c> :: CodePointStatus -> CodePointStatus -> Bool
> :: CodePointStatus -> CodePointStatus -> Bool
$c>= :: CodePointStatus -> CodePointStatus -> Bool
>= :: CodePointStatus -> CodePointStatus -> Bool
$cmax :: CodePointStatus -> CodePointStatus -> CodePointStatus
max :: CodePointStatus -> CodePointStatus -> CodePointStatus
$cmin :: CodePointStatus -> CodePointStatus -> CodePointStatus
min :: CodePointStatus -> CodePointStatus -> CodePointStatus
Ord, Int -> CodePointStatus
CodePointStatus -> Int
CodePointStatus -> [CodePointStatus]
CodePointStatus -> CodePointStatus
CodePointStatus -> CodePointStatus -> [CodePointStatus]
CodePointStatus
-> CodePointStatus -> CodePointStatus -> [CodePointStatus]
(CodePointStatus -> CodePointStatus)
-> (CodePointStatus -> CodePointStatus)
-> (Int -> CodePointStatus)
-> (CodePointStatus -> Int)
-> (CodePointStatus -> [CodePointStatus])
-> (CodePointStatus -> CodePointStatus -> [CodePointStatus])
-> (CodePointStatus -> CodePointStatus -> [CodePointStatus])
-> (CodePointStatus
-> CodePointStatus -> CodePointStatus -> [CodePointStatus])
-> Enum CodePointStatus
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: CodePointStatus -> CodePointStatus
succ :: CodePointStatus -> CodePointStatus
$cpred :: CodePointStatus -> CodePointStatus
pred :: CodePointStatus -> CodePointStatus
$ctoEnum :: Int -> CodePointStatus
toEnum :: Int -> CodePointStatus
$cfromEnum :: CodePointStatus -> Int
fromEnum :: CodePointStatus -> Int
$cenumFrom :: CodePointStatus -> [CodePointStatus]
enumFrom :: CodePointStatus -> [CodePointStatus]
$cenumFromThen :: CodePointStatus -> CodePointStatus -> [CodePointStatus]
enumFromThen :: CodePointStatus -> CodePointStatus -> [CodePointStatus]
$cenumFromTo :: CodePointStatus -> CodePointStatus -> [CodePointStatus]
enumFromTo :: CodePointStatus -> CodePointStatus -> [CodePointStatus]
$cenumFromThenTo :: CodePointStatus
-> CodePointStatus -> CodePointStatus -> [CodePointStatus]
enumFromThenTo :: CodePointStatus
-> CodePointStatus -> CodePointStatus -> [CodePointStatus]
Enum, CodePointStatus
CodePointStatus -> CodePointStatus -> Bounded CodePointStatus
forall a. a -> a -> Bounded a
$cminBound :: CodePointStatus
minBound :: CodePointStatus
$cmaxBound :: CodePointStatus
maxBound :: CodePointStatus
Bounded, (forall x. CodePointStatus -> Rep CodePointStatus x)
-> (forall x. Rep CodePointStatus x -> CodePointStatus)
-> Generic CodePointStatus
forall x. Rep CodePointStatus x -> CodePointStatus
forall x. CodePointStatus -> Rep CodePointStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CodePointStatus -> Rep CodePointStatus x
from :: forall x. CodePointStatus -> Rep CodePointStatus x
$cto :: forall x. Rep CodePointStatus x -> CodePointStatus
to :: forall x. Rep CodePointStatus x -> CodePointStatus
Generic)
instance NFData CodePointStatus
data BidiClass
= L
| R
| AL
| AN
| EN
| ES
| ET
| CS
| NSM
| BN
| B
| S
| WS
| ON
| LRE
| LRO
| RLE
| RLO
| PDF
| LRI
| RLI
| FSI
| PDI
deriving (Int -> BidiClass -> ShowS
[BidiClass] -> ShowS
BidiClass -> String
(Int -> BidiClass -> ShowS)
-> (BidiClass -> String)
-> ([BidiClass] -> ShowS)
-> Show BidiClass
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BidiClass -> ShowS
showsPrec :: Int -> BidiClass -> ShowS
$cshow :: BidiClass -> String
show :: BidiClass -> String
$cshowList :: [BidiClass] -> ShowS
showList :: [BidiClass] -> ShowS
Show, BidiClass -> BidiClass -> Bool
(BidiClass -> BidiClass -> Bool)
-> (BidiClass -> BidiClass -> Bool) -> Eq BidiClass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BidiClass -> BidiClass -> Bool
== :: BidiClass -> BidiClass -> Bool
$c/= :: BidiClass -> BidiClass -> Bool
/= :: BidiClass -> BidiClass -> Bool
Eq, Eq BidiClass
Eq BidiClass =>
(BidiClass -> BidiClass -> Ordering)
-> (BidiClass -> BidiClass -> Bool)
-> (BidiClass -> BidiClass -> Bool)
-> (BidiClass -> BidiClass -> Bool)
-> (BidiClass -> BidiClass -> Bool)
-> (BidiClass -> BidiClass -> BidiClass)
-> (BidiClass -> BidiClass -> BidiClass)
-> Ord BidiClass
BidiClass -> BidiClass -> Bool
BidiClass -> BidiClass -> Ordering
BidiClass -> BidiClass -> BidiClass
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BidiClass -> BidiClass -> Ordering
compare :: BidiClass -> BidiClass -> Ordering
$c< :: BidiClass -> BidiClass -> Bool
< :: BidiClass -> BidiClass -> Bool
$c<= :: BidiClass -> BidiClass -> Bool
<= :: BidiClass -> BidiClass -> Bool
$c> :: BidiClass -> BidiClass -> Bool
> :: BidiClass -> BidiClass -> Bool
$c>= :: BidiClass -> BidiClass -> Bool
>= :: BidiClass -> BidiClass -> Bool
$cmax :: BidiClass -> BidiClass -> BidiClass
max :: BidiClass -> BidiClass -> BidiClass
$cmin :: BidiClass -> BidiClass -> BidiClass
min :: BidiClass -> BidiClass -> BidiClass
Ord, Int -> BidiClass
BidiClass -> Int
BidiClass -> [BidiClass]
BidiClass -> BidiClass
BidiClass -> BidiClass -> [BidiClass]
BidiClass -> BidiClass -> BidiClass -> [BidiClass]
(BidiClass -> BidiClass)
-> (BidiClass -> BidiClass)
-> (Int -> BidiClass)
-> (BidiClass -> Int)
-> (BidiClass -> [BidiClass])
-> (BidiClass -> BidiClass -> [BidiClass])
-> (BidiClass -> BidiClass -> [BidiClass])
-> (BidiClass -> BidiClass -> BidiClass -> [BidiClass])
-> Enum BidiClass
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: BidiClass -> BidiClass
succ :: BidiClass -> BidiClass
$cpred :: BidiClass -> BidiClass
pred :: BidiClass -> BidiClass
$ctoEnum :: Int -> BidiClass
toEnum :: Int -> BidiClass
$cfromEnum :: BidiClass -> Int
fromEnum :: BidiClass -> Int
$cenumFrom :: BidiClass -> [BidiClass]
enumFrom :: BidiClass -> [BidiClass]
$cenumFromThen :: BidiClass -> BidiClass -> [BidiClass]
enumFromThen :: BidiClass -> BidiClass -> [BidiClass]
$cenumFromTo :: BidiClass -> BidiClass -> [BidiClass]
enumFromTo :: BidiClass -> BidiClass -> [BidiClass]
$cenumFromThenTo :: BidiClass -> BidiClass -> BidiClass -> [BidiClass]
enumFromThenTo :: BidiClass -> BidiClass -> BidiClass -> [BidiClass]
Enum, BidiClass
BidiClass -> BidiClass -> Bounded BidiClass
forall a. a -> a -> Bounded a
$cminBound :: BidiClass
minBound :: BidiClass
$cmaxBound :: BidiClass
maxBound :: BidiClass
Bounded, (forall x. BidiClass -> Rep BidiClass x)
-> (forall x. Rep BidiClass x -> BidiClass) -> Generic BidiClass
forall x. Rep BidiClass x -> BidiClass
forall x. BidiClass -> Rep BidiClass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BidiClass -> Rep BidiClass x
from :: forall x. BidiClass -> Rep BidiClass x
$cto :: forall x. Rep BidiClass x -> BidiClass
to :: forall x. Rep BidiClass x -> BidiClass
Generic)
instance NFData BidiClass
data ContextRule
= ZWNJRule
| ZWJRule
| MiddleDotRule
| GreekKeraiaRule
| HebrewGereshRule
| HebrewGershayimRule
| KatakanaMiddleDotRule
| ArabicIndicDigitsRule
| ExtendedArabicIndicDigitsRule
deriving (Int -> ContextRule -> ShowS
[ContextRule] -> ShowS
ContextRule -> String
(Int -> ContextRule -> ShowS)
-> (ContextRule -> String)
-> ([ContextRule] -> ShowS)
-> Show ContextRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContextRule -> ShowS
showsPrec :: Int -> ContextRule -> ShowS
$cshow :: ContextRule -> String
show :: ContextRule -> String
$cshowList :: [ContextRule] -> ShowS
showList :: [ContextRule] -> ShowS
Show, ContextRule -> ContextRule -> Bool
(ContextRule -> ContextRule -> Bool)
-> (ContextRule -> ContextRule -> Bool) -> Eq ContextRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContextRule -> ContextRule -> Bool
== :: ContextRule -> ContextRule -> Bool
$c/= :: ContextRule -> ContextRule -> Bool
/= :: ContextRule -> ContextRule -> Bool
Eq, Eq ContextRule
Eq ContextRule =>
(ContextRule -> ContextRule -> Ordering)
-> (ContextRule -> ContextRule -> Bool)
-> (ContextRule -> ContextRule -> Bool)
-> (ContextRule -> ContextRule -> Bool)
-> (ContextRule -> ContextRule -> Bool)
-> (ContextRule -> ContextRule -> ContextRule)
-> (ContextRule -> ContextRule -> ContextRule)
-> Ord ContextRule
ContextRule -> ContextRule -> Bool
ContextRule -> ContextRule -> Ordering
ContextRule -> ContextRule -> ContextRule
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ContextRule -> ContextRule -> Ordering
compare :: ContextRule -> ContextRule -> Ordering
$c< :: ContextRule -> ContextRule -> Bool
< :: ContextRule -> ContextRule -> Bool
$c<= :: ContextRule -> ContextRule -> Bool
<= :: ContextRule -> ContextRule -> Bool
$c> :: ContextRule -> ContextRule -> Bool
> :: ContextRule -> ContextRule -> Bool
$c>= :: ContextRule -> ContextRule -> Bool
>= :: ContextRule -> ContextRule -> Bool
$cmax :: ContextRule -> ContextRule -> ContextRule
max :: ContextRule -> ContextRule -> ContextRule
$cmin :: ContextRule -> ContextRule -> ContextRule
min :: ContextRule -> ContextRule -> ContextRule
Ord, Int -> ContextRule
ContextRule -> Int
ContextRule -> [ContextRule]
ContextRule -> ContextRule
ContextRule -> ContextRule -> [ContextRule]
ContextRule -> ContextRule -> ContextRule -> [ContextRule]
(ContextRule -> ContextRule)
-> (ContextRule -> ContextRule)
-> (Int -> ContextRule)
-> (ContextRule -> Int)
-> (ContextRule -> [ContextRule])
-> (ContextRule -> ContextRule -> [ContextRule])
-> (ContextRule -> ContextRule -> [ContextRule])
-> (ContextRule -> ContextRule -> ContextRule -> [ContextRule])
-> Enum ContextRule
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ContextRule -> ContextRule
succ :: ContextRule -> ContextRule
$cpred :: ContextRule -> ContextRule
pred :: ContextRule -> ContextRule
$ctoEnum :: Int -> ContextRule
toEnum :: Int -> ContextRule
$cfromEnum :: ContextRule -> Int
fromEnum :: ContextRule -> Int
$cenumFrom :: ContextRule -> [ContextRule]
enumFrom :: ContextRule -> [ContextRule]
$cenumFromThen :: ContextRule -> ContextRule -> [ContextRule]
enumFromThen :: ContextRule -> ContextRule -> [ContextRule]
$cenumFromTo :: ContextRule -> ContextRule -> [ContextRule]
enumFromTo :: ContextRule -> ContextRule -> [ContextRule]
$cenumFromThenTo :: ContextRule -> ContextRule -> ContextRule -> [ContextRule]
enumFromThenTo :: ContextRule -> ContextRule -> ContextRule -> [ContextRule]
Enum, ContextRule
ContextRule -> ContextRule -> Bounded ContextRule
forall a. a -> a -> Bounded a
$cminBound :: ContextRule
minBound :: ContextRule
$cmaxBound :: ContextRule
maxBound :: ContextRule
Bounded, (forall x. ContextRule -> Rep ContextRule x)
-> (forall x. Rep ContextRule x -> ContextRule)
-> Generic ContextRule
forall x. Rep ContextRule x -> ContextRule
forall x. ContextRule -> Rep ContextRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContextRule -> Rep ContextRule x
from :: forall x. ContextRule -> Rep ContextRule x
$cto :: forall x. Rep ContextRule x -> ContextRule
to :: forall x. Rep ContextRule x -> ContextRule
Generic)
instance NFData ContextRule
data BidiRule
= Rule1
| Rule2
| Rule3
| Rule4
| Rule5
| Rule6
deriving (Int -> BidiRule -> ShowS
[BidiRule] -> ShowS
BidiRule -> String
(Int -> BidiRule -> ShowS)
-> (BidiRule -> String) -> ([BidiRule] -> ShowS) -> Show BidiRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BidiRule -> ShowS
showsPrec :: Int -> BidiRule -> ShowS
$cshow :: BidiRule -> String
show :: BidiRule -> String
$cshowList :: [BidiRule] -> ShowS
showList :: [BidiRule] -> ShowS
Show, BidiRule -> BidiRule -> Bool
(BidiRule -> BidiRule -> Bool)
-> (BidiRule -> BidiRule -> Bool) -> Eq BidiRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BidiRule -> BidiRule -> Bool
== :: BidiRule -> BidiRule -> Bool
$c/= :: BidiRule -> BidiRule -> Bool
/= :: BidiRule -> BidiRule -> Bool
Eq, Eq BidiRule
Eq BidiRule =>
(BidiRule -> BidiRule -> Ordering)
-> (BidiRule -> BidiRule -> Bool)
-> (BidiRule -> BidiRule -> Bool)
-> (BidiRule -> BidiRule -> Bool)
-> (BidiRule -> BidiRule -> Bool)
-> (BidiRule -> BidiRule -> BidiRule)
-> (BidiRule -> BidiRule -> BidiRule)
-> Ord BidiRule
BidiRule -> BidiRule -> Bool
BidiRule -> BidiRule -> Ordering
BidiRule -> BidiRule -> BidiRule
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BidiRule -> BidiRule -> Ordering
compare :: BidiRule -> BidiRule -> Ordering
$c< :: BidiRule -> BidiRule -> Bool
< :: BidiRule -> BidiRule -> Bool
$c<= :: BidiRule -> BidiRule -> Bool
<= :: BidiRule -> BidiRule -> Bool
$c> :: BidiRule -> BidiRule -> Bool
> :: BidiRule -> BidiRule -> Bool
$c>= :: BidiRule -> BidiRule -> Bool
>= :: BidiRule -> BidiRule -> Bool
$cmax :: BidiRule -> BidiRule -> BidiRule
max :: BidiRule -> BidiRule -> BidiRule
$cmin :: BidiRule -> BidiRule -> BidiRule
min :: BidiRule -> BidiRule -> BidiRule
Ord, Int -> BidiRule
BidiRule -> Int
BidiRule -> [BidiRule]
BidiRule -> BidiRule
BidiRule -> BidiRule -> [BidiRule]
BidiRule -> BidiRule -> BidiRule -> [BidiRule]
(BidiRule -> BidiRule)
-> (BidiRule -> BidiRule)
-> (Int -> BidiRule)
-> (BidiRule -> Int)
-> (BidiRule -> [BidiRule])
-> (BidiRule -> BidiRule -> [BidiRule])
-> (BidiRule -> BidiRule -> [BidiRule])
-> (BidiRule -> BidiRule -> BidiRule -> [BidiRule])
-> Enum BidiRule
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: BidiRule -> BidiRule
succ :: BidiRule -> BidiRule
$cpred :: BidiRule -> BidiRule
pred :: BidiRule -> BidiRule
$ctoEnum :: Int -> BidiRule
toEnum :: Int -> BidiRule
$cfromEnum :: BidiRule -> Int
fromEnum :: BidiRule -> Int
$cenumFrom :: BidiRule -> [BidiRule]
enumFrom :: BidiRule -> [BidiRule]
$cenumFromThen :: BidiRule -> BidiRule -> [BidiRule]
enumFromThen :: BidiRule -> BidiRule -> [BidiRule]
$cenumFromTo :: BidiRule -> BidiRule -> [BidiRule]
enumFromTo :: BidiRule -> BidiRule -> [BidiRule]
$cenumFromThenTo :: BidiRule -> BidiRule -> BidiRule -> [BidiRule]
enumFromThenTo :: BidiRule -> BidiRule -> BidiRule -> [BidiRule]
Enum, BidiRule
BidiRule -> BidiRule -> Bounded BidiRule
forall a. a -> a -> Bounded a
$cminBound :: BidiRule
minBound :: BidiRule
$cmaxBound :: BidiRule
maxBound :: BidiRule
Bounded, (forall x. BidiRule -> Rep BidiRule x)
-> (forall x. Rep BidiRule x -> BidiRule) -> Generic BidiRule
forall x. Rep BidiRule x -> BidiRule
forall x. BidiRule -> Rep BidiRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BidiRule -> Rep BidiRule x
from :: forall x. BidiRule -> Rep BidiRule x
$cto :: forall x. Rep BidiRule x -> BidiRule
to :: forall x. Rep BidiRule x -> BidiRule
Generic)
instance NFData BidiRule
data Script
= Latin
| Greek
| Cyrillic
| Hebrew
| Arabic
| Devanagari
| Bengali
| Gurmukhi
| Gujarati
| Oriya
| Tamil
| Telugu
| Kannada
| Malayalam
| Thai
| Lao
| Tibetan
| Myanmar
| Georgian
| Hangul
| Hiragana
| Katakana
| Han
| OtherScript
deriving (Int -> Script -> ShowS
[Script] -> ShowS
Script -> String
(Int -> Script -> ShowS)
-> (Script -> String) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Script -> ShowS
showsPrec :: Int -> Script -> ShowS
$cshow :: Script -> String
show :: Script -> String
$cshowList :: [Script] -> ShowS
showList :: [Script] -> ShowS
Show, Script -> Script -> Bool
(Script -> Script -> Bool)
-> (Script -> Script -> Bool) -> Eq Script
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Script -> Script -> Bool
== :: Script -> Script -> Bool
$c/= :: Script -> Script -> Bool
/= :: Script -> Script -> Bool
Eq, Eq Script
Eq Script =>
(Script -> Script -> Ordering)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Script)
-> (Script -> Script -> Script)
-> Ord Script
Script -> Script -> Bool
Script -> Script -> Ordering
Script -> Script -> Script
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Script -> Script -> Ordering
compare :: Script -> Script -> Ordering
$c< :: Script -> Script -> Bool
< :: Script -> Script -> Bool
$c<= :: Script -> Script -> Bool
<= :: Script -> Script -> Bool
$c> :: Script -> Script -> Bool
> :: Script -> Script -> Bool
$c>= :: Script -> Script -> Bool
>= :: Script -> Script -> Bool
$cmax :: Script -> Script -> Script
max :: Script -> Script -> Script
$cmin :: Script -> Script -> Script
min :: Script -> Script -> Script
Ord, Int -> Script
Script -> Int
Script -> [Script]
Script -> Script
Script -> Script -> [Script]
Script -> Script -> Script -> [Script]
(Script -> Script)
-> (Script -> Script)
-> (Int -> Script)
-> (Script -> Int)
-> (Script -> [Script])
-> (Script -> Script -> [Script])
-> (Script -> Script -> [Script])
-> (Script -> Script -> Script -> [Script])
-> Enum Script
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Script -> Script
succ :: Script -> Script
$cpred :: Script -> Script
pred :: Script -> Script
$ctoEnum :: Int -> Script
toEnum :: Int -> Script
$cfromEnum :: Script -> Int
fromEnum :: Script -> Int
$cenumFrom :: Script -> [Script]
enumFrom :: Script -> [Script]
$cenumFromThen :: Script -> Script -> [Script]
enumFromThen :: Script -> Script -> [Script]
$cenumFromTo :: Script -> Script -> [Script]
enumFromTo :: Script -> Script -> [Script]
$cenumFromThenTo :: Script -> Script -> Script -> [Script]
enumFromThenTo :: Script -> Script -> Script -> [Script]
Enum, Script
Script -> Script -> Bounded Script
forall a. a -> a -> Bounded a
$cminBound :: Script
minBound :: Script
$cmaxBound :: Script
maxBound :: Script
Bounded, (forall x. Script -> Rep Script x)
-> (forall x. Rep Script x -> Script) -> Generic Script
forall x. Rep Script x -> Script
forall x. Script -> Rep Script x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Script -> Rep Script x
from :: forall x. Script -> Rep Script x
$cto :: forall x. Rep Script x -> Script
to :: forall x. Rep Script x -> Script
Generic)
instance NFData Script
data PunycodeState = PunycodeState
{ PunycodeState -> Int
n :: {-# UNPACK #-}!Int
, PunycodeState -> Int
delta :: {-# UNPACK #-}!Int
, PunycodeState -> Int
bias :: {-# UNPACK #-}!Int
, PunycodeState -> Int
h :: {-# UNPACK #-}!Int
}
deriving (Int -> PunycodeState -> ShowS
[PunycodeState] -> ShowS
PunycodeState -> String
(Int -> PunycodeState -> ShowS)
-> (PunycodeState -> String)
-> ([PunycodeState] -> ShowS)
-> Show PunycodeState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PunycodeState -> ShowS
showsPrec :: Int -> PunycodeState -> ShowS
$cshow :: PunycodeState -> String
show :: PunycodeState -> String
$cshowList :: [PunycodeState] -> ShowS
showList :: [PunycodeState] -> ShowS
Show, PunycodeState -> PunycodeState -> Bool
(PunycodeState -> PunycodeState -> Bool)
-> (PunycodeState -> PunycodeState -> Bool) -> Eq PunycodeState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PunycodeState -> PunycodeState -> Bool
== :: PunycodeState -> PunycodeState -> Bool
$c/= :: PunycodeState -> PunycodeState -> Bool
/= :: PunycodeState -> PunycodeState -> Bool
Eq, (forall x. PunycodeState -> Rep PunycodeState x)
-> (forall x. Rep PunycodeState x -> PunycodeState)
-> Generic PunycodeState
forall x. Rep PunycodeState x -> PunycodeState
forall x. PunycodeState -> Rep PunycodeState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PunycodeState -> Rep PunycodeState x
from :: forall x. PunycodeState -> Rep PunycodeState x
$cto :: forall x. Rep PunycodeState x -> PunycodeState
to :: forall x. Rep PunycodeState x -> PunycodeState
Generic)
instance NFData PunycodeState
initialState :: PunycodeState
initialState :: PunycodeState
initialState = PunycodeState
{ n :: Int
n = Int
0x80
, delta :: Int
delta = Int
0
, bias :: Int
bias = Int
72
, h :: Int
h = Int
0
}
data PunycodeParams = PunycodeParams
{ PunycodeParams -> Int
base :: Int
, PunycodeParams -> Int
tmin :: Int
, PunycodeParams -> Int
tmax :: Int
, PunycodeParams -> Int
skew :: Int
, PunycodeParams -> Int
damp :: Int
}
deriving (Int -> PunycodeParams -> ShowS
[PunycodeParams] -> ShowS
PunycodeParams -> String
(Int -> PunycodeParams -> ShowS)
-> (PunycodeParams -> String)
-> ([PunycodeParams] -> ShowS)
-> Show PunycodeParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PunycodeParams -> ShowS
showsPrec :: Int -> PunycodeParams -> ShowS
$cshow :: PunycodeParams -> String
show :: PunycodeParams -> String
$cshowList :: [PunycodeParams] -> ShowS
showList :: [PunycodeParams] -> ShowS
Show, PunycodeParams -> PunycodeParams -> Bool
(PunycodeParams -> PunycodeParams -> Bool)
-> (PunycodeParams -> PunycodeParams -> Bool) -> Eq PunycodeParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PunycodeParams -> PunycodeParams -> Bool
== :: PunycodeParams -> PunycodeParams -> Bool
$c/= :: PunycodeParams -> PunycodeParams -> Bool
/= :: PunycodeParams -> PunycodeParams -> Bool
Eq, (forall x. PunycodeParams -> Rep PunycodeParams x)
-> (forall x. Rep PunycodeParams x -> PunycodeParams)
-> Generic PunycodeParams
forall x. Rep PunycodeParams x -> PunycodeParams
forall x. PunycodeParams -> Rep PunycodeParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PunycodeParams -> Rep PunycodeParams x
from :: forall x. PunycodeParams -> Rep PunycodeParams x
$cto :: forall x. Rep PunycodeParams x -> PunycodeParams
to :: forall x. Rep PunycodeParams x -> PunycodeParams
Generic)
instance NFData PunycodeParams
punycodeParams :: PunycodeParams
punycodeParams :: PunycodeParams
punycodeParams = PunycodeParams
{ base :: Int
base = Int
36
, tmin :: Int
tmin = Int
1
, tmax :: Int
tmax = Int
26
, skew :: Int
skew = Int
38
, damp :: Int
damp = Int
700
}