waargonaut-0.8.0.1: JSON wrangling

Safe HaskellNone
LanguageHaskell2010

Waargonaut.Types.JArray

Contents

Description

JSON Array representation and functions.

Synopsis

Types

newtype JArray ws a Source #

Conveniently, a JSON array is a CommaSeparated list with an optional trailing comma, some instances and other functions need to work differently so we wrap it up in a newtype.

Constructors

JArray (CommaSeparated ws a) 
Instances
Bifunctor JArray Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

bimap :: (a -> b) -> (c -> d) -> JArray a c -> JArray b d #

first :: (a -> b) -> JArray a c -> JArray b c #

second :: (b -> c) -> JArray a b -> JArray a c #

Bitraversable JArray Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> JArray a b -> f (JArray c d) #

Bifoldable JArray Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

bifold :: Monoid m => JArray m m -> m #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> JArray a b -> m #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> JArray a b -> c #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> JArray a b -> c #

Functor (JArray ws) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

fmap :: (a -> b) -> JArray ws a -> JArray ws b #

(<$) :: a -> JArray ws b -> JArray ws a #

Foldable (JArray ws) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

fold :: Monoid m => JArray ws m -> m #

foldMap :: Monoid m => (a -> m) -> JArray ws a -> m #

foldr :: (a -> b -> b) -> b -> JArray ws a -> b #

foldr' :: (a -> b -> b) -> b -> JArray ws a -> b #

foldl :: (b -> a -> b) -> b -> JArray ws a -> b #

foldl' :: (b -> a -> b) -> b -> JArray ws a -> b #

foldr1 :: (a -> a -> a) -> JArray ws a -> a #

foldl1 :: (a -> a -> a) -> JArray ws a -> a #

toList :: JArray ws a -> [a] #

null :: JArray ws a -> Bool #

length :: JArray ws a -> Int #

elem :: Eq a => a -> JArray ws a -> Bool #

maximum :: Ord a => JArray ws a -> a #

minimum :: Ord a => JArray ws a -> a #

sum :: Num a => JArray ws a -> a #

product :: Num a => JArray ws a -> a #

Traversable (JArray ws) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

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

sequenceA :: Applicative f => JArray ws (f a) -> f (JArray ws a) #

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

sequence :: Monad m => JArray ws (m a) -> m (JArray ws a) #

(Eq ws, Eq a) => Eq (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

(==) :: JArray ws a -> JArray ws a -> Bool #

(/=) :: JArray ws a -> JArray ws a -> Bool #

(Show ws, Show a) => Show (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

showsPrec :: Int -> JArray ws a -> ShowS #

show :: JArray ws a -> String #

showList :: [JArray ws a] -> ShowS #

(Monoid ws, Semigroup ws) => Semigroup (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

(<>) :: JArray ws a -> JArray ws a -> JArray ws a #

sconcat :: NonEmpty (JArray ws a) -> JArray ws a #

stimes :: Integral b => b -> JArray ws a -> JArray ws a #

(Semigroup ws, Monoid ws) => Monoid (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

mempty :: JArray ws a #

mappend :: JArray ws a -> JArray ws a -> JArray ws a #

mconcat :: [JArray ws a] -> JArray ws a #

Ixed (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

ix :: Index (JArray ws a) -> Traversal' (JArray ws a) (IxValue (JArray ws a)) #

Wrapped (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Associated Types

type Unwrapped (JArray ws a) :: Type #

Methods

_Wrapped' :: Iso' (JArray ws a) (Unwrapped (JArray ws a)) #

(Semigroup ws, Monoid ws) => AsEmpty (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

_Empty :: Prism' (JArray ws a) () #

JArray ws a ~ t => Rewrapped (JArray ws a) t Source # 
Instance details

Defined in Waargonaut.Types.JArray

Monoid ws => Cons (JArray ws a) (JArray ws a) a a Source # 
Instance details

Defined in Waargonaut.Types.JArray

Methods

_Cons :: Prism (JArray ws a) (JArray ws a) (a, JArray ws a) (a, JArray ws a) #

type Index (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

type Index (JArray ws a) = Int
type IxValue (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

type IxValue (JArray ws a) = a
type Unwrapped (JArray ws a) Source # 
Instance details

Defined in Waargonaut.Types.JArray

type Unwrapped (JArray ws a) = CommaSeparated ws a

Parser

parseJArray :: (Monad f, CharParsing f) => f ws -> f a -> f (JArray ws a) Source #

Parse a single JSON array

>>> testparse (parseJArray parseWhitespace parseWaargonaut) "[null ]"
Right (JArray (CommaSeparated (WS []) (Just (Elems {_elemsElems = [], _elemsLast = Elem {_elemVal = Json (JNull (WS [Space])), _elemTrailing = Nothing}}))))
>>> testparse (parseJArray parseWhitespace parseWaargonaut) "[null,]"
Right (JArray (CommaSeparated (WS []) (Just (Elems {_elemsElems = [], _elemsLast = Elem {_elemVal = Json (JNull (WS [])), _elemTrailing = Just (Comma,WS [])}}))))