{-# 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 | StringEnd
| JValue AE.Value | JInteger CLong
deriving (Show, Eq)
data TokenResult = TokMoreData (BS.ByteString -> TokenResult)
| PartialResult Element (TokenResult)
| TokFailed
instance Show TokenResult where
show (TokMoreData _) = "TokMoreData"
show TokFailed = "TokFailed"
show (PartialResult el _) = "(PartialResult' " ++ show el ++ ")"