module Basement.UTF8.Types
(
Step(..)
, StepBack(..)
, StepASCII(..)
, StepDigit(..)
, isValidStepASCII
, isValidStepDigit
, ValidationFailure(..)
, CharUTF8(..)
, CM (..)
) where
import Basement.Compat.Base
import Basement.Types.OffsetSize
data Step = Step {-# UNPACK #-} !Char {-# UNPACK #-} !(Offset Word8)
data StepBack = StepBack {-# UNPACK #-} !Char {-# UNPACK #-} !(Offset Word8)
newtype StepDigit = StepDigit Word8
newtype StepASCII = StepASCII { StepASCII -> Word8
stepAsciiRawValue :: Word8 }
data CM = CM {-# UNPACK #-} !Char {-# UNPACK #-} !Char {-# UNPACK #-} !Char deriving (CM -> CM -> Bool
(CM -> CM -> Bool) -> (CM -> CM -> Bool) -> Eq CM
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CM -> CM -> Bool
$c/= :: CM -> CM -> Bool
== :: CM -> CM -> Bool
$c== :: CM -> CM -> Bool
Eq)
newtype CharUTF8 = CharUTF8 Word32
isValidStepASCII :: StepASCII -> Bool
isValidStepASCII :: StepASCII -> Bool
isValidStepASCII (StepASCII Word8
w) = Word8
w Word8 -> Word8 -> Bool
forall a. Ord a => a -> a -> Bool
< Word8
0x80
isValidStepDigit :: StepDigit -> Bool
isValidStepDigit :: StepDigit -> Bool
isValidStepDigit (StepDigit Word8
w) = Word8
w Word8 -> Word8 -> Bool
forall a. Ord a => a -> a -> Bool
< Word8
0xa
data ValidationFailure =
| InvalidContinuation
| MissingByte
| BuildingFailure
deriving (Int -> ValidationFailure -> ShowS
[ValidationFailure] -> ShowS
ValidationFailure -> String
(Int -> ValidationFailure -> ShowS)
-> (ValidationFailure -> String)
-> ([ValidationFailure] -> ShowS)
-> Show ValidationFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidationFailure] -> ShowS
$cshowList :: [ValidationFailure] -> ShowS
show :: ValidationFailure -> String
$cshow :: ValidationFailure -> String
showsPrec :: Int -> ValidationFailure -> ShowS
$cshowsPrec :: Int -> ValidationFailure -> ShowS
Show,ValidationFailure -> ValidationFailure -> Bool
(ValidationFailure -> ValidationFailure -> Bool)
-> (ValidationFailure -> ValidationFailure -> Bool)
-> Eq ValidationFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidationFailure -> ValidationFailure -> Bool
$c/= :: ValidationFailure -> ValidationFailure -> Bool
== :: ValidationFailure -> ValidationFailure -> Bool
$c== :: ValidationFailure -> ValidationFailure -> Bool
Eq,Typeable)
instance Exception ValidationFailure