waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.JChar.Escaped

Description

Types and functions for handling escaped characters in JSON.

Synopsis

Types

data Escaped digit Source #

Things that may be escaped in a JSON string.

Instances

Instances details
Functor Escaped Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

Methods

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

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

Foldable Escaped Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

Methods

fold :: Monoid m => Escaped m -> m #

foldMap :: Monoid m => (a -> m) -> Escaped a -> m #

foldMap' :: Monoid m => (a -> m) -> Escaped a -> m #

foldr :: (a -> b -> b) -> b -> Escaped a -> b #

foldr' :: (a -> b -> b) -> b -> Escaped a -> b #

foldl :: (b -> a -> b) -> b -> Escaped a -> b #

foldl' :: (b -> a -> b) -> b -> Escaped a -> b #

foldr1 :: (a -> a -> a) -> Escaped a -> a #

foldl1 :: (a -> a -> a) -> Escaped a -> a #

toList :: Escaped a -> [a] #

null :: Escaped a -> Bool #

length :: Escaped a -> Int #

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

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

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

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

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

Traversable Escaped Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

Methods

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

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

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

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

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

Defined in Waargonaut.Types.JChar.Escaped

Methods

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

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

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

Defined in Waargonaut.Types.JChar.Escaped

Methods

compare :: Escaped digit -> Escaped digit -> Ordering #

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

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

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

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

max :: Escaped digit -> Escaped digit -> Escaped digit #

min :: Escaped digit -> Escaped digit -> Escaped digit #

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

Defined in Waargonaut.Types.JChar.Escaped

Methods

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

show :: Escaped digit -> String #

showList :: [Escaped digit] -> ShowS #

AsEscaped (Escaped digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

Methods

_Escaped :: Prism' (Escaped digit) (Escaped digit) Source #

_QuotationMark :: Prism' (Escaped digit) () Source #

_ReverseSolidus :: Prism' (Escaped digit) () Source #

_Solidus :: Prism' (Escaped digit) () Source #

_Backspace :: Prism' (Escaped digit) () Source #

_WhiteSpace :: Prism' (Escaped digit) Whitespace Source #

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

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

Typeclass for things that may be used as an escaped JChar.

Minimal complete definition

_Escaped

Methods

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

_QuotationMark :: Prism' r () Source #

_ReverseSolidus :: Prism' r () Source #

_Solidus :: Prism' r () Source #

_Backspace :: Prism' r () Source #

_WhiteSpace :: Prism' r Whitespace Source #

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

Instances

Instances details
AsEscaped (Escaped digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

Methods

_Escaped :: Prism' (Escaped digit) (Escaped digit) Source #

_QuotationMark :: Prism' (Escaped digit) () Source #

_ReverseSolidus :: Prism' (Escaped digit) () Source #

_Solidus :: Prism' (Escaped digit) () Source #

_Backspace :: Prism' (Escaped digit) () Source #

_WhiteSpace :: Prism' (Escaped digit) Whitespace Source #

_Hex :: Prism' (Escaped digit) (HexDigit4 digit) 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 #

Parser

parseEscaped :: (CharParsing f, HeXaDeCiMaL digit) => f (Escaped digit) Source #

Parse an escapted JSON character.

>>> testparse parseEscaped "\\\""
Right QuotationMark
>>> testparse parseEscaped "\\\\"
Right ReverseSolidus
>>> testparse parseEscaped "\\/"
Right Solidus
>>> testparse parseEscaped "\\b"
Right Backspace
>>> testparse parseEscaped "\\f"
Right (WhiteSpace LineFeed)
>>> testparse parseEscaped "\\n"
Right (WhiteSpace NewLine)
>>> testparse parseEscaped "\\r"
Right (WhiteSpace CarriageReturn)
>>> testparse parseEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>> testparse parseEscaped "\\u1234" :: Either DecodeError (Escaped HeXDigit)
Right (Hex (HexDigit4 HeXDigit1 HeXDigit2 HeXDigit3 HeXDigit4))
>>> testparsetheneof parseEscaped "\\t"
Right (WhiteSpace HorizontalTab)
>>> testparsethennoteof parseEscaped "\\tx"
Right (WhiteSpace HorizontalTab)

Conversion

escapedToChar :: Escaped HeXDigit -> Char Source #

Convert an Escaped character to a Haskell Char

charToEscaped :: Char -> Maybe (Escaped HeXDigit) Source #

Attempt to convert a Haskell Char to an Escaped JSON character