waargonaut-0.8.0.1: JSON wrangling

Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.JChar.Escaped

Contents

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

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

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

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

Minimal complete definition

_Escaped

Instances
AsEscaped (Escaped digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar.Escaped

AsEscaped (JChar digit) digit Source # 
Instance details

Defined in Waargonaut.Types.JChar

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