waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.JChar

Description

Types and functions for handling characters in JSON.

Synopsis

Types

data JChar digit Source #

A JChar may be unescaped or escaped.

Instances

Instances details
Functor JChar Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

fmap :: (a -> b) -> JChar a -> JChar b #

(<$) :: a -> JChar b -> JChar a #

Foldable JChar Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

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 #

toList :: JChar a -> [a] #

null :: JChar a -> Bool #

length :: JChar a -> Int #

elem :: Eq a => a -> JChar a -> Bool #

maximum :: Ord a => JChar a -> a #

minimum :: Ord a => JChar a -> a #

sum :: Num a => JChar a -> a #

product :: Num a => JChar a -> a #

Traversable JChar Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

traverse :: Applicative f => (a -> f b) -> JChar a -> f (JChar b) #

sequenceA :: Applicative f => JChar (f a) -> f (JChar a) #

mapM :: Monad m => (a -> m b) -> JChar a -> m (JChar b) #

sequence :: Monad m => JChar (m a) -> m (JChar a) #

Eq digit => Eq (JChar digit) Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

(==) :: JChar digit -> JChar digit -> Bool #

(/=) :: JChar digit -> JChar digit -> Bool #

Ord digit => Ord (JChar digit) Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

compare :: JChar digit -> JChar digit -> Ordering #

(<) :: JChar digit -> JChar digit -> Bool #

(<=) :: JChar digit -> JChar digit -> Bool #

(>) :: JChar digit -> JChar digit -> Bool #

(>=) :: JChar digit -> JChar digit -> Bool #

max :: JChar digit -> JChar digit -> JChar digit #

min :: JChar digit -> JChar digit -> JChar digit #

Show digit => Show (JChar digit) Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

showsPrec :: Int -> JChar digit -> ShowS #

show :: JChar digit -> String #

showList :: [JChar digit] -> ShowS #

AsUnescaped (JChar digit) Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

_Unescaped :: Prism' (JChar digit) Unescaped Source #

AsJString [JChar HeXDigit] Source # 
Instance details

Defined in Waargonaut.Types.JString

Methods

_JString :: Prism' [JChar HeXDigit] JString Source #

AsEscaped (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

_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 #

_Hex :: Prism' (JChar digit) (HexDigit4 digit) Source #

AsJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

_JChar :: Prism' (JChar digit) (JChar digit) Source #

_EscapedJChar :: Prism' (JChar digit) (Escaped digit) Source #

_UnescapedJChar :: Prism' (JChar digit) Unescaped Source #

HasJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

jChar :: Lens' (JChar digit) (JChar digit) Source #

class AsJChar r digit | r -> digit where Source #

Typeclass for things that be used as a JChar.

Minimal complete definition

_JChar

Methods

_JChar :: Prism' r (JChar digit) Source #

_EscapedJChar :: Prism' r (Escaped digit) Source #

_UnescapedJChar :: Prism' r Unescaped Source #

Instances

Instances details
AsJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

_JChar :: Prism' (JChar digit) (JChar digit) Source #

_EscapedJChar :: Prism' (JChar digit) (Escaped digit) Source #

_UnescapedJChar :: Prism' (JChar digit) Unescaped Source #

class HasJChar c digit | c -> digit where Source #

Typeclass for things that have a JChar.

Methods

jChar :: Lens' c (JChar digit) Source #

Instances

Instances details
HasJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

Methods

jChar :: Lens' (JChar digit) (JChar digit) Source #

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 #

Convert a Char to 'JChar HexDigit' and replace any invalid values with U+FFFD as per the Text documentation.

Refer to 'Text' documentation for more info.

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

jCharToChar :: JChar HeXDigit -> Char Source #

Convert a JChar to a Haskell Char

charToJChar :: Char -> Maybe (JChar HeXDigit) Source #

Attempt to convert a Haskell Char to a JSON acceptable JChar