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
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'))