waargonaut-0.8.0.1: JSON wrangling

Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.JChar

Contents

Description

Types and functions for handling characters in JSON.

Synopsis

Types

data JChar digit Source #

A JChar may be unescaped or escaped.

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

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

AsJString [JChar HeXDigit] Source # 
Instance details

Defined in Waargonaut.Types.JString

AsEscaped (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

AsJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

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

Instances
AsJChar (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

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

Typeclass for things that have a JChar.

Methods

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

Instances
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.

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