Safe Haskell | None |
---|---|
Language | Haskell2010 |
JSON Array representation and functions.
Synopsis
- newtype JArray ws a = JArray (CommaSeparated ws a)
- parseJArray :: (Monad f, CharParsing f) => f ws -> f a -> f (JArray ws a)
Types
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.
JArray (CommaSeparated ws a) |
Instances
Bitraversable JArray Source # | |
Defined in Waargonaut.Types.JArray bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> JArray a b -> f (JArray c d) # | |
Bifoldable JArray Source # | |
Bifunctor JArray Source # | |
Functor (JArray ws) Source # | |
Foldable (JArray ws) Source # | |
Defined in Waargonaut.Types.JArray fold :: Monoid m => JArray ws m -> m # foldMap :: Monoid m => (a -> m) -> JArray ws a -> 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] # 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 # | |
Traversable (JArray ws) Source # | |
Defined in Waargonaut.Types.JArray | |
(Eq ws, Eq a) => Eq (JArray ws a) Source # | |
(Show ws, Show a) => Show (JArray ws a) Source # | |
(Monoid ws, Semigroup ws) => Semigroup (JArray ws a) Source # | |
(Semigroup ws, Monoid ws) => Monoid (JArray ws a) Source # | |
Ixed (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray | |
(Semigroup ws, Monoid ws) => AsEmpty (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray | |
Wrapped (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray type Unwrapped (JArray ws a) | |
JArray ws a ~ t => Rewrapped (JArray ws a) t Source # | |
Defined in Waargonaut.Types.JArray | |
Monoid ws => Cons (JArray ws a) (JArray ws a) a a Source # | |
type Index (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray | |
type IxValue (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray type IxValue (JArray ws a) = a | |
type Unwrapped (JArray ws a) Source # | |
Defined in Waargonaut.Types.JArray |
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 [])}}))))