Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions for handling characters in JSON.
Synopsis
- data JChar digit
- = EscapedJChar (Escaped digit)
- | UnescapedJChar Unescaped
- class AsJChar r digit | r -> digit where
- _JChar :: Prism' r (JChar digit)
- _EscapedJChar :: Prism' r (Escaped digit)
- _UnescapedJChar :: Prism' r Unescaped
- class HasJChar c digit | c -> digit where
- parseJChar :: (CharParsing f, HeXaDeCiMaL digit) => f (JChar digit)
- utf8CharToJChar :: Char -> JChar HeXDigit
- jCharToUtf8Char :: JChar HeXDigit -> Maybe Char
- jCharToChar :: JChar HeXDigit -> Char
- charToJChar :: Char -> Maybe (JChar HeXDigit)
Types
A JChar may be unescaped or escaped.
EscapedJChar (Escaped digit) | |
UnescapedJChar Unescaped |
Instances
Functor JChar Source # | |
Foldable JChar Source # | |
Defined in Waargonaut.Types.JChar fold :: Monoid m => JChar m -> m # foldMap :: Monoid m => (a -> m) -> JChar a -> m # foldMap' :: Monoid m => (a -> m) -> JChar a -> m # foldr :: (a -> b -> b) -> b -> JChar a -> b # foldr' :: (a -> b -> b) -> b -> JChar a -> b # foldl :: (b -> a -> b) -> b -> JChar a -> b # foldl' :: (b -> a -> b) -> b -> JChar a -> b # foldr1 :: (a -> a -> a) -> JChar a -> a # foldl1 :: (a -> a -> a) -> JChar a -> a # elem :: Eq a => a -> JChar a -> Bool # maximum :: Ord a => JChar a -> a # minimum :: Ord a => JChar a -> a # | |
Traversable JChar Source # | |
Eq digit => Eq (JChar digit) Source # | |
Ord digit => Ord (JChar digit) Source # | |
Defined in Waargonaut.Types.JChar | |
Show digit => Show (JChar digit) Source # | |
AsUnescaped (JChar digit) Source # | |
Defined in Waargonaut.Types.JChar _Unescaped :: Prism' (JChar digit) Unescaped Source # | |
AsJString [JChar HeXDigit] Source # | |
AsEscaped (JChar digit) digit Source # | |
Defined in Waargonaut.Types.JChar _Escaped :: Prism' (JChar digit) (Escaped digit) Source # _QuotationMark :: Prism' (JChar digit) () Source # _ReverseSolidus :: Prism' (JChar digit) () Source # _Solidus :: Prism' (JChar digit) () Source # _Backspace :: Prism' (JChar digit) () Source # _WhiteSpace :: Prism' (JChar digit) Whitespace Source # | |
AsJChar (JChar digit) digit Source # | |
HasJChar (JChar digit) digit Source # | |
class AsJChar r digit | r -> digit where Source #
Typeclass for things that be used as a JChar
.
Parser
parseJChar :: (CharParsing f, HeXaDeCiMaL digit) => f (JChar digit) Source #
Parse a JSON character.
>>>
testparse parseJChar "\\u1234" :: Either DecodeError (JChar HeXDigit)
Right (EscapedJChar (Hex (HexDigit4 HeXDigit1 HeXDigit2 HeXDigit3 HeXDigit4)))
>>>
testparse parseJChar "\\\\" :: Either DecodeError (JChar HeXDigit)
Right (EscapedJChar ReverseSolidus)
>>>
testparse parseJChar "\\r"
Right (EscapedJChar (WhiteSpace CarriageReturn))
>>>
testparsetheneof parseJChar "a"
Right (UnescapedJChar (Unescaped 'a'))
>>>
testparsethennoteof parseJChar "ax"
Right (UnescapedJChar (Unescaped 'a'))
Conversion
utf8CharToJChar :: Char -> JChar HeXDigit Source #
jCharToUtf8Char :: JChar HeXDigit -> Maybe Char Source #
Try to convert a JChar
to a Text
safe Char
value. Refer to the link for more info:
https://hackage.haskell.org/package/text-1.2.3.0/docs/Data-Text-Internal.html#v:safe