Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types and functions for handling characters in JSON.
Synopsis
- data HexDigit4 d = HexDigit4 d d d d
- class HasHexDigit4 c d | c -> d where
- data JChar digit
- = EscapedJChar (JCharEscaped digit)
- | UnescapedJChar JCharUnescaped
- class AsJChar r digit | r -> digit where
- _JChar :: Prism' r (JChar digit)
- _EscapedJChar :: Prism' r (JCharEscaped digit)
- _UnescapedJChar :: Prism' r JCharUnescaped
- class HasJChar c digit | c -> digit where
- data JCharEscaped digit
- = QuotationMark
- | ReverseSolidus
- | Solidus
- | Backspace
- | WhiteSpace Whitespace
- | Hex (HexDigit4 digit)
- class AsJCharEscaped r digit | r -> digit where
- _JCharEscaped :: Prism' r (JCharEscaped digit)
- _QuotationMark :: Prism' r ()
- _ReverseSolidus :: Prism' r ()
- _Solidus :: Prism' r ()
- _Backspace :: Prism' r ()
- _WhiteSpace :: Prism' r Whitespace
- _Hex :: Prism' r (HexDigit4 digit)
- newtype JCharUnescaped = JCharUnescaped Char
- class AsJCharUnescaped a where
- parseJChar :: (CharParsing f, HeXaDeCiMaL digit) => f (JChar digit)
- parseJCharEscaped :: (CharParsing f, HeXaDeCiMaL digit) => f (JCharEscaped digit)
- parseJCharUnescaped :: CharParsing f => f JCharUnescaped
- jCharBuilder :: HeXaDeCiMaL digit => JChar digit -> Builder
- jCharToChar :: HeXaDeCiMaL digit => JChar digit -> Char
- utf8CharToJChar :: Char -> JChar HeXDigit
- jCharToUtf8Char :: JChar HeXDigit -> Maybe Char
Types
JSON Characters may be single escaped UTF16 "uab34".
HexDigit4 d d d d |
Instances
Functor HexDigit4 Source # | |
Foldable HexDigit4 Source # | |
Defined in Waargonaut.Types.JChar fold :: Monoid m => HexDigit4 m -> m # foldMap :: Monoid m => (a -> m) -> HexDigit4 a -> m # foldr :: (a -> b -> b) -> b -> HexDigit4 a -> b # foldr' :: (a -> b -> b) -> b -> HexDigit4 a -> b # foldl :: (b -> a -> b) -> b -> HexDigit4 a -> b # foldl' :: (b -> a -> b) -> b -> HexDigit4 a -> b # foldr1 :: (a -> a -> a) -> HexDigit4 a -> a # foldl1 :: (a -> a -> a) -> HexDigit4 a -> a # toList :: HexDigit4 a -> [a] # length :: HexDigit4 a -> Int # elem :: Eq a => a -> HexDigit4 a -> Bool # maximum :: Ord a => HexDigit4 a -> a # minimum :: Ord a => HexDigit4 a -> a # | |
Traversable HexDigit4 Source # | |
Eq d => Eq (HexDigit4 d) Source # | |
Ord d => Ord (HexDigit4 d) Source # | |
Defined in Waargonaut.Types.JChar | |
Show d => Show (HexDigit4 d) Source # | |
HasHexDigit4 (HexDigit4 d) d Source # | |
class HasHexDigit4 c d | c -> d where Source #
Typeclass for things that contain a HexDigit4
.
A JChar may be unescaped or escaped.
Instances
class AsJChar r digit | r -> digit where Source #
Typeclass for things that be used as a JChar
.
_JChar :: Prism' r (JChar digit) Source #
_EscapedJChar :: Prism' r (JCharEscaped digit) Source #
Instances
AsJChar Char HeXDigit Source # | |
Defined in Waargonaut.Types.JChar | |
AsJChar (JChar digit) digit Source # | |
Defined in Waargonaut.Types.JChar _JChar :: Prism' (JChar digit) (JChar digit) Source # _EscapedJChar :: Prism' (JChar digit) (JCharEscaped digit) Source # _UnescapedJChar :: Prism' (JChar digit) JCharUnescaped Source # |
data JCharEscaped digit Source #
Things that may be escaped in a JSON string.
Instances
class AsJCharEscaped r digit | r -> digit where Source #
Typeclass for things that may be used as an escaped JChar.
_JCharEscaped :: Prism' r (JCharEscaped digit) Source #
_QuotationMark :: Prism' r () Source #
_ReverseSolidus :: Prism' r () Source #
_Solidus :: Prism' r () Source #
_Backspace :: Prism' r () Source #
_WhiteSpace :: Prism' r Whitespace Source #
Instances
newtype JCharUnescaped Source #
Type to specify that this character is unescaped and may be represented
using a normal Haskell Char
.
Instances
class AsJCharUnescaped a where Source #
Typeclass for things that may used as an unescaped JChar.
Instances
AsJCharUnescaped Char Source # | |
Defined in Waargonaut.Types.JChar | |
AsJCharUnescaped JCharUnescaped Source # | |
Defined in Waargonaut.Types.JChar | |
AsJCharUnescaped (JChar digit) Source # | |
Defined in Waargonaut.Types.JChar _JCharUnescaped :: Prism' (JChar digit) JCharUnescaped Source # |
Parser / Builder
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 (JCharUnescaped 'a'))
>>>
testparsethennoteof parseJChar "ax"
Right (UnescapedJChar (JCharUnescaped 'a'))
parseJCharEscaped :: (CharParsing f, HeXaDeCiMaL digit) => f (JCharEscaped digit) Source #
Parse an escapted JSON character.
>>>
testparse parseJCharEscaped "\\\""
Right QuotationMark
>>>
testparse parseJCharEscaped "\\\\"
Right ReverseSolidus
>>>
testparse parseJCharEscaped "\\/"
Right Solidus
>>>
testparse parseJCharEscaped "\\b"
Right Backspace
>>>
testparse parseJCharEscaped "\\f"
Right (WhiteSpace LineFeed)
>>>
testparse parseJCharEscaped "\\n"
Right (WhiteSpace NewLine)
>>>
testparse parseJCharEscaped "\\r"
Right (WhiteSpace CarriageReturn)
>>>
testparse parseJCharEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>>
testparse parseJCharEscaped "\\u1234" :: Either DecodeError (JCharEscaped HeXDigit)
Right (Hex (HexDigit4 HeXDigit1 HeXDigit2 HeXDigit3 HeXDigit4))
>>>
testparsetheneof parseJCharEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>>
testparsethennoteof parseJCharEscaped "\\tx"
Right (WhiteSpace HorizontalTab)
parseJCharUnescaped :: CharParsing f => f JCharUnescaped Source #
Parse an unescaped JSON character.
>>>
testparse parseJCharUnescaped "a"
Right (JCharUnescaped 'a')
>>>
testparse parseJCharUnescaped "\8728"
Right (JCharUnescaped '\8728')
>>>
testparsetheneof parseJCharUnescaped "a"
Right (JCharUnescaped 'a')
>>>
testparsethennoteof parseJCharUnescaped "ax"
Right (JCharUnescaped 'a')
jCharBuilder :: HeXaDeCiMaL digit => JChar digit -> Builder Source #
jCharToChar :: HeXaDeCiMaL digit => JChar digit -> Char Source #