{-# LANGUAGE OverloadedStrings #-}
module Data.JsonStream.TokenParser (
Element(..)
, TokenResult(..)
) where
import qualified Data.Aeson as AE
import qualified Data.ByteString.Char8 as BS
import Foreign.C.Types
data Element =
ArrayBegin
| ArrayEnd !BS.ByteString
| ObjectBegin
| ObjectEnd !BS.ByteString
| StringContent !BS.ByteString
| StringRaw !BS.ByteString !Bool
| StringEnd
| JValue !AE.Value
| JInteger !CLong
deriving (Int -> Element -> ShowS
[Element] -> ShowS
Element -> String
(Int -> Element -> ShowS)
-> (Element -> String) -> ([Element] -> ShowS) -> Show Element
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Element] -> ShowS
$cshowList :: [Element] -> ShowS
show :: Element -> String
$cshow :: Element -> String
showsPrec :: Int -> Element -> ShowS
$cshowsPrec :: Int -> Element -> ShowS
Show, Element -> Element -> Bool
(Element -> Element -> Bool)
-> (Element -> Element -> Bool) -> Eq Element
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Element -> Element -> Bool
$c/= :: Element -> Element -> Bool
== :: Element -> Element -> Bool
$c== :: Element -> Element -> Bool
Eq)
data TokenResult = TokMoreData (BS.ByteString -> TokenResult)
| PartialResult Element TokenResult
| TokFailed
instance Show TokenResult where
show :: TokenResult -> String
show (TokMoreData ByteString -> TokenResult
_) = String
"TokMoreData"
show TokenResult
TokFailed = String
"TokFailed"
show (PartialResult Element
el TokenResult
_) = String
"(PartialResult' " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Element -> String
forall a. Show a => a -> String
show Element
el String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"